ATLAS Offline Software
Loading...
Searching...
No Matches
JobConfig.cxx File Reference
Include dependency graph for JobConfig.cxx:

Go to the source code of this file.

Functions

 ClassImp (EL::JobConfig) namespace EL

Function Documentation

◆ ClassImp()

ClassImp ( EL::JobConfig )
Author
Nils Krumnack

Definition at line 25 of file JobConfig.cxx.

28{
29 void JobConfig ::
30 testInvariant () const
31 {
32 RCU_INVARIANT (this != nullptr);
33 }
34
35
36
37 JobConfig ::
38 JobConfig () noexcept
39 {
40 RCU_NEW_INVARIANT (this);
41 }
42
43
44
45 JobConfig ::
46 JobConfig (const JobConfig& that)
47 : TObject (that),
48 m_algorithmCount (that.m_algorithmCount),
49 m_algSequenceStartIndices (that.m_algSequenceStartIndices)
50 {
51 RCU_READ_INVARIANT (&that);
52
53 for (const auto& algorithm : that.m_algorithms)
54 {
55 if (algorithm != nullptr)
56 {
57 m_algorithms.push_back (algorithm->makeClone ());
58 } else
59 {
60 m_algorithms.emplace_back (nullptr);
61 }
62 }
63
64 RCU_NEW_INVARIANT (this);
65 }
66
67
68
69 JobConfig ::
70 JobConfig (JobConfig&& that) noexcept
71 : JobConfig ()
72 {
73 that.swap (*this);
74
75 // no invariant used
76 }
77
78
79
80 JobConfig ::
81 ~JobConfig () noexcept
82 {
84
85 // not actually doing anything here, but have to make the
86 // destructor explicit to break include dependencies.
87 }
88
89
90
91 JobConfig& JobConfig ::
92 operator = (const JobConfig& that)
93 {
94 // no invariant used
95 JobConfig (that).swap (*this);
96 return *this;
97 }
98
99
100
101 JobConfig& JobConfig ::
102 operator = (JobConfig&& that) noexcept
103 {
104 // no invariant used
105 that.swap (*this);
106 return *this;
107 }
108
109
110
111 void JobConfig ::
112 swap (JobConfig& that) noexcept
113 {
115 RCU_CHANGE_INVARIANT (&that);
116 std::swap (m_algorithmCount, that.m_algorithmCount);
117 m_algorithms.swap (that.m_algorithms);
118 m_algSequenceStartIndices.swap (that.m_algSequenceStartIndices);
119 }
120
121
122
123 ::StatusCode JobConfig ::
124 addAlgorithm (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
125 {
126 using namespace msgEventLoop;
127
129 RCU_REQUIRE (val_algorithm != nullptr);
130
131 if (getAlgorithm (val_algorithm->getName()) != nullptr)
132 {
133 ANA_MSG_ERROR ("can't have two algorithms with the same name: " << val_algorithm->getName());
134 return ::StatusCode::FAILURE;
135 }
136
137 m_algorithms.push_back (std::move (val_algorithm));
138 ++ m_algorithmCount;
139 return ::StatusCode::SUCCESS;
140 }
141
142
143
144 const IAlgorithmWrapper *JobConfig ::
145 getAlgorithm (std::string_view name) const noexcept
146 {
147 RCU_READ_INVARIANT (this);
148 for (const auto& algorithm : m_algorithms)
149 {
150 if (algorithm != nullptr && algorithm->getName() == name)
151 return algorithm.get();
152 }
153 return nullptr;
154 }
155
156
157
158 std::vector<Detail::AlgorithmData> JobConfig ::
159 extractAlgorithms ()
160 {
162 if (m_algorithmCount != m_algorithms.size())
163 RCU_THROW_MSG ("algorithm count missmatch. streaming error?");
164 for (const auto& algorithm : m_algorithms)
165 {
166 if (algorithm == nullptr)
167 RCU_THROW_MSG ("algorithm null. streaming error?");
168 }
169 m_algorithmCount = 0;
170 std::vector<Detail::AlgorithmData> result;
171 result.reserve (m_algorithms.size());
172 for (auto& algorithm : m_algorithms)
173 result.emplace_back (std::move (algorithm));
174 m_algorithms.clear();
175 for (auto sequenceStartIndex : m_algSequenceStartIndices)
176 {
177 // need to check here, since the user could have added a new
178 // sequence start at the end of the list, without adding an
179 // algorithm for it.
180 if (sequenceStartIndex < result.size())
181 result[sequenceStartIndex].m_sequenceStart = true;
182 }
183 return result;
184 }
185
186
187
188 std::size_t JobConfig ::
189 numberOfAlgorithms () const noexcept
190 {
191 RCU_READ_INVARIANT (this);
192 return m_algorithms.size();
193 }
194
195
196
197 void
198 JobConfig ::
199 startNewAlgSequence ()
200 {
202 m_algSequenceStartIndices.push_back (m_algorithms.size());
203 }
204}
#define RCU_INVARIANT(x)
Definition Assert.h:196
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:230
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:226
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
#define RCU_REQUIRE(x)
Definition Assert.h:203
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53
std::string algorithm
Definition hcg.cxx:87
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)