ifw-ccf 6.0.0
 
Loading...
Searching...
No Matches
pubThread.hpp
Go to the documentation of this file.
1
6
7#ifndef CCF_CONTROL_PUB_THREAD_HPP_H_
8#define CCF_CONTROL_PUB_THREAD_HPP_H_
9
14
15namespace ifw::ccf::control {
16
19 public:
20
22 static void SetStatusAll(const ifw::ccf::PubStatus status);
23
26 PubThread(const std::string& thread_name,
27 ifw::ccf::mptk::MessageBus& message_bus,
28 const double period = 0.1);
29
30 virtual ~PubThread();
31
33 void Initialise();
34
36 virtual void UserLogic();
37
39 void SetProcThrOutputQ(std::shared_ptr<ifw::ccf::common::FrameQueue>& queue);
40
43
45 void SetStatus(const ifw::ccf::PubStatus status);
46
49
53
56 uint8_t NbOfPublishers() const;
57
59 const ifw::ccf::common::PubBase& GetPublisher(const uint16_t nb) const;
60
63
65 const std::list<ifw::ccf::common::PubBase*>& GetPublishers() const;
66
68 void SetParentProcThreadName(const std::string& parent_proc_thread_name);
69
71 const std::string& GetParentProcThreadName() 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(ifw::ccf::Status& status,
85 std::string& diagnostics);
86
87 std::string m_parent_proc_thr_name;
88
89 ifw::ccf::mptk::Message m_cur_msg; // Current thread message being handled.
90
91 // Current data frame being handled. Should not be shared_ptr.
92 ifw::ccf::common::DataFrame* m_cur_frame;
93
94 // Used to avoid updating OLDB/PubSub unnecessary.
95 ifw::ccf::PubStatus m_pub_thread_status;
96
97 // TODO: Consider to allow only one publisher:
98 // std::shared_ptr<ifw::ccf::common::PubBase> m_publisher;
99 std::list<ifw::ccf::common::PubBase*> m_publishers;
100
101 ProcThread* m_parent_proc_thr;
102
103 // Map to find Data Publisher objects easily by means of the Thread ID.
104 std::map<std::string, ifw::ccf::common::PubBase*> m_publisher_map;
105
106 // Note: The queues are allocated and deleted by the ifw::ccf::control::application class.
107 std::shared_ptr<ifw::ccf::common::FrameQueue> m_proc_thr_output_q;
108
110 };
111
112}
113
114#endif // CCF_CONTROL_PUB_THREAD_HPP_H_
Class to be used as parent all CCF classes.
Definition base.hpp:122
Frame class used to store the data and metadata for one frames received from the camera.
Definition dataFrame.hpp:20
The FrameQueue class implements a queue, to manage a set of CCF DataFrame instances as a ring buffer.
Definition frameQueue.hpp:17
Class used by the threads to store info for generating performance statistics.
Definition utilities.hpp:29
Class for implementing CCF Data Publishers.
Definition pubBase.hpp:117
Processing Thread MPTK Thread implementation (see also ifw::ccf::mptk::Thread).
Definition procThread.hpp:18
void SetParentProcThreadName(const std::string &parent_proc_thread_name)
Set the name of the parent Processing Thread in the object.
Definition pubThread.cpp:315
ifw::ccf::PubStatus GetStatus() const
Return Publishing Status of this Publisher Thread.
Definition pubThread.cpp:270
virtual void UserLogic()
Use logic invoked periodically (ifw::ccf::mptk::Thread).
Definition pubThread.cpp:73
PubThread(const std::string &thread_name, ifw::ccf::mptk::MessageBus &message_bus, const double period=0.1)
Definition pubThread.cpp:30
virtual ~PubThread()
Definition pubThread.cpp:42
ifw::ccf::common::PubBase & GetPublisher()
Get the reference to the internal publisher object.
Definition pubThread.cpp:305
uint8_t NbOfPublishers() const
Definition pubThread.cpp:289
const std::list< ifw::ccf::common::PubBase * > & GetPublishers() const
Get the list of internal Data Publisher (objects).
Definition pubThread.cpp:310
const std::string & GetParentProcThreadName() const
Return the name of the parent Processing Thread from the object.
Definition pubThread.cpp:320
void SetProcThrOutputQ(std::shared_ptr< ifw::ccf::common::FrameQueue > &queue)
Set reference to the Output Queue of this Processing Thread.
Definition pubThread.cpp:122
void SetStatus(const ifw::ccf::PubStatus status)
Set the Publishing Status of this Publisher Thread.
Definition pubThread.cpp:135
ifw::ccf::common::FrameStatistics & GetFrameStat()
Get reference to frame handling statistics.
Definition pubThread.cpp:329
void AddPublisher(ifw::ccf::common::PubBase &pub_obj)
Definition pubThread.cpp:275
void Initialise()
Initialise this thread (object).
Definition pubThread.cpp:58
static void SetStatusAll(const ifw::ccf::PubStatus status)
Set the Publishing Status of all Publisher Threads running.
Definition pubThread.cpp:13
ifw::ccf::common::FrameQueue & GetProcThrOutputQ()
Get reference to the Output Queue of this Processing Thread.
Definition pubThread.cpp:127
IFW CTD Multiprocessing Toolkit Message Bus.
Definition messageBus.hpp:92
IFW CTD Multiprocessing Toolkit Message class.
Definition message.hpp:25
IFW CTD Multiprocessing Toolkit Thread base class.
Definition thread.hpp:31
Definition acqThread.cpp:11
PubStatus
Defines the various possible states of a Data Publisher.
Definition base.hpp:180
Status
General status variable.
Definition base.hpp:158