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/posix_time/posix_time_types.hpp>
12#include <boost/date_time/gregorian/gregorian_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
29 boost::posix_time::ptime str2time(const char * value, size_t len, const char * file_name = nullptr);
30 boost::gregorian::date str2date(const char * value, size_t len);
31
32
33 // the structure for efficient search of objects to be re-read or to be deleted during reload
34
36
37
38 template<typename T>
39 using map_str_t = std::map<std::string, T>;
40
41 std::map< const OksClass *, map_str_t<OksObject *> * > data;
42 std::vector<OksObject *> created;
43
45 void put(OksObject * obj);
46 OksObject * pop(const OksClass* c, const std::string& id);
47 };
48
49
50 // the structure to pass common parameters to various read() methods of OksData and OksObject class
51
69
70
71 // 17-SEP-2009: for compatibility with previous OKS versions
72 // FIXME: remove later ...
73
74 class Date {
75
76 public:
77
78 Date (const char * s) {set(s);} // dd/mm/[yy]yy
79
80 virtual ~Date() { ; }
81
82 void set(const char *);
83
84 long year() const {return p_tm.tm_year;}
85 unsigned short month() const {return p_tm.tm_mon;}
86 unsigned short day() const {return p_tm.tm_mday;}
87
88 virtual std::string str() const;
89
90
91 protected:
92
93 struct tm p_tm;
94
95 };
96
97 std::ostream& operator<<(std::ostream&, const Date&);
98
99
100 class Time : public Date {
101
102 public:
103
104 Time (const char * s) : Date(s) {/*set(s);*/} // dd/mm/[yy]yy hh:mm[:ss]
105
106 virtual ~Time() { ; }
107
108 unsigned short hour() const {return p_tm.tm_hour;}
109 unsigned short min() const {return p_tm.tm_min;}
110 unsigned short sec() const {return p_tm.tm_sec;}
111
112 virtual std::string str() const;
113 };
114
115 std::ostream& operator<<(std::ostream&, const Time&);
116
117
118} // namespace oks
119} // namespace dunedaq
120
121#endif
unsigned short day() const
Definition oks_utils.hpp:86
virtual std::string str() const
Definition time.cpp:141
long year() const
Definition oks_utils.hpp:84
Date(const char *s)
Definition oks_utils.hpp:78
unsigned short month() const
Definition oks_utils.hpp:85
The OKS class.
Definition class.hpp:205
Provides interface to the OKS XML schema and data files.
Definition file.hpp:345
Provides interface to the OKS kernel.
Definition kernel.hpp:582
OksObject describes instance of OksClass.
Definition object.hpp:841
virtual std::string str() const
Definition time.cpp:152
Time(const char *s)
unsigned short sec() const
unsigned short hour() const
unsigned short min() const
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)
Including Qt Headers.
Definition module.cpp:16
msgpack::object obj
Monitoring thread not set
The struct OksAliasTable is used to support aliases.
Definition kernel.hpp:451
OksXmlInputStream & s
Definition oks_utils.hpp:54
ReadFileParams(OksFile *f_, OksXmlInputStream &s_, OksAliasTable *t_, OksKernel *k_, char m_, ReloadObjects *l_)
Definition oks_utils.hpp:64
ReloadObjects * reload_objects
Definition oks_utils.hpp:58
OksAliasTable * alias_table
Definition oks_utils.hpp:55
OksObject * pop(const OksClass *c, const std::string &id)
Definition kernel.cpp:3189
std::map< std::string, T > map_str_t
Definition oks_utils.hpp:39
void put(OksObject *obj)
Definition kernel.cpp:3181
std::vector< OksObject * > created
Definition oks_utils.hpp:42
std::map< const OksClass *, map_str_t< OksObject * > * > data
Definition oks_utils.hpp:41