ATLAS Offline Software
Loading...
Searching...
No Matches
SampleComposite.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7//
8// includes
9//
10
12
16
17//
18// method implementations
19//
20
22
23namespace SH
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 RCU_THROW_MSG ("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 RCU_THROW_MSG ("Sample::numFiles not supported for SampleComposite");
72 return 0; // compiler dummy
73 }
74
75
76
77 std::string SampleComposite ::
78 getFileName (const std::size_t /*index*/) const
79 {
80 RCU_READ_INVARIANT (this);
81 RCU_THROW_MSG ("Sample::fileName not supported for SampleComposite");
82 return ""; // compiler dummy
83 }
84
85
86
87 std::vector<std::string> SampleComposite ::
88 doMakeFileList () const
89 {
90 RCU_READ_INVARIANT (this);
91
92 std::vector<std::string> result;
93 for (SamplesIter sample = m_samples.begin(),
94 end = m_samples.end(); sample != end; ++ sample)
95 {
96 std::vector<std::string> subresult = (*sample)->makeFileList();
97 result.insert (result.end(), subresult.begin(), subresult.end());
98 }
99 return result;
100 }
101
102
103
104 std::unique_ptr<SampleLocal> SampleComposite ::
105 doMakeLocal () const
106 {
107 RCU_READ_INVARIANT (this);
108 RCU_THROW_MSG ("Sample::makeLocal not supported for SampleComposite");
109 return {}; // compiler dummy
110 }
111
112
113
114 void SampleComposite ::
115 doUpdateLocation (const std::string& from, const std::string& to)
116 {
117 RCU_READ_INVARIANT (this);
118 for (auto sample = m_samples.begin(),
119 end = m_samples.end(); sample != end; ++ sample)
120 {
121 (*sample)->updateLocation (from, to);
122 }
123 }
124
125
126
127 bool SampleComposite ::
128 getContains (const std::string& name) const
129 {
130 RCU_READ_INVARIANT (this);
131 for (SamplesIter sample = m_samples.begin(),
132 end = m_samples.end(); sample != end; ++ sample)
133 {
134 if ((*sample)->contains (name))
135 return true;
136 };
137 return false;
138 }
139
140
141
142 void SampleComposite ::
143 doAddSamples (SampleHandler& result, const std::shared_ptr<Sample>& /*self*/)
144 {
145 RCU_READ_INVARIANT (this);
146 for (auto& sample : m_samples)
147 {
148 sample->addSamples (result, sample);
149 };
150 }
151}
#define RCU_INVARIANT(x)
Definition Assert.h:196
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:226
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:148
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53
ClassImp(SH::SampleComposite) namespace SH
This module defines an implementation of Sample that contains composite samples.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15