ddt  0.1
ddtDataPublisher.hpp
Go to the documentation of this file.
1 // @copyright
2 // (c) Copyright ESO 2020
3 // All Rights Reserved
4 // ESO (eso.org) is an Intergovernmental Organization, and therefore special
5 // legal conditions apply.
6 //
7 // @file ddtDataPublisher.hpp
8 // @brief Data Publisher.
9 //
10 // This class provides the functionality for publisher applications to register
11 // / unregister at a local broker and to publish data for a specified data
12 // stream.
13 //
14 // @author Matthias Grimm, CGI
15 // @since 2020/01/16
16 //
17 
18 #ifndef SRC_DDTDATAPUBLISHER_H_
19 #define SRC_DDTDATAPUBLISHER_H_
20 
21 #include <boost/circular_buffer.hpp>
22 #include <boost/interprocess/managed_shared_memory.hpp>
23 #include <boost/signals2/signal.hpp>
24 
26 
27 namespace ddt {
28 
35  public:
40 
44  virtual ~DdtDataPublisher();
45 
46  int RegisterPublisher(std::string broker_uri,
47  std::string data_stream_identifier,
48  bool compute_checksum) override;
49 
50  int UnregisterPublisher() override;
51 
52  void PublishData() override;
53 
57  void SetBufferSize(int max_data_sample_size, int number_of_samples);
58 
62  void WriteData(int32_t sample_id, const std::vector<uint8_t> &datavec,
63  const std::vector<uint8_t> &metadatavec);
64 
68  void set_topic_id(int topic_id);
69 
74 
75  protected:
79  void LoadDefaults();
80 
84  void ReadIni();
85 
89  int topic_id;
90 
91  private:
95  void Init();
96 
100  void PrintConfigValues();
101 
106  void Reregister();
107 
108  DdtMemoryAccessor *memory_accessor;
109  std::string shm_id;
110  std::string data_stream_identifier;
111  int writer_index;
112  int max_data_sample_size;
113  int number_of_samples;
114 
115  bool compute_checksum;
116  std::string publishing_uri;
117 };
118 
119 } // namespace ddt
120 
121 #endif /* SRC_DDTDATAPUBLISHER_H_ */
ddt::DdtDataPublisher::UnregisterPublisher
int UnregisterPublisher() override
Definition: ddtDataPublisher.cpp:279
ddt::DdtDataPublisher::get_connected_to_broker
bool get_connected_to_broker()
Definition: ddtDataPublisher.cpp:336
ddt::DdtDataPublisher::SetBufferSize
void SetBufferSize(int max_data_sample_size, int number_of_samples)
Definition: ddtDataPublisher.cpp:298
ddt::DdtDataPublisher::RegisterPublisher
int RegisterPublisher(std::string broker_uri, std::string data_stream_identifier, bool compute_checksum) override
Definition: ddtDataPublisher.cpp:94
ddt::DdtDataPublisher::LoadDefaults
void LoadDefaults()
Definition: ddtDataPublisher.cpp:51
ddt::DdtLogger
Definition: ddtLogger.hpp:71
ddt::DdtMemoryAccessor
Definition: ddtMemoryAccessor.hpp:258
ddt
Definition: ddtClient.hpp:36
ddt::DdtDataPublisher::WriteData
void WriteData(int32_t sample_id, const std::vector< uint8_t > &datavec, const std::vector< uint8_t > &metadatavec)
Definition: ddtDataPublisher.cpp:304
ddt::DdtDataPublisher::DdtDataPublisher
DdtDataPublisher(DdtLogger *logger)
Definition: ddtDataPublisher.cpp:22
ddt::DdtDataPublisher
Definition: ddtDataPublisher.hpp:34
ddt::DdtDataPublisher::PublishData
void PublishData() override
Definition: ddtDataPublisher.cpp:321
ddt::DdtDataPublisher::topic_id
int topic_id
Definition: ddtDataPublisher.hpp:89
ddtDataTransferLib.hpp
ddt::DdtDataTransferLib::logger
DdtLogger * logger
Definition: ddtDataTransferLib.hpp:172
ddt::DdtDataPublisher::ReadIni
void ReadIni()
Definition: ddtDataPublisher.cpp:53
ddt::DdtDataPublisher::~DdtDataPublisher
virtual ~DdtDataPublisher()
Definition: ddtDataPublisher.cpp:30
ddt::DdtDataTransferLib
Definition: ddtDataTransferLib.hpp:39
ddt::DdtDataPublisher::set_topic_id
void set_topic_id(int topic_id)
Definition: ddtDataPublisher.cpp:334