DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_utils.hpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
3// Fork baseline commit: oks-08-03-04 (2022-04-14).
4// Renamed since fork: yes (from src/oks_utils.h to src/oks_utils.hpp).
5
6#ifndef OKS_KERNEL_UTILS_H
7#define OKS_KERNEL_UTILS_H
8
9#include "oks/exceptions.hpp"
10
11#include <boost/date_time/gregorian/gregorian_types.hpp>
12#include <boost/date_time/posix_time/posix_time_types.hpp>
13
14#include <map>
15#include <string>
16
17namespace dunedaq {
18namespace oks {
19
20class OksClass;
21class OksObject;
23class OksFile;
24struct OksAliasTable;
25class OksKernel;
26
27// read date and time strings from OKS files (oks::Date, oks::Time or Boost ISO strings)
28
29boost::posix_time::ptime
30str2time(const char* value, size_t len, const char* file_name = nullptr);
31boost::gregorian::date
32str2date(const char* value, size_t len);
33
34// the structure for efficient search of objects to be re-read or to be deleted during reload
35
37{
38
39 template<typename T>
40 using map_str_t = std::map<std::string, T>;
41
42 std::map<const OksClass*, map_str_t<OksObject*>*> data;
43 std::vector<OksObject*> created;
44
46 void put(OksObject* obj);
47 OksObject* pop(const OksClass* c, const std::string& id);
48};
49
50// the structure to pass common parameters to various read() methods of OksData and OksObject class
51
53{
58 char format;
60 const char* object_tag;
63 std::string tmp;
64
66 : f(f_)
67 , s(s_)
68 , alias_table(t_)
69 , oks_kernel(k_)
70 , format(m_)
71 , reload_objects(l_)
72 {
73 init();
74 }
75
76 void init();
77};
78
79// 17-SEP-2009: for compatibility with previous OKS versions
80// FIXME: remove later ...
81
82class Date
83{
84
85public:
86 Date(const char* s) { set(s); } // dd/mm/[yy]yy
87
88 virtual ~Date() { ; }
89
90 void set(const char*);
91
92 long year() const { return p_tm.tm_year; }
93 unsigned short month() const { return p_tm.tm_mon; }
94 unsigned short day() const { return p_tm.tm_mday; }
95
96 virtual std::string str() const;
97
98protected:
99 struct tm p_tm;
100};
101
102std::ostream&
103operator<<(std::ostream&, const Date&);
104
105class Time : public Date
106{
107
108public:
109 Time(const char* s)
110 : Date(s)
111 { /*set(s);*/
112 } // dd/mm/[yy]yy hh:mm[:ss]
113
114 virtual ~Time() { ; }
115
116 unsigned short hour() const { return p_tm.tm_hour; }
117 unsigned short min() const { return p_tm.tm_min; }
118 unsigned short sec() const { return p_tm.tm_sec; }
119
120 virtual std::string str() const;
121};
122
123std::ostream&
124operator<<(std::ostream&, const Time&);
125
126} // namespace oks
127} // namespace dunedaq
128
129#endif
unsigned short day() const
Definition oks_utils.hpp:94
void set(const char *)
Definition time.cpp:27
virtual std::string str() const
Definition time.cpp:137
long year() const
Definition oks_utils.hpp:92
Date(const char *s)
Definition oks_utils.hpp:86
unsigned short month() const
Definition oks_utils.hpp:93
The OKS class.
Definition class.hpp:223
Provides interface to the OKS XML schema and data files.
Definition file.hpp:355
Provides interface to the OKS kernel.
Definition kernel.hpp:615
OksObject describes instance of OksClass.
Definition object.hpp:1144
virtual std::string str() const
Definition time.cpp:150
Time(const char *s)
unsigned short sec() const
unsigned short hour() const
unsigned short min() const
void init(unordered_map< std::string, std::string > params)
boost::posix_time::ptime str2time(const char *value, size_t len, const char *file_name=nullptr)
std::ostream & operator<<(std::ostream &s, const oks::exception &ex)
boost::gregorian::date str2date(const char *value, size_t len)
The DUNE-DAQ namespace.
msgpack::object obj
std::ostream & operator<<(std::ostream &s, const ConfigurationChange &c)
The struct OksAliasTable is used to support aliases.
Definition kernel.hpp:478
OksXmlInputStream & s
Definition oks_utils.hpp:55
ReadFileParams(OksFile *f_, OksXmlInputStream &s_, OksAliasTable *t_, OksKernel *k_, char m_, ReloadObjects *l_)
Definition oks_utils.hpp:65
ReloadObjects * reload_objects
Definition oks_utils.hpp:59
OksAliasTable * alias_table
Definition oks_utils.hpp:56
std::vector< OksObject * > created
Definition oks_utils.hpp:43
std::map< const OksClass *, map_str_t< OksObject * > * > data
Definition oks_utils.hpp:42
OksObject * pop(const OksClass *c, const std::string &id)
Definition kernel.cpp:2973
std::map< std::string, T > map_str_t
Definition oks_utils.hpp:40
void put(OksObject *obj)
Definition kernel.cpp:2964