DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
oksdalgen
apps
class_info.hpp
Go to the documentation of this file.
1
//
2
// DUNE DAQ modification notice:
3
// This file has been modified from the original ATLAS genconfig source for the DUNE DAQ project.
4
// Fork baseline commit: genconfig-03-10-00 (2021-04-26).
5
// Renamed since fork: yes (from src/class_info.h to apps/class_info.hpp).
6
//
7
8
#ifndef __OKSDALGEN_CLASS_INFO__
9
#define __OKSDALGEN_CLASS_INFO__
10
11
#include "
oks/class.hpp
"
12
13
#include <map>
14
#include <ostream>
15
#include <set>
16
#include <string>
17
18
namespace
dunedaq
{
19
namespace
oksdalgen
{
20
21
class
ClassInfo
{
22
23
public
:
24
25
struct
SortByName
{
26
bool
operator()
(
const
oks::OksClass
* c1,
const
oks::OksClass
* c2)
const
{
27
return
c1->
get_name
() < c2->
get_name
();
28
}
29
};
30
31
typedef
std::map<const oks::OksClass *, ClassInfo, SortByName>
Map
;
32
33
ClassInfo
() {};
34
35
ClassInfo
(
const
std::string& cpp_ns_name,
const
std::string& dir_prefix) :
36
p_namespace
(cpp_ns_name),
p_include_prefix
(dir_prefix) {};
37
38
const
std::string&
get_namespace
()
const
{
return
p_namespace
;}
39
const
std::string&
get_include_prefix
()
const
{
return
p_include_prefix
;}
40
41
42
private
:
43
44
std::string
p_namespace
;
45
std::string
p_include_prefix
;
46
47
};
48
49
struct
NameSpaceInfo
50
{
51
std::set<std::string>
m_classes
;
52
std::map<std::string, NameSpaceInfo>
m_nested
;
53
54
bool
55
empty
()
const
56
{
57
return
(
m_classes
.empty() &&
m_nested
.empty());
58
}
59
60
void
61
add
(
const
std::string &ns_name,
const
std::string &class_name)
62
{
63
if
(!ns_name.empty())
64
{
65
std::string::size_type idx = ns_name.find_first_of(
':'
);
66
NameSpaceInfo
&ns =
m_nested
[ns_name.substr(0, idx)];
67
if
(idx != std::string::npos)
68
ns.
add
(ns_name.substr(ns_name.find_first_not_of(
':'
, idx)), class_name);
69
else
70
ns.
add
(
""
, class_name);
71
}
72
else
73
m_classes
.insert(class_name);
74
}
75
76
void
77
print
(std::ostream &s,
int
level)
const
78
{
79
std::string dx(level * 2,
' '
);
80
81
for
(
const
auto
&x :
m_nested
)
82
{
83
s << dx <<
"namespace "
<< x.first <<
" {\n"
;
84
x.second.print(s, level + 1);
85
s << dx <<
"}\n"
;
86
}
87
88
for
(
const
auto
&x :
m_classes
)
89
s << dx <<
"class "
<< x <<
";\n"
;
90
}
91
};
92
93
}
// namespace oksdalgen
94
}
// namespace dunedaq
95
#endif
class.hpp
dunedaq::oks::OksClass
The OKS class.
Definition
class.hpp:205
dunedaq::oks::OksClass::get_name
const std::string & get_name() const noexcept
Definition
class.hpp:368
dunedaq::oksdalgen::ClassInfo::ClassInfo
ClassInfo(const std::string &cpp_ns_name, const std::string &dir_prefix)
Definition
class_info.hpp:35
dunedaq::oksdalgen::ClassInfo::p_include_prefix
std::string p_include_prefix
Definition
class_info.hpp:45
dunedaq::oksdalgen::ClassInfo::Map
std::map< const oks::OksClass *, ClassInfo, SortByName > Map
Definition
class_info.hpp:31
dunedaq::oksdalgen::ClassInfo::ClassInfo
ClassInfo()
Definition
class_info.hpp:33
dunedaq::oksdalgen::ClassInfo::get_namespace
const std::string & get_namespace() const
Definition
class_info.hpp:38
dunedaq::oksdalgen::ClassInfo::p_namespace
std::string p_namespace
Definition
class_info.hpp:44
dunedaq::oksdalgen::ClassInfo::get_include_prefix
const std::string & get_include_prefix() const
Definition
class_info.hpp:39
dunedaq::oksdalgen
Definition
class_info.hpp:19
dunedaq
Including Qt Headers.
Definition
module.cpp:16
dunedaq::oksdalgen::ClassInfo::SortByName
Definition
class_info.hpp:25
dunedaq::oksdalgen::ClassInfo::SortByName::operator()
bool operator()(const oks::OksClass *c1, const oks::OksClass *c2) const
Definition
class_info.hpp:26
dunedaq::oksdalgen::NameSpaceInfo
Definition
class_info.hpp:50
dunedaq::oksdalgen::NameSpaceInfo::print
void print(std::ostream &s, int level) const
Definition
class_info.hpp:77
dunedaq::oksdalgen::NameSpaceInfo::m_nested
std::map< std::string, NameSpaceInfo > m_nested
Definition
class_info.hpp:52
dunedaq::oksdalgen::NameSpaceInfo::m_classes
std::set< std::string > m_classes
Definition
class_info.hpp:51
dunedaq::oksdalgen::NameSpaceInfo::empty
bool empty() const
Definition
class_info.hpp:55
dunedaq::oksdalgen::NameSpaceInfo::add
void add(const std::string &ns_name, const std::string &class_name)
Definition
class_info.hpp:61
Generated on
for DUNE-DAQ by
1.17.0