00001 #ifndef artdaq_RTIDDS_RTIDDS_hh
00002 #define artdaq_RTIDDS_RTIDDS_hh
00003
00004 #include "artdaq-core/Data/Fragment.hh"
00005
00006 #include <ndds/ndds_cpp.h>
00007
00008 #include <string>
00009 #include <queue>
00010 #include <mutex>
00011
00012
00013 namespace artdaq
00014 {
00015 class RTIDDS;
00016 }
00017
00021 class artdaq::RTIDDS
00022 {
00023 public:
00024
00028 enum class IOType
00029 {
00030 reader,
00031 writer
00032 };
00033
00040 RTIDDS(std::string name, IOType iotype, std::string max_size = "1000000");
00041
00045 virtual ~RTIDDS() = default;
00046
00047
00048
00049
00056 void copyFragmentToDDS_(artdaq::Fragment& fragment);
00057
00065 void moveFragmentToDDS_(artdaq::Fragment&& fragment);
00066
00070 class OctetsListener: public DDSDataReaderListener
00071 {
00072 public:
00073
00078 void on_data_available(DDSDataReader* reader);
00079
00086 bool receiveFragmentFromDDS(artdaq::Fragment& fragment,
00087 const size_t receiveTimeout);
00088
00089 private:
00090
00091 DDS_Octets dds_octets_;
00092 std::queue<DDS_Octets> dds_octets_queue_;
00093
00094 std::mutex queue_mutex_;
00095 };
00096
00097 OctetsListener octets_listener_;
00098
00099 private:
00100
00101 std::string name_;
00102 IOType iotype_;
00103 std::string max_size_;
00104
00105 std::unique_ptr<DDSDomainParticipant, std::function<void(DDSDomainParticipant * )>> participant_;
00106
00107 DDSTopic* topic_octets_;
00108 DDSOctetsDataWriter* octets_writer_;
00109 DDSDataReader* octets_reader_;
00110
00111 static void participantDeleter(DDSDomainParticipant* participant);
00112 };
00113
00114 #endif