OpenRTM-aist 2.0.2
読み取り中…
検索中…
一致する文字列を見つけられません
Timestamp.h
[詳解]
1// -*- C++ -*-
18#ifndef RTM_TIMESTAMP_H
19#define RTM_TIMESTAMP_H
20
22#include <chrono>
23
45template <class DataType>
46void setTimestamp(DataType& data)
47{
48 auto now = std::chrono::system_clock::now().time_since_epoch();
49 auto sec = std::chrono::duration_cast<std::chrono::seconds>(now);
50 auto nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(now - sec);
51// We do not consider overflow of tm.sec.
52 data.tm.sec = static_cast<decltype(data.tm.sec)>(sec.count());
53 data.tm.nsec = static_cast<decltype(data.tm.nsec)>(nsec.count());
54}
55
56namespace RTC
57{
58 template <class DataType>
60 : public ConnectorDataListenerT<DataType>
61 {
62 USE_CONNLISTENER_STATUS;
63 public:
64 Timestamp(const char* ts_type) : m_tstype(ts_type) {}
65 ~Timestamp() override = default;
66 ReturnCode operator()(ConnectorInfo& info, DataType& data) override
67 {
68 if (info.properties["timestamp_policy"] != m_tstype)
69 {
70 return NO_CHANGE;
71 }
73 return DATA_CHANGED;
74 }
75 std::string m_tstype;
76 };
77} // namespace RTC
78
79#endif // RTM_TIMESTAMP_H
connector listener class
void setTimestamp(DataType &data)
データにタイムスタンプをセットする
Definition Timestamp.h:46
ConnectorDataListenerT クラス
Definition ConnectorListener.h:515
ConnectorInfo クラス
Definition ConnectorBase.h:50
coil::Properties properties
プロパティ
Definition ConnectorBase.h:178
@ NO_CHANGE
Definition ConnectorListener.h:71
@ DATA_CHANGED
Definition ConnectorListener.h:73
Definition Timestamp.h:61
ReturnCode operator()(ConnectorInfo &info, DataType &data) override
仮想コールバックメソッド
Definition Timestamp.h:66
~Timestamp() override=default
std::string m_tstype
Definition Timestamp.h:75
Timestamp(const char *ts_type)
Definition Timestamp.h:64
RTコンポーネント