DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_utils.hpp
Go to the documentation of this file.
1#ifndef OKS_KERNEL_UTILS_H
2#define OKS_KERNEL_UTILS_H
3
4#include "oks/exceptions.hpp"
5
6#include <boost/date_time/posix_time/posix_time_types.hpp>
7#include <boost/date_time/gregorian/gregorian_types.hpp>
8
9#include <map>
10#include <string>
11
12namespace dunedaq {
13namespace oks {
14
15class OksClass;
16class OksObject;
17class OksXmlInputStream;
18class OksFile;
19struct OksAliasTable;
20class OksKernel;
21
22 // read date and time strings from OKS files (oks::Date, oks::Time or Boost ISO strings)
23
24 boost::posix_time::ptime str2time(const char * value, size_t len, const char * file_name = nullptr);
25 boost::gregorian::date str2date(const char * value, size_t len);
26
27
28 // the structure for efficient search of objects to be re-read or to be deleted during reload
29
31
32
33 template<typename T>
34 using map_str_t = std::map<std::string, T>;
35
36 std::map< const OksClass *, map_str_t<OksObject *> * > data;
37 std::vector<OksObject *> created;
38
40 void put(OksObject * obj);
41 OksObject * pop(const OksClass* c, const std::string& id);
42 };
43
44
45 // the structure to pass common parameters to various read() methods of OksData and OksObject class
46
64
65
66 // 17-SEP-2009: for compatibility with previous OKS versions
67 // FIXME: remove later ...
68
69 class Date {
70
71 public:
72
73 Date (const char * s) {set(s);} // dd/mm/[yy]yy
74
75 virtual ~Date() { ; }
76
77 void set(const char *);
78
79 long year() const {return p_tm.tm_year;}
80 unsigned short month() const {return p_tm.tm_mon;}
81 unsigned short day() const {return p_tm.tm_mday;}
82
83 virtual std::string str() const;
84
85
86 protected:
87
88 struct tm p_tm;
89
90 };
91
92 std::ostream& operator<<(std::ostream&, const Date&);
93
94
95 class Time : public Date {
96
97 public:
98
99 Time (const char * s) : Date(s) {/*set(s);*/} // dd/mm/[yy]yy hh:mm[:ss]
100
101 virtual ~Time() { ; }
102
103 unsigned short hour() const {return p_tm.tm_hour;}
104 unsigned short min() const {return p_tm.tm_min;}
105 unsigned short sec() const {return p_tm.tm_sec;}
106
107 virtual std::string str() const;
108 };
109
110 std::ostream& operator<<(std::ostream&, const Time&);
111
112
113} // namespace oks
114} // namespace dunedaq
115
116#endif
unsigned short day() const
Definition oks_utils.hpp:81
virtual std::string str() const
Definition time.cpp:136
long year() const
Definition oks_utils.hpp:79
Date(const char *s)
Definition oks_utils.hpp:73
unsigned short month() const
Definition oks_utils.hpp:80
The OKS class.
Definition class.hpp:200
Provides interface to the OKS XML schema and data files.
Definition file.hpp:340
Provides interface to the OKS kernel.
Definition kernel.hpp:577
OksObject describes instance of OksClass.
Definition object.hpp:836
virtual std::string str() const
Definition time.cpp:147
Time(const char *s)
Definition oks_utils.hpp:99
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.
Monitoring thread not set
Definition __init__.py:1
The struct OksAliasTable is used to support aliases.
Definition kernel.hpp:446
OksXmlInputStream & s
Definition oks_utils.hpp:49
ReadFileParams(OksFile *f_, OksXmlInputStream &s_, OksAliasTable *t_, OksKernel *k_, char m_, ReloadObjects *l_)
Definition oks_utils.hpp:59
ReloadObjects * reload_objects
Definition oks_utils.hpp:53
OksAliasTable * alias_table
Definition oks_utils.hpp:50
OksObject * pop(const OksClass *c, const std::string &id)
Definition kernel.cpp:3184
std::map< std::string, T > map_str_t
Definition oks_utils.hpp:34
void put(OksObject *obj)
Definition kernel.cpp:3176
std::vector< OksObject * > created
Definition oks_utils.hpp:37
std::map< const OksClass *, map_str_t< OksObject * > * > data
Definition oks_utils.hpp:36