ATLAS Offline Software
Loading...
Searching...
No Matches
DiskList.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7//
8// includes
9//
10
12
15
16//
17// method implementations
18//
19
20namespace SH
21{
22 void DiskList ::
23 testInvariant () const
24 {
26 }
27
28
29 DiskList ::
30 ~DiskList ()
31 {
33 }
34
35
36
37 DiskList ::
38 DiskList ()
40 {
41 RCU_NEW_INVARIANT (this);
42 }
43
44
45
46 bool DiskList ::
47 next ()
48 {
50 switch (m_state)
51 {
52 case S_BLANK:
53 case S_VALID:
55 if (getNext())
57 else
59 return m_state == S_VALID;
60 case S_DONE:
61 RCU_THROW_MSG ("already finished processing list");
62 case S_BROKEN:
63 RCU_THROW_MSG ("list is in error state");
64 };
65 return false; // compiler dummy
66 }
67
68
69
70 std::string DiskList ::
71 path () const
72 {
73 RCU_READ_INVARIANT (this);
74 RCU_REQUIRE2_SOFT (m_state == S_VALID, "getNext() has not been called successfully");
75 return getPath();
76 }
77
78
79
80 std::string DiskList ::
81 fileName () const
82 {
83 // no invariant used
84 std::string result = path();
85 std::string::size_type split = result.rfind ('/');
86 if (split != std::string::npos)
87 result = result.substr (split + 1);
88 return result;
89 }
90
91
92
93 DiskList *DiskList ::
94 openDir () const
95 {
96 RCU_READ_INVARIANT (this);
97 RCU_REQUIRE2_SOFT (m_state == S_VALID, "getNext() has not been called successfully");
98 return doOpenDir();
99 }
100
101
102
103 std::string DiskList ::
104 dirname () const
105 {
106 RCU_READ_INVARIANT (this);
107 return getDirname ();
108 }
109}
#define RCU_INVARIANT(x)
Definition Assert.h:196
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:230
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:226
#define RCU_REQUIRE2_SOFT(x, y)
Definition Assert.h:150
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53
virtual DiskList * doOpenDir() const =0
make a new list object for the sub-directory
std::string path() const
the path for the current entry.
Definition DiskList.cxx:71
virtual std::string getDirname() const =0
the base path for the directory listed
@ S_VALID
holding a valid entry
Definition DiskList.h:161
@ S_DONE
finished reading entries
Definition DiskList.h:162
@ S_BROKEN
an error occured
Definition DiskList.h:163
@ S_BLANK
just initialized
Definition DiskList.h:160
State m_state
the current state
Definition DiskList.h:166
virtual std::string getPath() const =0
the path for the current entry.
virtual bool getNext()=0
get the next list entry
DiskList()
standard constructor
Definition DiskList.cxx:38
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15