OpenDDS::DCPS::Data_Types_Register Class Reference

#include <Registered_Data_Types.h>

List of all members.

Public Member Functions

DDS::ReturnCode_t register_type (DDS::DomainParticipant_ptr domain_participant, const char *type_name, TypeSupport_ptr the_type)
DDS::ReturnCode_t unregister_participant (DDS::DomainParticipant_ptr domain_participant)
TypeSupport_ptr lookup (DDS::DomainParticipant_ptr domain_participant, const char *type_name) const

Static Public Member Functions

static Data_Types_Registerinstance ()
 Return a singleton instance of this class.

Private Member Functions

 Data_Types_Register ()
 ~Data_Types_Register ()

Private Attributes

ACE_SYNCH_MUTEX lock_
ParticipantMap participants_

Friends

class ACE_Singleton< Data_Types_Register, ACE_SYNCH_MUTEX >


Detailed Description

A singleton class that keeps track of the registered DDS data types local to this process. Data types are registered by domain participant.

Definition at line 35 of file Registered_Data_Types.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::Data_Types_Register::Data_Types_Register (  )  [private]

Definition at line 22 of file Registered_Data_Types.cpp.

00023 {
00024 }

OpenDDS::DCPS::Data_Types_Register::~Data_Types_Register (  )  [private]

Definition at line 26 of file Registered_Data_Types.cpp.

00027 {
00028 }


Member Function Documentation

Data_Types_Register * OpenDDS::DCPS::Data_Types_Register::instance (  )  [static]

Return a singleton instance of this class.

Definition at line 31 of file Registered_Data_Types.cpp.

00032 {
00033   return ACE_Singleton<Data_Types_Register, ACE_SYNCH_MUTEX>::instance();
00034 }

TypeSupport_ptr OpenDDS::DCPS::Data_Types_Register::lookup ( DDS::DomainParticipant_ptr  domain_participant,
const char *  type_name 
) const

Find a data type by its type name.

Returns:
the TypeSupport object registered as type_name Otherwise returns TypeSupport::_nil()

Definition at line 68 of file Registered_Data_Types.cpp.

References lock_, and participants_.

00071 {
00072   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, 0);
00073 
00074   ParticipantMap::const_iterator iter1 = participants_.find(domain_participant);
00075   if (iter1 == participants_.end()) {
00076     return 0;
00077   }
00078 
00079   TypeSupportMap::const_iterator iter2 = iter1->second.find(type_name);
00080   if (iter2 == iter1->second.end()) {
00081     return 0;
00082   }
00083 
00084   TypeSupport_var typeSupport = iter2->second;
00085   return typeSupport._retn();
00086 }

DDS::ReturnCode_t OpenDDS::DCPS::Data_Types_Register::register_type ( DDS::DomainParticipant_ptr  domain_participant,
const char *  type_name,
TypeSupport_ptr  the_type 
)

Register a type.

Returns:
RETCODE_OK if the type_name is unique to the domain participant or the type_name is already registered to the_type's class. Otherwise returns RETCODE_ERROR

Definition at line 36 of file Registered_Data_Types.cpp.

References lock_, participants_, DDS::RETCODE_ERROR, and DDS::RETCODE_OK.

00040 {
00041   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, DDS::RETCODE_ERROR);
00042 
00043   TypeSupportMap& tsm = participants_[domain_participant];
00044   const TypeSupport_var typeSupport = TypeSupport::_duplicate(the_type);
00045 
00046   TypeSupportMap::iterator iter = tsm.find(type_name);
00047   if (iter == tsm.end()) {
00048     tsm[type_name] = typeSupport;
00049     return DDS::RETCODE_OK;
00050   }
00051 
00052   if (std::strcmp(typeSupport->_interface_repository_id(),
00053                   iter->second->_interface_repository_id()) == 0) {
00054     return DDS::RETCODE_OK;
00055   }
00056 
00057   return DDS::RETCODE_ERROR;
00058 }

DDS::ReturnCode_t OpenDDS::DCPS::Data_Types_Register::unregister_participant ( DDS::DomainParticipant_ptr  domain_participant  ) 

Definition at line 60 of file Registered_Data_Types.cpp.

References lock_, participants_, DDS::RETCODE_ERROR, and DDS::RETCODE_OK.

00062 {
00063   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, DDS::RETCODE_ERROR);
00064   participants_.erase(domain_participant);
00065   return DDS::RETCODE_OK;
00066 }


Friends And Related Function Documentation

friend class ACE_Singleton< Data_Types_Register, ACE_SYNCH_MUTEX > [friend]

Definition at line 36 of file Registered_Data_Types.h.


Member Data Documentation

ACE_SYNCH_MUTEX OpenDDS::DCPS::Data_Types_Register::lock_ [mutable, private]

Definition at line 67 of file Registered_Data_Types.h.

Referenced by lookup(), register_type(), and unregister_participant().

ParticipantMap OpenDDS::DCPS::Data_Types_Register::participants_ [private]

Definition at line 68 of file Registered_Data_Types.h.

Referenced by lookup(), register_type(), and unregister_participant().


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