00001 #ifndef dds_DCPS_TypeSupportImpl_h 00002 #define dds_DCPS_TypeSupportImpl_h 00003 00004 #include "dds/DCPS/LocalObject.h" 00005 #include "dds/DCPS/TypeSupportImpl.h" 00006 #include "dds/DCPS/MultiTopicDataReader_T.h" 00007 #include "dds/DCPS/DataWriterImpl_T.h" 00008 #include "dds/DCPS/DataReaderImpl_T.h" 00009 #include "dcps_export.h" 00010 00011 namespace OpenDDS { 00012 namespace DCPS { 00013 00014 /** Servant for TypeSupport interface of Traits::MessageType data type. 00015 * 00016 * See the DDS specification, OMG formal/04-12-02, for a description of 00017 * this interface. 00018 * 00019 */ 00020 template <typename MessageType> 00021 class 00022 #if ( __GNUC__ == 4 && __GNUC_MINOR__ == 1) 00023 OpenDDS_Dcps_Export 00024 #endif 00025 TypeSupportImpl_T 00026 : public virtual OpenDDS::DCPS::LocalObject<typename DDSTraits<MessageType>::TypeSupportType> 00027 , public virtual OpenDDS::DCPS::TypeSupportImpl 00028 { 00029 public: 00030 typedef DDSTraits<MessageType> TraitsType; 00031 typedef typename TraitsType::TypeSupportType TypeSupportType; 00032 typedef typename OpenDDS::DCPS::LocalObject<TypeSupportType>::_var_type _var_type; 00033 typedef typename OpenDDS::DCPS::LocalObject<TypeSupportType>::_ptr_type _ptr_type; 00034 00035 TypeSupportImpl_T() { } 00036 virtual ~TypeSupportImpl_T() { } 00037 00038 virtual ::DDS::DataWriter_ptr create_datawriter() 00039 { 00040 typedef DataWriterImpl_T<MessageType> DataWriterImplType; 00041 00042 DataWriterImplType* writer_impl; 00043 ACE_NEW_RETURN(writer_impl, 00044 DataWriterImplType(), 00045 ::DDS::DataWriter::_nil()); 00046 00047 return writer_impl; 00048 } 00049 00050 virtual ::DDS::DataReader_ptr create_datareader() 00051 { 00052 typedef DataReaderImpl_T<MessageType> DataReaderImplType; 00053 00054 DataReaderImplType* reader_impl = 0; 00055 ACE_NEW_RETURN(reader_impl, 00056 DataReaderImplType(), 00057 ::DDS::DataReader::_nil()); 00058 00059 return reader_impl; 00060 } 00061 00062 #ifndef OPENDDS_NO_MULTI_TOPIC 00063 virtual ::DDS::DataReader_ptr create_multitopic_datareader() 00064 { 00065 typedef DataReaderImpl_T<MessageType> DataReaderImplType; 00066 return new OpenDDS::DCPS::MultiTopicDataReader_T<MessageType, DataReaderImplType>; 00067 } 00068 #endif 00069 00070 #ifndef OPENDDS_NO_CONTENT_SUBSCRIPTION_PROFILE 00071 virtual const OpenDDS::DCPS::MetaStruct& getMetaStructForType() 00072 { 00073 return OpenDDS::DCPS::getMetaStruct<MessageType>(); 00074 } 00075 #endif 00076 00077 virtual bool has_dcps_key() 00078 { 00079 return TraitsType::gen_has_key(MessageType()); 00080 } 00081 00082 const char* default_type_name() const 00083 { 00084 return TraitsType::type_name(); 00085 } 00086 00087 static typename TraitsType::TypeSupportType::_ptr_type _narrow(CORBA::Object_ptr obj) { 00088 return TypeSupportType::_narrow(obj); 00089 } 00090 }; 00091 00092 } 00093 } 00094 00095 #endif /* dds_DCPS_TypeSupportImpl_h */