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_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 37 of file Registered_Data_Types.h.


Constructor & Destructor Documentation

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

Definition at line 24 of file Registered_Data_Types.cpp.

00025 {
00026 }

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

Definition at line 28 of file Registered_Data_Types.cpp.

00029 {
00030 }


Member Function Documentation

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

Return a singleton instance of this class.

Definition at line 33 of file Registered_Data_Types.cpp.

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 95 of file Registered_Data_Types.cpp.

References lock_, and participants_.

00098 {
00099   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, 0);
00100 
00101   ParticipantMap::const_iterator iter1 = participants_.find(domain_participant);
00102   if (iter1 == participants_.end()) {
00103     return 0;
00104   }
00105 
00106   TypeSupportMap::const_iterator iter2 = iter1->second.find(type_name);
00107   if (iter2 == iter1->second.end()) {
00108     return 0;
00109   }
00110 
00111   TypeSupport_var typeSupport = iter2->second;
00112   return typeSupport._retn();
00113 }

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 38 of file Registered_Data_Types.cpp.

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

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

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

Definition at line 87 of file Registered_Data_Types.cpp.

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

00089 {
00090   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, DDS::RETCODE_ERROR);
00091   participants_.erase(domain_participant);
00092   return DDS::RETCODE_OK;
00093 }

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

Unregister a type.

Returns:
RETCODE_OK if the type_name has been removed or if the type_name cannot be found in the map associated with the domain_participant. Otherwise returns RETCODE_ERROR

Definition at line 62 of file Registered_Data_Types.cpp.

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

00066 {
00067   ACE_GUARD_RETURN(ACE_SYNCH_MUTEX, guard, lock_, DDS::RETCODE_ERROR);
00068 
00069   TypeSupportMap& tsm = participants_[domain_participant];
00070 
00071   TypeSupportMap::iterator iter = tsm.find(type_name);
00072   if (iter == tsm.end()) {
00073     // Not in the map, can't delete
00074     return DDS::RETCODE_ERROR;
00075   }
00076   else {
00077     if (std::strcmp(the_type->_interface_repository_id(), iter->second->_interface_repository_id()) == 0) {
00078       tsm.erase(iter);
00079       return DDS::RETCODE_OK;
00080     }
00081     else {
00082       return DDS::RETCODE_ERROR;
00083     }
00084   }
00085 }


Friends And Related Function Documentation

friend class ACE_Singleton< Data_Types_Register, ACE_SYNCH_MUTEX > [friend]

Definition at line 38 of file Registered_Data_Types.h.


Member Data Documentation

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

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1