OpenDDS  Snapshot(2023/04/28-20:55)
Registered_Data_Types.cpp
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 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
9 
10 #include "Registered_Data_Types.h"
11 
12 #include "Util.h"
13 #include "dds/DdsDcpsDomainC.h"
14 
15 #include "ace/Singleton.h"
16 
17 #include <cstring>
18 
20 
21 namespace OpenDDS {
22 namespace DCPS {
23 
25 {
26 }
27 
29 {
30 }
31 
34 {
36 }
37 
39  DDS::DomainParticipant_ptr domain_participant,
40  const char* type_name,
41  TypeSupport_ptr the_type)
42 {
44 
45  TypeSupportMap& tsm = participants_[domain_participant];
46  const TypeSupport_var typeSupport = TypeSupport::_duplicate(the_type);
47 
48  TypeSupportMap::iterator iter = tsm.find(type_name);
49  if (iter == tsm.end()) {
50  tsm[type_name] = typeSupport;
51  return DDS::RETCODE_OK;
52  }
53 
54  if (std::strcmp(typeSupport->_interface_repository_id(),
55  iter->second->_interface_repository_id()) == 0) {
56  return DDS::RETCODE_OK;
57  }
58 
59  return DDS::RETCODE_ERROR;
60 }
61 
63  DDS::DomainParticipant_ptr domain_participant,
64  const char* type_name,
65  TypeSupport_ptr the_type)
66 {
68 
69  TypeSupportMap& tsm = participants_[domain_participant];
70 
71  TypeSupportMap::iterator iter = tsm.find(type_name);
72  if (iter == tsm.end()) {
73  // Not in the map, can't delete
74  return DDS::RETCODE_ERROR;
75  }
76  else {
77  if (std::strcmp(the_type->_interface_repository_id(), iter->second->_interface_repository_id()) == 0) {
78  tsm.erase(iter);
79  return DDS::RETCODE_OK;
80  }
81  else {
82  return DDS::RETCODE_ERROR;
83  }
84  }
85 }
86 
88  DDS::DomainParticipant_ptr domain_participant)
89 {
91  participants_.erase(domain_participant);
92  return DDS::RETCODE_OK;
93 }
94 
96  DDS::DomainParticipant_ptr domain_participant,
97  const char* type_name) const
98 {
100 
101  ParticipantMap::const_iterator iter1 = participants_.find(domain_participant);
102  if (iter1 == participants_.end()) {
103  return 0;
104  }
105 
106  TypeSupportMap::const_iterator iter2 = iter1->second.find(type_name);
107  if (iter2 == iter1->second.end()) {
108  return 0;
109  }
110 
111  TypeSupport_var typeSupport = iter2->second;
112  return typeSupport._retn();
113 }
114 
115 } // namespace DCPS
116 } // namespace OpenDDS
117 
#define ACE_SYNCH_MUTEX
TypeSupport_ptr lookup(DDS::DomainParticipant_ptr domain_participant, const char *type_name) const
static Data_Types_Register * instance()
Return a singleton instance of this class.
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)
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
DDS::ReturnCode_t unregister_type(DDS::DomainParticipant_ptr domain_participant, const char *type_name, TypeSupport_ptr the_type)
static TYPE * instance(void)
const ReturnCode_t RETCODE_ERROR
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
const ReturnCode_t RETCODE_OK
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28