Registered_Data_Types.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef REGISTERED_DATA_TYPES_H_
00009 #define REGISTERED_DATA_TYPES_H_
00010 
00011 #include "dcps_export.h"
00012 #include "dds/DdsDcpsDomainC.h"
00013 #include "dds/DdsDcpsTypeSupportExtC.h"
00014 #include "Definitions.h"
00015 
00016 #include "PoolAllocator.h"
00017 
00018 #include "ace/Singleton.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 namespace OpenDDS {
00027 namespace DCPS {
00028 
00029 typedef OPENDDS_MAP(OPENDDS_STRING, TypeSupport_var) TypeSupportMap;
00030 typedef OPENDDS_MAP(DDS::DomainParticipant_ptr, TypeSupportMap) ParticipantMap;
00031 
00032 /**
00033 * A singleton class that keeps track of the registered DDS data types
00034 * local to this process.
00035 * Data types are registered by domain participant.
00036 */
00037 class OpenDDS_Dcps_Export Data_Types_Register {
00038   friend class ACE_Singleton<Data_Types_Register, ACE_SYNCH_MUTEX>;
00039 
00040 public:
00041 
00042   /// Return a singleton instance of this class.
00043   static Data_Types_Register* instance();
00044 
00045   /**
00046    * Register a type.
00047    *
00048    * @returns RETCODE_OK if the type_name is unique to the domain participant
00049    *         or the type_name is already registered to the_type's class.
00050    *         Otherwise returns RETCODE_ERROR
00051    */
00052   DDS::ReturnCode_t register_type(DDS::DomainParticipant_ptr domain_participant,
00053                                   const char* type_name,
00054                                   TypeSupport_ptr the_type);
00055 
00056   /**
00057    * Unregister a type.
00058    *
00059    * @returns RETCODE_OK if the type_name has been removed or if the type_name
00060    *        cannot be found in the map associated with the domain_participant.
00061    *        Otherwise returns RETCODE_ERROR
00062    */
00063   DDS::ReturnCode_t unregister_type(DDS::DomainParticipant_ptr domain_participant,
00064                                     const char* type_name,
00065                                     TypeSupport_ptr the_type);
00066 
00067   DDS::ReturnCode_t unregister_participant(DDS::DomainParticipant_ptr domain_participant);
00068 
00069   /**
00070    * Find a data type by its type name.
00071    * @returns the TypeSupport object registered as type_name
00072    *         Otherwise returns TypeSupport::_nil()
00073    */
00074   TypeSupport_ptr lookup(DDS::DomainParticipant_ptr domain_participant,
00075                          const char* type_name) const;
00076 private:
00077   Data_Types_Register();
00078   ~Data_Types_Register();
00079 
00080   mutable ACE_SYNCH_MUTEX lock_;
00081   ParticipantMap participants_;
00082 };
00083 
00084 #define Registered_Data_Types Data_Types_Register::instance()
00085 
00086 } // namespace DCPS
00087 } // namespace OpenDDS
00088 
00089 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00090 
00091 #endif /* REGISTERED_DATA_TYPES_H_  */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1