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 namespace OpenDDS {
00016 namespace DCPS {
00017 
00018 /**
00019  * @class PriorityKey
00020  *
00021  * @brief Encapsulate a priority value and internet address as a key.
00022  *
00023  * This class is encapsulates a priority value and an
00024  * internet address value for use as a key in either an STL container
00025  * or an ACE hash container.  The '<' operator is used by the STL
00026  * containers and the '==' operator and hash() method are used by the
00027  * ACE hash map container(s).  The ACE hash map container(s) also
00028  * require the use of a default constructor as well.
00029  *
00030  * To use keys of this type as an STL container key, simply include
00031  * this type as the key template parameter.  An example usage is:
00032  *
00033  *   typedef std::map<PriorityKey, ValueType> PriorityMap;
00034  *
00035  * To use this type as an ACE hash container key, use the function
00036  * object templates ACE_Hash and ACE_Equal_To for the HASH_KEY and
00037  * COMPARE_KEYS template parameters.  An example usage is:
00038  *
00039  *   typedef ACE_Hash_Map_Manager_Ex<
00040  *             PriorityKey,
00041  *             ValueType,
00042  *             ACE_Hash<PriorityKey>,
00043  *             ACE_Equal_To<PriorityKey>,
00044  *             SynchType
00045  *           > PriorityHashMap;
00046  *
00047  *  Default copy constructor and assigment are sufficient.  Readonly
00048  *  and read/write accessors for member data are provided.
00049  */
00050 class OpenDDS_Dcps_Export PriorityKey {
00051 public:
00052   // Default constructor.
00053   PriorityKey();
00054 
00055   // Construct with values.
00056   PriorityKey(Priority priority, ACE_INET_Addr address, bool is_loopback, bool active);
00057 
00058   // Ordering for STL containers.
00059   bool operator<(const PriorityKey& rhs) const;
00060 
00061   // Ordering (location identification) for ACE_Hash_Map_Manager_Ex.
00062   bool operator==(const PriorityKey& rhs) const;
00063 
00064   // Identity for ACE_Hash_Map_Manager_Ex.
00065   unsigned long hash() const;
00066 
00067   // Access priority value.
00068   Priority& priority();
00069   Priority  priority() const;
00070 
00071   // Access address value.
00072   ACE_INET_Addr& address();
00073   ACE_INET_Addr  address() const;
00074 
00075   bool& is_loopback();
00076   bool  is_loopback() const;
00077 
00078   bool& is_active();
00079   bool  is_active() const;
00080 
00081 private:
00082   // Priority value of key.
00083   Priority priority_;
00084 
00085   // Address value of key.
00086   ACE_INET_Addr address_;
00087 
00088   bool is_loopback_;
00089   bool is_active_;
00090 };
00091 
00092 } // namespace DCPS
00093 } // namespace OpenDDS
00094 
00095 #if defined (__ACE_INLINE__)
00096 #include "PriorityKey.inl"
00097 #endif /* __ACE_INLINE__ */
00098 
00099 #endif  /* PRIORITY_KEY_H */

Generated on Fri Feb 12 20:05:24 2016 for OpenDDS by  doxygen 1.4.7