ATLAS Offline Software
Loading...
Searching...
No Matches
JobConfig.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9//
10// includes
11//
12
13#include <EventLoop/JobConfig.h>
14
20
21//
22// method implementations
23//
24
26
27namespace EL
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 {
50 RCU_READ_INVARIANT (&that);
51
52 for (const auto& algorithm : that.m_algorithms)
53 {
54 if (algorithm != nullptr)
55 {
56 m_algorithms.push_back (algorithm->makeClone ());
57 } else
58 {
59 m_algorithms.emplace_back (nullptr);
60 }
61 }
62
63 RCU_NEW_INVARIANT (this);
64 }
65
66
67
68 JobConfig ::
69 JobConfig (JobConfig&& that) noexcept
70 : JobConfig ()
71 {
72 that.swap (*this);
73
74 // no invariant used
75 }
76
77
78
79 JobConfig ::
80 ~JobConfig () noexcept
81 {
83
84 // not actually doing anything here, but have to make the
85 // destructor explicit to break include dependencies.
86 }
87
88
89
90 JobConfig& JobConfig ::
91 operator = (const JobConfig& that)
92 {
93 // no invariant used
94 JobConfig (that).swap (*this);
95 return *this;
96 }
97
98
99
100 JobConfig& JobConfig ::
101 operator = (JobConfig&& that) noexcept
102 {
103 // no invariant used
104 that.swap (*this);
105 return *this;
106 }
107
108
109
110 void JobConfig ::
111 swap (JobConfig& that) noexcept
112 {
114 RCU_CHANGE_INVARIANT (&that);
115 std::swap (m_algorithmCount, that.m_algorithmCount);
116 m_algorithms.swap (that.m_algorithms);
117 }
118
119
120
121 ::StatusCode JobConfig ::
122 addAlgorithm (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
123 {
124 using namespace msgEventLoop;
125
127 RCU_REQUIRE (val_algorithm != nullptr);
128
129 if (getAlgorithm (val_algorithm->getName()) != nullptr)
130 {
131 ANA_MSG_ERROR ("can't have two algorithms with the same name: " << val_algorithm->getName());
132 return ::StatusCode::FAILURE;
133 }
134
135 m_algorithms.push_back (std::move (val_algorithm));
136 ++ m_algorithmCount;
137 return ::StatusCode::SUCCESS;
138 }
139
140
141
142 const IAlgorithmWrapper *JobConfig ::
143 getAlgorithm (std::string_view name) const noexcept
144 {
145 RCU_READ_INVARIANT (this);
146 for (const auto& algorithm : m_algorithms)
147 {
148 if (algorithm != nullptr && algorithm->getName() == name)
149 return algorithm.get();
150 }
151 return nullptr;
152 }
153
154
155
156 std::vector<Detail::AlgorithmData> JobConfig ::
157 extractAlgorithms ()
158 {
160 if (m_algorithmCount != m_algorithms.size())
161 RCU_THROW_MSG ("algorithm count missmatch. streaming error?");
162 for (const auto& algorithm : m_algorithms)
163 {
164 if (algorithm == nullptr)
165 RCU_THROW_MSG ("algorithm null. streaming error?");
166 }
167 m_algorithmCount = 0;
168 std::vector<Detail::AlgorithmData> result;
169 result.reserve (m_algorithms.size());
170 for (auto& algorithm : m_algorithms)
171 result.emplace_back (std::move (algorithm));
172 m_algorithms.clear();
173 for (auto sequenceStartIndex : m_algSequenceStartIndices)
174 {
175 // need to check here, since the user could have added a new
176 // sequence start at the end of the list, without adding an
177 // algorithm for it.
178 if (sequenceStartIndex < result.size())
179 result[sequenceStartIndex].m_sequenceStart = true;
180 }
181 return result;
182 }
183
184
185
186 std::size_t JobConfig ::
187 numberOfAlgorithms () const noexcept
188 {
189 RCU_READ_INVARIANT (this);
190 return m_algorithms.size();
191 }
192
193
194
195 void
196 JobConfig ::
197 startNewAlgSequence ()
198 {
200 m_algSequenceStartIndices.push_back (m_algorithms.size());
201 }
202}
#define RCU_INVARIANT(x)
Definition Assert.h:201
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_REQUIRE(x)
Definition Assert.h:208
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
ClassImp(EL::JobConfig) namespace EL
Definition JobConfig.cxx:25
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
the job configuration that is independent of driver and dataset
Definition JobConfig.h:45
std::string algorithm
Definition hcg.cxx:87
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)