ATLAS Offline Software
Loading...
Searching...
No Matches
SampleComposite.cxx File Reference
#include <SampleHandler/SampleComposite.h>
#include <stdexcept>
#include <RootCoreUtils/Assert.h>
#include <SampleHandler/SampleLocal.h>
Include dependency graph for SampleComposite.cxx:

Go to the source code of this file.

Functions

 ClassImp (SH::SampleComposite) namespace SH

Function Documentation

◆ ClassImp()

ClassImp ( SH::SampleComposite )
Author
Nils Krumnack

Definition at line 21 of file SampleComposite.cxx.

24{
25 void SampleComposite ::
26 testInvariant () const
27 {
28 for (const auto& sample : m_samples)
29 {
30 RCU_INVARIANT (sample != nullptr);
31 }
32 }
33
34
35
36 SampleComposite ::
37 SampleComposite ()
38 : Sample ("unnamed")
39 {
40 RCU_NEW_INVARIANT (this);
41 }
42
43
44
45 SampleComposite ::
46 SampleComposite (const std::string& name)
47 : Sample (name)
48 {
49 RCU_NEW_INVARIANT (this);
50 }
51
52
53
54 void SampleComposite ::
55 add (std::shared_ptr<Sample> sample)
56 {
58 RCU_REQUIRE_SOFT (sample != nullptr);
59 if (contains (sample->name()))
60 throw std::runtime_error ("trying to add sample " + sample->name() + " to sample " + name() + ", which already contains a sample " + sample->name());
61 m_samples.push_back (std::move (sample));
62 }
63
64
65
66 std::size_t SampleComposite ::
67 getNumFiles () const
68 {
69 RCU_READ_INVARIANT (this);
70 throw std::runtime_error ("Sample::numFiles not supported for SampleComposite");
71 }
72
73
74
75 std::string SampleComposite ::
76 getFileName (const std::size_t /*index*/) const
77 {
78 RCU_READ_INVARIANT (this);
79 throw std::runtime_error ("Sample::fileName not supported for SampleComposite");
80 }
81
82
83
84 std::vector<std::string> SampleComposite ::
85 doMakeFileList () const
86 {
87 RCU_READ_INVARIANT (this);
88
89 std::vector<std::string> result;
90 for (const auto& sample : m_samples)
91 {
92 std::vector<std::string> subresult = sample->makeFileList();
93 result.insert (result.end(), subresult.begin(), subresult.end());
94 }
95 return result;
96 }
97
98
99
100 std::unique_ptr<SampleLocal> SampleComposite ::
101 doMakeLocal () const
102 {
103 RCU_READ_INVARIANT (this);
104 throw std::runtime_error ("Sample::makeLocal not supported for SampleComposite");
105 }
106
107
108
109 void SampleComposite ::
110 doUpdateLocation (const std::string& from, const std::string& to)
111 {
112 RCU_READ_INVARIANT (this);
113 for (const auto& sample : m_samples)
114 {
115 sample->updateLocation (from, to);
116 }
117 }
118
119
120
121 bool SampleComposite ::
122 getContains (const std::string& name) const
123 {
124 RCU_READ_INVARIANT (this);
125 for (const auto& sample : m_samples)
126 {
127 if (sample->contains (name))
128 return true;
129 }
130 return false;
131 }
132
133
134
135 void SampleComposite ::
136 doAddSamples (SampleHandler& result, const std::shared_ptr<Sample>& /*self*/)
137 {
138 RCU_READ_INVARIANT (this);
139 for (auto& sample : m_samples)
140 {
141 sample->addSamples (result, sample);
142 }
143 }
144}
#define RCU_INVARIANT(x)
Definition Assert.h:187
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:141
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116