OpenDDS  Snapshot(2023/04/07-19:43)
Public Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::PriorityKey Class Reference

Encapsulate a priority value and internet address as a key. More...

#include <PriorityKey.h>

Collaboration diagram for OpenDDS::DCPS::PriorityKey:
Collaboration graph
[legend]

Public Member Functions

 PriorityKey ()
 
 PriorityKey (Priority priority, ACE_INET_Addr address, bool is_loopback, bool active)
 
bool operator< (const PriorityKey &rhs) const
 
bool operator== (const PriorityKey &rhs) const
 
unsigned long hash () const
 
Prioritypriority ()
 
Priority priority () const
 
ACE_INET_Addraddress ()
 
ACE_INET_Addr address () const
 
bool & is_loopback ()
 
bool is_loopback () const
 
bool & is_active ()
 
bool is_active () const
 

Private Attributes

Priority priority_
 
ACE_INET_Addr address_
 
bool is_loopback_
 
bool is_active_
 

Detailed Description

Encapsulate a priority value and internet address as a key.

This class is encapsulates a priority value and an internet address value for use as a key in either an STL container or an ACE hash container. The '<' operator is used by the STL containers and the '==' operator and hash() method are used by the ACE hash map container(s). The ACE hash map container(s) also require the use of a default constructor as well.

To use keys of this type as an STL container key, simply include this type as the key template parameter. An example usage is:

typedef std::map<PriorityKey, ValueType> PriorityMap;

To use this type as an ACE hash container key, use the function object templates ACE_Hash and ACE_Equal_To for the HASH_KEY and COMPARE_KEYS template parameters. An example usage is:

typedef ACE_Hash_Map_Manager_Ex< PriorityKey, ValueType, ACE_Hash<PriorityKey>, ACE_Equal_To<PriorityKey>, SynchType > PriorityHashMap;

Default copy constructor and assigment are sufficient. Readonly and read/write accessors for member data are provided.

Definition at line 52 of file PriorityKey.h.

Constructor & Destructor Documentation

◆ PriorityKey() [1/2]

ACE_INLINE OpenDDS::DCPS::PriorityKey::PriorityKey ( )

Definition at line 14 of file PriorityKey.inl.

References ACE_INLINE.

15  : priority_(0), is_loopback_(false), is_active_(false)
16 {
17 }

◆ PriorityKey() [2/2]

ACE_INLINE OpenDDS::DCPS::PriorityKey::PriorityKey ( Priority  priority,
ACE_INET_Addr  address,
bool  is_loopback,
bool  active 
)

Definition at line 20 of file PriorityKey.inl.

References ACE_INLINE.

Member Function Documentation

◆ address() [1/2]

ACE_INLINE ACE_INET_Addr & OpenDDS::DCPS::PriorityKey::address ( void  )

◆ address() [2/2]

ACE_INLINE ACE_INET_Addr OpenDDS::DCPS::PriorityKey::address ( void  ) const

Definition at line 79 of file PriorityKey.inl.

References ACE_INLINE, and address_.

80 {
81  return this->address_;
82 }

◆ hash()

ACE_INLINE unsigned long OpenDDS::DCPS::PriorityKey::hash ( void  ) const

Definition at line 50 of file PriorityKey.inl.

References ACE_INLINE, address_, ACE_INET_Addr::hash(), is_active_, is_loopback_, and priority_.

51 {
52  return (this->priority_ << 16) + this->address_.hash() + this->is_loopback_
53  + this->is_active_;
54 }
virtual u_long hash(void) const

◆ is_active() [1/2]

ACE_INLINE bool & OpenDDS::DCPS::PriorityKey::is_active ( )

◆ is_active() [2/2]

ACE_INLINE bool OpenDDS::DCPS::PriorityKey::is_active ( ) const

Definition at line 107 of file PriorityKey.inl.

References is_active_, and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

108 {
109  return this->is_active_;
110 }

◆ is_loopback() [1/2]

ACE_INLINE bool & OpenDDS::DCPS::PriorityKey::is_loopback ( void  )

◆ is_loopback() [2/2]

ACE_INLINE bool OpenDDS::DCPS::PriorityKey::is_loopback ( void  ) const

Definition at line 93 of file PriorityKey.inl.

References ACE_INLINE, and is_loopback_.

94 {
95  return this->is_loopback_;
96 }

◆ operator<()

ACE_INLINE bool OpenDDS::DCPS::PriorityKey::operator< ( const PriorityKey rhs) const

Definition at line 27 of file PriorityKey.inl.

References ACE_INLINE, address_, is_active_, is_loopback_, and priority_.

28 {
29  return (this->address_ < rhs.address_)? true:
30  (rhs.address_ < this->address_)? false:
31  this->priority_ < rhs.priority_? true:
32  (rhs.priority_ < this->priority_)? false :
33  (this->is_loopback_ != rhs.is_loopback_) ? rhs.is_loopback_ :
34  (this->is_active_ != rhs.is_active_) ? rhs.is_active_ :
35  false;
36 }

◆ operator==()

ACE_INLINE bool OpenDDS::DCPS::PriorityKey::operator== ( const PriorityKey rhs) const

Definition at line 40 of file PriorityKey.inl.

References ACE_INLINE, address_, is_active_, is_loopback_, and priority_.

41 {
42  return (this->priority_ == rhs.priority_)
43  && (this->address_ == rhs.address_)
44  && (this->is_loopback_ == rhs.is_loopback_)
45  && (this->is_active_ == rhs.is_active_);
46 }

◆ priority() [1/2]

ACE_INLINE Priority & OpenDDS::DCPS::PriorityKey::priority ( void  )

◆ priority() [2/2]

ACE_INLINE Priority OpenDDS::DCPS::PriorityKey::priority ( void  ) const

Definition at line 65 of file PriorityKey.inl.

References ACE_INLINE, and priority_.

66 {
67  return this->priority_;
68 }

Member Data Documentation

◆ address_

ACE_INET_Addr OpenDDS::DCPS::PriorityKey::address_
private

Definition at line 88 of file PriorityKey.h.

Referenced by address(), hash(), operator<(), and operator==().

◆ is_active_

bool OpenDDS::DCPS::PriorityKey::is_active_
private

Definition at line 91 of file PriorityKey.h.

Referenced by hash(), is_active(), operator<(), and operator==().

◆ is_loopback_

bool OpenDDS::DCPS::PriorityKey::is_loopback_
private

Definition at line 90 of file PriorityKey.h.

Referenced by hash(), is_loopback(), operator<(), and operator==().

◆ priority_

Priority OpenDDS::DCPS::PriorityKey::priority_
private

Definition at line 85 of file PriorityKey.h.

Referenced by hash(), operator<(), operator==(), and priority().


The documentation for this class was generated from the following files: