ATLAS Offline Software
Loading...
Searching...
No Matches
SampleLocal.cxx File Reference
#include <SampleHandler/SampleLocal.h>
#include <RootCoreUtils/Assert.h>
#include <SampleHandler/SamplePtr.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 )

Definition at line 28 of file SampleLocal.cxx.

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