OpenDDS::DCPS::GuidConverter Class Reference

Conversion processing and value testing utilities for RTPS GUID_t types. More...

#include <GuidConverter.h>

Inheritance diagram for OpenDDS::DCPS::GuidConverter:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::GuidConverter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GuidConverter (const GUID_t &guid)
 Construct from a GUID_t.
virtual ~GuidConverter ()
 Virtual destructor (this is a base class).
long checksum () const
 Calculate the CRC32 checksum.
long vendorId () const
 Extract the VendorId value.
long entityId () const
 Extract the EntityId value.
long entityKey () const
 Extract the EntityKey value.
EntityKind entityKind () const
 Extract the EntityKind value.
 operator OPENDDS_STRING () const
 Convert to diagnostic string.
OPENDDS_STRING uniqueId () const

Protected Attributes

const GUID_t guid_

Detailed Description

Conversion processing and value testing utilities for RTPS GUID_t types.

This class encapsulates the conversion of a GUID_t value to and from other types used within OpenDDS. This class handles opaque GUID_t values only. For specific access, the appropriate subclass must instead be used.

Since the GUID_t type is formed of octets in network order, we do all processing byte by byte to avoid any endian issues.

Currently the GUID_t is mapped from various internal values. These mappings are:

byte structure reference content ---- --------------------- -------------------------- 0 GUID_t.guidPrefix[ 0] == VendorId_t == 0x01 for OCI (used for OpenDDS) 1 GUID_t.guidPrefix[ 1] == VendorId_t == 0x03 for OCI (used for OpenDDS) 2 GUID_t.guidPrefix[ 2] == 0x00 3 GUID_t.guidPrefix[ 3] == 0x00

4 GUID_t.guidPrefix[ 4] == <private> (MS byte) 5 GUID_t.guidPrefix[ 5] == <private> 6 GUID_t.guidPrefix[ 6] == <private> 7 GUID_t.guidPrefix[ 7] == <private> (LS byte)

8 GUID_t.guidPrefix[ 8] == <private> (MS byte) 9 GUID_t.guidPrefix[ 9] == <private> 10 GUID_t.guidPrefix[10] == <private> 11 GUID_t.guidPrefix[11] == <private> (LS byte)

12 GUID_t.entityId.entityKey[ 0] == entity id[0] (MS byte) 13 GUID_t.entityId.entityKey[ 1] == entity id[1] 14 GUID_t.entityId.entityKey[ 2] == entity id[2] (LS byte) 15 GUID_t.entityId.entityKind == entity kind

Definition at line 63 of file GuidConverter.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::GuidConverter::GuidConverter ( const GUID_t guid  ) 

Construct from a GUID_t.

Definition at line 19 of file GuidConverter.cpp.

00020   : guid_(guid)
00021 {}

OpenDDS::DCPS::GuidConverter::~GuidConverter (  )  [virtual]

Virtual destructor (this is a base class).

Definition at line 23 of file GuidConverter.cpp.

00024 {}


Member Function Documentation

long OpenDDS::DCPS::GuidConverter::checksum (  )  const

Calculate the CRC32 checksum.

Definition at line 27 of file GuidConverter.cpp.

References guid_.

Referenced by operator OPENDDS_STRING().

00028 {
00029   return ACE::crc32(reinterpret_cast<const void*>(&guid_), sizeof(guid_));
00030 }

long OpenDDS::DCPS::GuidConverter::entityId (  )  const

Extract the EntityId value.

Definition at line 40 of file GuidConverter.cpp.

References OpenDDS::DCPS::GUID_t::entityId, entityKey(), OpenDDS::DCPS::EntityId_t::entityKind, and guid_.

00041 {
00042   return entityKey() << 8
00043          | guid_.entityId.entityKind;
00044 }

long OpenDDS::DCPS::GuidConverter::entityKey (  )  const

Extract the EntityKey value.

Definition at line 47 of file GuidConverter.cpp.

References OpenDDS::DCPS::GUID_t::entityId, OpenDDS::DCPS::EntityId_t::entityKey, and guid_.

Referenced by TAO_DDS_DCPSInfo_i::add_publication(), TAO_DDS_DCPSInfo_i::add_subscription(), TAO_DDS_DCPSInfo_i::add_topic(), and entityId().

00048 {
00049   return guid_.entityId.entityKey[0] << 16
00050          | guid_.entityId.entityKey[1] << 8
00051          | guid_.entityId.entityKey[2];
00052 }

EntityKind OpenDDS::DCPS::GuidConverter::entityKind (  )  const

Extract the EntityKind value.

Definition at line 55 of file GuidConverter.cpp.

References OpenDDS::DCPS::GUID_t::entityId, OpenDDS::DCPS::EntityId_t::entityKind, OpenDDS::DCPS::ENTITYKIND_BUILTIN_PARTICIPANT, OpenDDS::DCPS::ENTITYKIND_BUILTIN_READER_NO_KEY, OpenDDS::DCPS::ENTITYKIND_BUILTIN_READER_WITH_KEY, OpenDDS::DCPS::ENTITYKIND_BUILTIN_UNKNOWN, OpenDDS::DCPS::ENTITYKIND_BUILTIN_WRITER_NO_KEY, OpenDDS::DCPS::ENTITYKIND_BUILTIN_WRITER_WITH_KEY, OpenDDS::DCPS::ENTITYKIND_OPENDDS_NIL_WRITER, OpenDDS::DCPS::ENTITYKIND_OPENDDS_PUBLISHER, OpenDDS::DCPS::ENTITYKIND_OPENDDS_SUBSCRIBER, OpenDDS::DCPS::ENTITYKIND_OPENDDS_TOPIC, OpenDDS::DCPS::ENTITYKIND_OPENDDS_USER, OpenDDS::DCPS::ENTITYKIND_USER_READER_NO_KEY, OpenDDS::DCPS::ENTITYKIND_USER_READER_WITH_KEY, OpenDDS::DCPS::ENTITYKIND_USER_UNKNOWN, OpenDDS::DCPS::ENTITYKIND_USER_WRITER_NO_KEY, OpenDDS::DCPS::ENTITYKIND_USER_WRITER_WITH_KEY, guid_, OpenDDS::DCPS::KIND_PARTICIPANT, OpenDDS::DCPS::KIND_PUBLISHER, OpenDDS::DCPS::KIND_READER, OpenDDS::DCPS::KIND_SUBSCRIBER, OpenDDS::DCPS::KIND_TOPIC, OpenDDS::DCPS::KIND_UNKNOWN, OpenDDS::DCPS::KIND_USER, and OpenDDS::DCPS::KIND_WRITER.

Referenced by OpenDDS::DCPS::RtpsUdpDataLink::associated(), OpenDDS::DCPS::RtpsUdpDataLink::check_handshake_complete(), and OpenDDS::DCPS::RtpsUdpDataLink::release_reservations_i().

00056 {
00057   switch (guid_.entityId.entityKind) {
00058   case ENTITYKIND_OPENDDS_TOPIC:
00059     return KIND_TOPIC;
00060 
00061   case ENTITYKIND_USER_READER_NO_KEY:
00062   case ENTITYKIND_USER_READER_WITH_KEY:
00063   case ENTITYKIND_BUILTIN_READER_NO_KEY:
00064   case ENTITYKIND_BUILTIN_READER_WITH_KEY:
00065     return KIND_READER;
00066 
00067   case ENTITYKIND_USER_WRITER_NO_KEY:
00068   case ENTITYKIND_USER_WRITER_WITH_KEY:
00069   case ENTITYKIND_BUILTIN_WRITER_NO_KEY:
00070   case ENTITYKIND_BUILTIN_WRITER_WITH_KEY:
00071   case ENTITYKIND_OPENDDS_NIL_WRITER:
00072     return KIND_WRITER;
00073 
00074   case ENTITYKIND_BUILTIN_PARTICIPANT:
00075     return KIND_PARTICIPANT;
00076 
00077   case ENTITYKIND_OPENDDS_PUBLISHER:
00078     return KIND_PUBLISHER;
00079 
00080   case ENTITYKIND_OPENDDS_SUBSCRIBER:
00081     return KIND_SUBSCRIBER;
00082 
00083   case ENTITYKIND_OPENDDS_USER:
00084     return KIND_USER;
00085 
00086   case ENTITYKIND_USER_UNKNOWN:
00087   case ENTITYKIND_BUILTIN_UNKNOWN:
00088   default:
00089     return KIND_UNKNOWN;
00090   }
00091 }

OpenDDS::DCPS::GuidConverter::operator OPENDDS_STRING (  )  const

Convert to diagnostic string.

Definition at line 93 of file GuidConverter.cpp.

References checksum(), guid_, OPENDDS_STRING, OpenDDS::DCPS::to_dds_string(), and OpenDDS::DCPS::to_string().

00094 {
00095 
00096   OPENDDS_STRING ret(to_string(guid_));
00097   ret += "(";
00098   ret += to_dds_string((unsigned long) checksum(), true);
00099   ret += ")";
00100 
00101   return ret;
00102 }

OPENDDS_STRING OpenDDS::DCPS::GuidConverter::uniqueId (  )  const

Definition at line 133 of file GuidConverter.cpp.

References guid_, and OpenDDS::DCPS::GUID_t::guidPrefix.

00134 {
00135   char id[64];
00136   ACE_OS::snprintf(id, sizeof id,
00137           "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
00138           guid_.guidPrefix[ 0],
00139           guid_.guidPrefix[ 1],
00140           guid_.guidPrefix[ 2],
00141           guid_.guidPrefix[ 3],
00142           guid_.guidPrefix[ 4],
00143           guid_.guidPrefix[ 5],
00144           guid_.guidPrefix[ 6],
00145           guid_.guidPrefix[ 7],
00146           guid_.guidPrefix[ 8],
00147           guid_.guidPrefix[ 9],
00148           guid_.guidPrefix[10],
00149           guid_.guidPrefix[11]);
00150   return id;
00151 }

long OpenDDS::DCPS::GuidConverter::vendorId (  )  const

Extract the VendorId value.

Definition at line 33 of file GuidConverter.cpp.

References guid_, and OpenDDS::DCPS::GUID_t::guidPrefix.

00034 {
00035   return guid_.guidPrefix[0] << 8
00036          | guid_.guidPrefix[1];
00037 }


Member Data Documentation

const GUID_t OpenDDS::DCPS::GuidConverter::guid_ [protected]

Definition at line 95 of file GuidConverter.h.

Referenced by checksum(), entityId(), entityKey(), entityKind(), OpenDDS::DCPS::RepoIdConverter::federationId(), operator OPENDDS_STRING(), OpenDDS::DCPS::RepoIdConverter::participantId(), uniqueId(), and vendorId().


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:18 2016 for OpenDDS by  doxygen 1.4.7