• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

DDSPublisher.h

Go to the documentation of this file.
00001 #ifndef _DDS_PUBLISHER_H
00002 #define _DDS_PUBLISHER_H
00003 
00004 #include <DDSHelper.h>
00005 #include <dds/DCPS/PublisherImpl.h>
00006 #include "acsddsncCDBProperties.h"
00007 
00008 namespace ddsnc{
00009 
00020 //      template<class DWVAR>
00021         class DDSPublisher : public ::ddsnc::DDSHelper{
00022                 private:
00023                 DDS::Publisher_var pub;
00024                 OpenDDS::DCPS::PublisherImpl *pub_impl;
00025                 DDS::DataWriter_var dw;
00026 //              DWVAR dataWriter;       
00027                 DDS::InstanceHandle_t handler;
00028 
00037                 void initialize();
00038 
00045                 void initializeDataWriter();
00046 
00052                 int createPublisher();
00053 
00054                 protected:
00055                 DDS::PublisherQos pubQos;
00056 
00057                 public:
00058                 DDS::DataWriterQos dwQos; 
00075                 DDSPublisher(const char *channelName): 
00076 			::ddsnc::DDSHelper(channelName)
00077                 {
00078                         initialize();
00079                 }
00080 
00081 
00097                 template <class D, class DW, class DWVAR, class TSV, class TSI>
00098                         void publishData(D data)
00099                         {
00100                                 if(initialized==false){
00101                                         /*Initialize Type Support*/
00102                                         TSV ts;
00103                                         ts = new TSI();
00104                                         if(DDS::RETCODE_OK != ts->register_type(participant.in(),""))
00105                                                 std::cerr << "register_type failed" << std::endl;
00106                                         /*Initialize the Topic*/
00107                                         initializeTopic(ts->get_type_name());
00108                                         if(CORBA::is_nil(topic.in()))
00109                                                         std::cerr<< "Topic is nil" << std::endl;
00110                                         initializeDataWriter();
00111                                         initialized=true;
00112                                 }
00113                                 DWVAR dataWriter = DW::_narrow(dw.in());
00114                                 handler = dataWriter->_cxx_register(data);
00115                                 dataWriter->write(data,handler);
00116                         }
00117 
00118                 ~DDSPublisher()
00119                 {
00120                 }
00121 
00122 
00123         };
00124 }
00125 
00126 #define PUBLISH_DATA(publisher_p, idlStruct, message) \
00127 { \
00128         publisher_p->publishData<idlStruct, idlStruct##DataWriter, \
00129         idlStruct##DataWriter_var, \
00130         idlStruct##TypeSupport_var, idlStruct##TypeSupportImpl> (message); \
00131 }
00132 #endif

Generated on Mon May 4 2015 08:27:43 for ACS-2015.4 C++ API by  doxygen 1.7.0