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 namespace OpenDDS {
00025 namespace DCPS {
00026 
00027 typedef OPENDDS_MAP(OPENDDS_STRING, TypeSupport_var) TypeSupportMap;
00028 typedef OPENDDS_MAP(DDS::DomainParticipant_ptr, TypeSupportMap) ParticipantMap;
00029 
00030 /**
00031 * A singleton class that keeps track of the registered DDS data types
00032 * local to this process.
00033 * Data types are registered by domain participant.
00034 */
00035 class OpenDDS_Dcps_Export Data_Types_Register {
00036   friend class ACE_Singleton<Data_Types_Register, ACE_SYNCH_MUTEX>;
00037 
00038 public:
00039 
00040   /// Return a singleton instance of this class.
00041   static Data_Types_Register* instance();
00042 
00043   /**
00044    * Register a type.
00045    *
00046    * @returns RETCODE_OK if the type_name is unique to the domain participant
00047    *         or the type_name is already registered to the_type's class.
00048    *         Otherwise returns RETCODE_ERROR
00049    */
00050   DDS::ReturnCode_t register_type(DDS::DomainParticipant_ptr domain_participant,
00051                                   const char* type_name,
00052                                   TypeSupport_ptr the_type);
00053 
00054   DDS::ReturnCode_t unregister_participant(DDS::DomainParticipant_ptr domain_participant);
00055 
00056   /**
00057    * Find a data type by its type name.
00058    * @returns the TypeSupport object registered as type_name
00059    *         Otherwise returns TypeSupport::_nil()
00060    */
00061   TypeSupport_ptr lookup(DDS::DomainParticipant_ptr domain_participant,
00062                          const char* type_name) const;
00063 private:
00064   Data_Types_Register();
00065   ~Data_Types_Register();
00066 
00067   mutable ACE_SYNCH_MUTEX lock_;
00068   ParticipantMap participants_;
00069 };
00070 
00071 #define Registered_Data_Types Data_Types_Register::instance()
00072 
00073 } // namespace DCPS
00074 } // namespace OpenDDS
00075 
00076 #endif /* REGISTERED_DATA_TYPES_H_  */

Generated on Fri Feb 12 20:05:25 2016 for OpenDDS by  doxygen 1.4.7