ifw-ccf  2.0.0
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 std::string GenId(const std::string& proc_thread_name,
21  const std::string& pub_thread_name);
22 
24  static void SetStatusAll(const ccf::PubStatus status);
25 
27  PubThread(const std::string& thread_id,
28  ccf::mptk::MessageBus& message_bus,
29  const double period = 0.1);
30 
31  virtual ~PubThread();
32 
34  void Initialise();
35 
37  virtual void UserLogic();
38 
40  void SetProcThrOutputQ(std::shared_ptr<ccf::common::FrameQueue>& queue);
41 
44 
46  void SetStatus(const ccf::PubStatus status);
47 
49  ccf::PubStatus GetStatus() const;
50 
53  //void AddPublisher(std::shared_ptr<ccf::common::PubBase>& pub_obj);
54  void AddPublisher(ccf::common::PubBase& pub_obj);
55 
58  uint8_t NbOfPublishers() const;
59 
61  const ccf::common::PubBase& GetPublisher(const uint16_t nb) const;
62 
64  //const std::list<std::shared_ptr<ccf::common::PubBase>>& GetPublishers() const;
65  const std::list<ccf::common::PubBase*>& GetPublishers() const;
66 
68  const std::string& GetProcThreadName() const;
69 
71  const std::string& GetPubThreadName() const;
72 
75 
76  protected:
77 
78  private:
79  bool _CheckMessageBus(bool& new_data_available,
80  bool& new_setup);
81  void _GetFrameHandleRef();
82  void _InvokePublishers();
83  void _ReleaseFrameHandle();
84  void _HandleNewSetup(ccf::Status status,
85  std::string& diagnostics);
86 
87  std::string m_proc_thr_name;
88  std::string m_pub_thr_id;
89  std::string m_pub_thr_name;
90 
91  ccf::mptk::Message m_cur_msg; // Current thread message being handled.
92 
93  // Current data frame being handled. Should not be shared_ptr.
94  ccf::common::DataFrame* m_cur_frame;
95 
96  // Used to avoid updating OLDB/PubSub unnecessary.
97  ccf::PubStatus m_pub_thread_status;
98 
99  // std::list<std::shared_ptr<ccf::common::PubBase>> m_publishers;
100  // // Map to find Data Publisher objects easily by means of the Thread ID.
101  // std::map<std::string, std::shared_ptr<ccf::common::PubBase>> m_publisher_map;
102  std::list<ccf::common::PubBase*> m_publishers;
103  // Map to find Data Publisher objects easily by means of the Thread ID.
104  std::map<std::string, ccf::common::PubBase*> m_publisher_map;
105 
106  // Note: The queues are allocated and deleted by the ccf::control::application class.
107  std::shared_ptr<ccf::common::FrameQueue> m_proc_thr_output_q;
108 
109  ccf::common::FrameStatistics m_frame_stat;
110  };
111 
112 }
113 
114 #endif // CCF_CONTROL_PUB_THREAD_HPP_H_
ccf::Base
Class to be used as parent all CCF classes.
Definition: base.hpp:152
frameQueue.hpp
ccf::control::PubThread::GetProcThreadName
const std::string & GetProcThreadName() const
Return the name of the Publisher.
Definition: pubThread.cpp:306
ccf::control::PubThread::GetStatus
ccf::PubStatus GetStatus() const
Return Publishing Status of this Publisher Thread.
Definition: pubThread.cpp:247
ccf::control::PubThread::GetPubThreadName
const std::string & GetPubThreadName() const
Return the name of the Publisher.
Definition: pubThread.cpp:311
ccf::mptk::Thread
IFW CTD Multiprocessing Toolkit Thread base class.
Definition: thread.hpp:29
ccf::control::PubThread::SetStatus
void SetStatus(const ccf::PubStatus status)
Set the Publishing Status of this Publisher Thread.
Definition: pubThread.cpp:130
ccf::control::PubThread::GenId
static std::string GenId(const std::string &proc_thread_name, const std::string &pub_thread_name)
Generate the Publisher Thread ID used for the interthread communication.
Definition: pubThread.cpp:12
ccf::control::PubThread::PubThread
PubThread(const std::string &thread_id, ccf::mptk::MessageBus &message_bus, const double period=0.1)
See ccf::mptk::Thread.
Definition: pubThread.cpp:34
ccf::control::PubThread::SetProcThrOutputQ
void SetProcThrOutputQ(std::shared_ptr< ccf::common::FrameQueue > &queue)
Set reference to the Output Queue of this Processing Thread.
Definition: pubThread.cpp:117
ccf::Status
Status
General status variable.
Definition: base.hpp:202
pubBase.hpp
ccf::control::PubThread::~PubThread
virtual ~PubThread()
Definition: pubThread.cpp:49
ccf::PubStatus
PubStatus
Defines the various possible states of a Data Publisher.
Definition: base.hpp:285
ccf::mptk::MessageBus
IFW CTD Multiprocessing Toolkit Message Bus.
Definition: messageBus.hpp:30
ccf::control::PubThread::SetStatusAll
static void SetStatusAll(const ccf::PubStatus status)
Set the Publishing Status of all Publisher Threads running.
Definition: pubThread.cpp:17
ccf::mptk::Message
IFW CTD Multiprocessing Toolkit Message class.
Definition: message.hpp:19
ccf::control::PubThread::GetPublishers
const std::list< ccf::common::PubBase * > & GetPublishers() const
Get the list of internal Data Publisher (objects).
Definition: pubThread.cpp:301
ccf::common::FrameQueue
The FrameQueue class implements a queue, to manage a set of CCF DataFrame instances as a ring buffer.
Definition: frameQueue.hpp:14
ccf::control::PubThread::AddPublisher
void AddPublisher(ccf::common::PubBase &pub_obj)
Definition: pubThread.cpp:266
ccf::common::PubBase
Class for implementing CCF Data Publishers.
Definition: pubBase.hpp:114
ccf::control::PubThread::GetFrameStat
ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition: pubThread.cpp:316
base.hpp
ccf::control::PubThread::Initialise
void Initialise()
Initialise this thread (object).
Definition: pubThread.cpp:65
ccf::control::PubThread
Publisher Thread MPTK Thread implementation (see also ccf::mptk::Thread).
Definition: pubThread.hpp:16
ccf::control::PubThread::NbOfPublishers
uint8_t NbOfPublishers() const
Definition: pubThread.cpp:280
ccf::control::PubThread::GetPublisher
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:285
ccf::common::FrameStatistics
Class used by the threads to store info for generating performance statistics.
Definition: utilities.hpp:25
ccf::control::PubThread::GetProcThrOutputQ
ccf::common::FrameQueue & GetProcThrOutputQ()
Get reference to the Output Queue of this Processing Thread.
Definition: pubThread.cpp:122
ccf::control
Definition: acqThread.cpp:10
ccf::control::PubThread::UserLogic
virtual void UserLogic()
Use logic invoked periodically (ccf::mptk::Thread).
Definition: pubThread.cpp:75
ccf::common::DataFrame
Frame class used to store the data and metadata for one frames received from the camera.
Definition: dataFrame.hpp:17
utilities.hpp