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