OpenDDS  Snapshot(2023/04/28-20:55)
PriorityKey.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_PRIORITYKEY_H
9 #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_PRIORITYKEY_H
10 
11 #include "dds/DCPS/dcps_export.h"
12 #include "TransportDefs.h"
13 #include "ace/INET_Addr.h"
14 
16 
17 namespace OpenDDS {
18 namespace DCPS {
19 
20 /**
21  * @class PriorityKey
22  *
23  * @brief Encapsulate a priority value and internet address as a key.
24  *
25  * This class is encapsulates a priority value and an
26  * internet address value for use as a key in either an STL container
27  * or an ACE hash container. The '<' operator is used by the STL
28  * containers and the '==' operator and hash() method are used by the
29  * ACE hash map container(s). The ACE hash map container(s) also
30  * require the use of a default constructor as well.
31  *
32  * To use keys of this type as an STL container key, simply include
33  * this type as the key template parameter. An example usage is:
34  *
35  * typedef std::map<PriorityKey, ValueType> PriorityMap;
36  *
37  * To use this type as an ACE hash container key, use the function
38  * object templates ACE_Hash and ACE_Equal_To for the HASH_KEY and
39  * COMPARE_KEYS template parameters. An example usage is:
40  *
41  * typedef ACE_Hash_Map_Manager_Ex<
42  * PriorityKey,
43  * ValueType,
44  * ACE_Hash<PriorityKey>,
45  * ACE_Equal_To<PriorityKey>,
46  * SynchType
47  * > PriorityHashMap;
48  *
49  * Default copy constructor and assigment are sufficient. Readonly
50  * and read/write accessors for member data are provided.
51  */
53 public:
54  // Default constructor.
55  PriorityKey();
56 
57  // Construct with values.
58  PriorityKey(Priority priority, ACE_INET_Addr address, bool is_loopback, bool active);
59 
60  // Ordering for STL containers.
61  bool operator<(const PriorityKey& rhs) const;
62 
63  // Ordering (location identification) for ACE_Hash_Map_Manager_Ex.
64  bool operator==(const PriorityKey& rhs) const;
65 
66  // Identity for ACE_Hash_Map_Manager_Ex.
67  unsigned long hash() const;
68 
69  // Access priority value.
70  Priority& priority();
71  Priority priority() const;
72 
73  // Access address value.
74  ACE_INET_Addr& address();
75  ACE_INET_Addr address() const;
76 
77  bool& is_loopback();
78  bool is_loopback() const;
79 
80  bool& is_active();
81  bool is_active() const;
82 
83 private:
84  // Priority value of key.
86 
87  // Address value of key.
89 
91  bool is_active_;
92 };
93 
94 } // namespace DCPS
95 } // namespace OpenDDS
96 
98 
99 #if defined (__ACE_INLINE__)
100 #include "PriorityKey.inl"
101 #endif /* __ACE_INLINE__ */
102 
103 #endif /* PRIORITY_KEY_H */
int hash(const std::vector< const DDS::OctetSeq *> &src, DDS::OctetSeq &dst)
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
Encapsulate a priority value and internet address as a key.
Definition: PriorityKey.h:52
bool operator==(const DisjointSequence::OrderedRanges< T > &a, const DisjointSequence::OrderedRanges< T > &b)
ACE_CDR::Long Priority
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool operator<(const GUID_t &lhs, const GUID_t &rhs)
Definition: GuidUtils.h:80