OpenDDS  Snapshot(2023/04/28-20:55)
Registered_Data_Types.h
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 #ifndef OPENDDS_DCPS_REGISTERED_DATA_TYPES_H
9 #define OPENDDS_DCPS_REGISTERED_DATA_TYPES_H
10 
11 #include "dcps_export.h"
12 #include "dds/DdsDcpsDomainC.h"
13 #include "dds/DdsDcpsTypeSupportExtC.h"
14 #include "Definitions.h"
15 
16 #include "PoolAllocator.h"
17 
18 #include "ace/Singleton.h"
19 
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 
25 
26 namespace OpenDDS {
27 namespace DCPS {
28 
29 typedef OPENDDS_MAP(OPENDDS_STRING, TypeSupport_var) TypeSupportMap;
30 typedef OPENDDS_MAP(DDS::DomainParticipant_ptr, TypeSupportMap) ParticipantMap;
31 
32 /**
33 * A singleton class that keeps track of the registered DDS data types
34 * local to this process.
35 * Data types are registered by domain participant.
36 */
39 
40 public:
41 
42  /// Return a singleton instance of this class.
43  static Data_Types_Register* instance();
44 
45  /**
46  * Register a type.
47  *
48  * @returns RETCODE_OK if the type_name is unique to the domain participant
49  * or the type_name is already registered to the_type's class.
50  * Otherwise returns RETCODE_ERROR
51  */
52  DDS::ReturnCode_t register_type(DDS::DomainParticipant_ptr domain_participant,
53  const char* type_name,
54  TypeSupport_ptr the_type);
55 
56  /**
57  * Unregister a type.
58  *
59  * @returns RETCODE_OK if the type_name has been removed or if the type_name
60  * cannot be found in the map associated with the domain_participant.
61  * Otherwise returns RETCODE_ERROR
62  */
63  DDS::ReturnCode_t unregister_type(DDS::DomainParticipant_ptr domain_participant,
64  const char* type_name,
65  TypeSupport_ptr the_type);
66 
67  DDS::ReturnCode_t unregister_participant(DDS::DomainParticipant_ptr domain_participant);
68 
69  /**
70  * Find a data type by its type name.
71  * @returns the TypeSupport object registered as type_name
72  * Otherwise returns TypeSupport::_nil()
73  */
74  TypeSupport_ptr lookup(DDS::DomainParticipant_ptr domain_participant,
75  const char* type_name) const;
76 private:
79 
81  ParticipantMap participants_;
82 };
83 
84 #define Registered_Data_Types OpenDDS::DCPS::Data_Types_Register::instance()
85 
86 } // namespace DCPS
87 } // namespace OpenDDS
88 
90 
91 #endif /* REGISTERED_DATA_TYPES_H_ */
#define ACE_SYNCH_MUTEX
#define OpenDDS_Dcps_Export
Definition: dcps_export.h:24
#define OPENDDS_STRING
static TYPE * instance(void)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) ValueMap
Helper types and functions for config file parsing.