ifw-ccf  3.0.0-pre2
pubThread.hpp
Go to the documentation of this file.
1 
5 #ifndef CCF_CONTROL_PUB_THREAD_HPP_H_
6 #define CCF_CONTROL_PUB_THREAD_HPP_H_
7 
8 #include "ccf/common/base.hpp"
11 #include "ccf/common/pubBase.hpp"
12 
13 namespace ccf::control {
14 
16  class PubThread: public ccf::mptk::Thread, public ccf::Base {
17  public:
18 
20  static void SetStatusAll(const ccf::PubStatus status);
21 
24  PubThread(const std::string& thread_name,
25  ccf::mptk::MessageBus& message_bus,
26  const double period = 0.1);
27 
28  virtual ~PubThread();
29 
31  void Initialise();
32 
34  virtual void UserLogic();
35 
37  void SetProcThrOutputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
38 
41 
43  void SetStatus(const ccf::PubStatus status);
44 
46  ccf::PubStatus GetStatus() const;
47 
50  void AddPublisher(ccf::common::PubBase& pub_obj);
51 
54  uint8_t NbOfPublishers() const;
55 
57  const ccf::common::PubBase& GetPublisher(const uint16_t nb) const;
58 
60  const std::list<ccf::common::PubBase*>& GetPublishers() const;
61 
63  void SetParentProcThreadName(const std::string& parent_proc_thread_name);
64 
66  const std::string& GetParentProcThreadName() const;
67 
70 
71  protected:
72 
73  private:
74  bool _CheckMessageBus(bool& new_data_available,
75  bool& new_setup);
76  void _GetFrameHandleRef();
77  void _InvokePublishers();
78  void _ReleaseFrameHandle();
79  void _HandleNewSetup(ccf::Status status,
80  std::string& diagnostics);
81 
82  std::string m_parent_proc_thr_name;
83 
84  ccf::mptk::Message m_cur_msg; // Current thread message being handled.
85 
86  // Current data frame being handled. Should not be shared_ptr.
87  ccf::common::DataFrame* m_cur_frame;
88 
89  // Used to avoid updating OLDB/PubSub unnecessary.
90  ccf::PubStatus m_pub_thread_status;
91 
92  std::list<ccf::common::PubBase*> m_publishers;
93 
94  // Map to find Data Publisher objects easily by means of the Thread ID.
95  std::map<std::string, ccf::common::PubBase*> m_publisher_map;
96 
97  // Note: The queues are allocated and deleted by the ccf::control::application class.
98  std::shared_ptr<ccf::common::FrameQueue> m_proc_thr_output_q;
99 
100  ccf::common::FrameStatistics m_frame_stat;
101 
102  bool m_pipeline_enabled;
103  };
104 
105 }
106 
107 #endif // CCF_CONTROL_PUB_THREAD_HPP_H_
Class to be used as parent all CCF classes.
Definition: base.hpp:151
Frame class used to store the data and metadata for one frames received from the camera.
Definition: dataFrame.hpp:17
The FrameQueue class implements a queue, to manage a set of CCF DataFrame instances as a ring buffer.
Definition: frameQueue.hpp:14
Class used by the threads to store info for generating performance statistics.
Definition: utilities.hpp:25
Class for implementing CCF Data Publishers.
Definition: pubBase.hpp:114
Publisher Thread MPTK Thread implementation (see also ccf::mptk::Thread).
Definition: pubThread.hpp:16
void SetParentProcThreadName(const std::string &parent_proc_thread_name)
Set the name of the parent Processing Thread.
Definition: pubThread.cpp:286
const ccf::common::PubBase & GetPublisher(const uint16_t nb) const
Get the reference to a specific Data Publisher registered in this Publisher Thread (object).
Definition: pubThread.cpp:270
const std::string & GetParentProcThreadName() const
Return the name of the parent Processing Thread.
Definition: pubThread.cpp:291
void AddPublisher(ccf::common::PubBase &pub_obj)
Definition: pubThread.cpp:251
ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition: pubThread.cpp:300
static void SetStatusAll(const ccf::PubStatus status)
Set the Publishing Status of all Publisher Threads running.
Definition: pubThread.cpp:12
ccf::common::FrameQueue & GetProcThrOutputQ()
Get reference to the Output Queue of this Processing Thread.
Definition: pubThread.cpp:118
void SetProcThrOutputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Output Queue of this Processing Thread.
Definition: pubThread.cpp:113
void Initialise()
Initialise this thread (object).
Definition: pubThread.cpp:56
virtual ~PubThread()
Definition: pubThread.cpp:40
ccf::PubStatus GetStatus() const
Return Publishing Status of this Publisher Thread.
Definition: pubThread.cpp:246
void SetStatus(const ccf::PubStatus status)
Set the Publishing Status of this Publisher Thread.
Definition: pubThread.cpp:126
virtual void UserLogic()
Use logic invoked periodically (ccf::mptk::Thread).
Definition: pubThread.cpp:71
uint8_t NbOfPublishers() const
Definition: pubThread.cpp:265
PubThread(const std::string &thread_name, ccf::mptk::MessageBus &message_bus, const double period=0.1)
Definition: pubThread.cpp:29
const std::list< ccf::common::PubBase * > & GetPublishers() const
Get the list of internal Data Publisher (objects).
Definition: pubThread.cpp:281
IFW CTD Multiprocessing Toolkit Message Bus.
Definition: messageBus.hpp:91
IFW CTD Multiprocessing Toolkit Message class.
Definition: message.hpp:19
IFW CTD Multiprocessing Toolkit Thread base class.
Definition: thread.hpp:29
Definition: acqThread.cpp:10
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:271
Status
General status variable.
Definition: base.hpp:201