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

Go to the source code of this file.

Functions

 ClassImp (SH::SampleLocal) namespace SH

Function Documentation

◆ ClassImp()

ClassImp ( SH::SampleLocal )
Author
Nils Krumnack

Definition at line 20 of file SampleLocal.cxx.

23{
24 void SampleLocal ::
25 testInvariant () const
26 {
27 for (FilesIter file = m_files.begin(),
28 end = m_files.end(); file != end; ++ file)
29 {
30 RCU_INVARIANT (!file->empty());
31 RCU_INVARIANT ((*file)[0]==0 || file->find (":/") != std::string::npos);
32 }
33 }
34
35
36
37 SampleLocal ::
38 SampleLocal ()
39 : Sample ("unnamed")
40 {
41 RCU_NEW_INVARIANT (this);
42 }
43
44
45
46 SampleLocal ::
47 SampleLocal (const std::string& name)
48 : Sample (name)
49 {
50 RCU_NEW_INVARIANT (this);
51 }
52
53
54
55 void SampleLocal ::
56 add (const std::string& file)
57 {
59 RCU_REQUIRE_SOFT (!file.empty());
60
61 std::string myfile = file;
62 if (myfile.find (":/") == std::string::npos)
63 {
64 if (myfile[0] != '/')
65 myfile = gSystem->WorkingDirectory() + ("/" + myfile);
66 myfile = "file://" + myfile;
67 }
68 m_files.push_back (myfile);
69 }
70
71
72
73 std::size_t SampleLocal ::
74 getNumFiles () const
75 {
76 RCU_READ_INVARIANT (this);
77 return m_files.size();
78 }
79
80
81
82 std::string SampleLocal ::
83 getFileName (const std::size_t index) const
84 {
85 RCU_READ_INVARIANT (this);
86
87 RCU_INVARIANT (index < m_files.size());
88 return m_files[index];
89 }
90
91
92
93 std::unique_ptr<SampleLocal> SampleLocal ::
94 doMakeLocal () const
95 {
96 RCU_READ_INVARIANT (this);
97 return std::make_unique<SampleLocal>(*this);
98 }
99
100
101
102 std::vector<std::string> SampleLocal ::
103 doMakeFileList () const
104 {
105 RCU_READ_INVARIANT (this);
106
107 std::vector<std::string> result;
108 for (FilesIter file = m_files.begin(),
109 end = m_files.end(); file != end; ++ file)
110 result.push_back (*file);
111 return result;
112 }
113
114
115
116 void SampleLocal ::
117 doUpdateLocation (const std::string& from, const std::string& to)
118 {
119 RCU_READ_INVARIANT (this);
120 for (FilesMIter file = m_files.begin(),
121 end = m_files.end(); file != end; ++ file)
122 {
123 if (strncmp (file->c_str(), from.c_str(), from.size()) == 0)
124 *file = to + "/" + file->substr (from.size());
125 }
126 }
127}
#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
CONT to(RANGE &&r)
Definition ranges.h:39
Definition index.py:1
TFile * file