PriorityKey.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef PRIORITY_KEY_H
00009 #define PRIORITY_KEY_H
00010 
00011 #include "dds/DCPS/dcps_export.h"
00012 #include "TransportDefs.h"
00013 #include "ace/INET_Addr.h"
00014 
00015 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00016 
00017 namespace OpenDDS {
00018 namespace DCPS {
00019 
00020 /**
00021  * @class PriorityKey
00022  *
00023  * @brief Encapsulate a priority value and internet address as a key.
00024  *
00025  * This class is encapsulates a priority value and an
00026  * internet address value for use as a key in either an STL container
00027  * or an ACE hash container.  The '<' operator is used by the STL
00028  * containers and the '==' operator and hash() method are used by the
00029  * ACE hash map container(s).  The ACE hash map container(s) also
00030  * require the use of a default constructor as well.
00031  *
00032  * To use keys of this type as an STL container key, simply include
00033  * this type as the key template parameter.  An example usage is:
00034  *
00035  *   typedef std::map<PriorityKey, ValueType> PriorityMap;
00036  *
00037  * To use this type as an ACE hash container key, use the function
00038  * object templates ACE_Hash and ACE_Equal_To for the HASH_KEY and
00039  * COMPARE_KEYS template parameters.  An example usage is:
00040  *
00041  *   typedef ACE_Hash_Map_Manager_Ex<
00042  *             PriorityKey,
00043  *             ValueType,
00044  *             ACE_Hash<PriorityKey>,
00045  *             ACE_Equal_To<PriorityKey>,
00046  *             SynchType
00047  *           > PriorityHashMap;
00048  *
00049  *  Default copy constructor and assigment are sufficient.  Readonly
00050  *  and read/write accessors for member data are provided.
00051  */
00052 class OpenDDS_Dcps_Export PriorityKey {
00053 public:
00054   // Default constructor.
00055   PriorityKey();
00056 
00057   // Construct with values.
00058   PriorityKey(Priority priority, ACE_INET_Addr address, bool is_loopback, bool active);
00059 
00060   // Ordering for STL containers.
00061   bool operator<(const PriorityKey& rhs) const;
00062 
00063   // Ordering (location identification) for ACE_Hash_Map_Manager_Ex.
00064   bool operator==(const PriorityKey& rhs) const;
00065 
00066   // Identity for ACE_Hash_Map_Manager_Ex.
00067   unsigned long hash() const;
00068 
00069   // Access priority value.
00070   Priority& priority();
00071   Priority  priority() const;
00072 
00073   // Access address value.
00074   ACE_INET_Addr& address();
00075   ACE_INET_Addr  address() const;
00076 
00077   bool& is_loopback();
00078   bool  is_loopback() const;
00079 
00080   bool& is_active();
00081   bool  is_active() const;
00082 
00083 private:
00084   // Priority value of key.
00085   Priority priority_;
00086 
00087   // Address value of key.
00088   ACE_INET_Addr address_;
00089 
00090   bool is_loopback_;
00091   bool is_active_;
00092 };
00093 
00094 } // namespace DCPS
00095 } // namespace OpenDDS
00096 
00097 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00098 
00099 #if defined (__ACE_INLINE__)
00100 #include "PriorityKey.inl"
00101 #endif /* __ACE_INLINE__ */
00102 
00103 #endif  /* PRIORITY_KEY_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1