• 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 
00029                 int attachToTransport();
00030 
00039                 void initialize();
00040 
00047                 void initializeDataWriter();
00048 
00054                 int createPublisher();
00055 
00056                 protected:
00057                 DDS::PublisherQos pubQos;
00058 
00059                 public:
00060                 DDS::DataWriterQos dwQos; 
00077                 DDSPublisher(const char *channelName): 
00078 			::ddsnc::DDSHelper(channelName)
00079                 {
00080                         initialize();
00081                 }
00082 
00083 
00099                 template <class D, class DW, class DWVAR, class TSV, class TSI>
00100                         void publishData(D data)
00101                         {
00102                                 if(initialized==false){
00103                                         /*Initialize Type Support*/
00104                                         TSV ts;
00105                                         ts = new TSI();
00106                                         if(DDS::RETCODE_OK != ts->register_type(participant.in(),""))
00107                                                 std::cerr << "register_type failed" << std::endl;
00108                                         /*Initialize the Topic*/
00109                                         initializeTopic(ts->get_type_name());
00110                                         if(CORBA::is_nil(topic.in()))
00111                                                         std::cerr<< "Topic is nil" << std::endl;
00112                                         initializeDataWriter();
00113                                         initialized=true;
00114                                 }
00115                                 DWVAR dataWriter = DW::_narrow(dw.in());
00116                                 handler = dataWriter->_cxx_register(data);
00117                                 dataWriter->write(data,handler);
00118                         }
00119 
00120                 ~DDSPublisher()
00121                 {
00122                 }
00123 
00124 
00125         };
00126 }
00127 
00128 #define PUBLISH_DATA(publisher_p, idlStruct, message) \
00129 { \
00130         publisher_p->publishData<idlStruct, idlStruct##DataWriter, \
00131         idlStruct##DataWriter_var, \
00132         idlStruct##TypeSupport_var, idlStruct##TypeSupportImpl> (message); \
00133 }
00134 #endif

Generated on Thu Jan 12 2012 23:13:50 for ACS-10.0 C++ API by  doxygen 1.7.0