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
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10// Please feel free to contact me (krumnack@iastate.edu) for bug
11// reports, feature suggestions, praise and complaints.
12
13
14//
15// includes
16//
17
19
22
23//
24// method implementations
25//
26
27namespace SH
28{
29 void DiskList ::
30 testInvariant () const
31 {
33 }
34
35
36 DiskList ::
37 ~DiskList ()
38 {
40 }
41
42
43
44 DiskList ::
45 DiskList ()
47 {
48 RCU_NEW_INVARIANT (this);
49 }
50
51
52
53 bool DiskList ::
54 next ()
55 {
57 switch (m_state)
58 {
59 case S_BLANK:
60 case S_VALID:
62 if (getNext())
64 else
66 return m_state == S_VALID;
67 case S_DONE:
68 RCU_THROW_MSG ("already finished processing list");
69 case S_BROKEN:
70 RCU_THROW_MSG ("list is in error state");
71 };
72 return false; // compiler dummy
73 }
74
75
76
77 std::string DiskList ::
78 path () const
79 {
80 RCU_READ_INVARIANT (this);
81 RCU_REQUIRE2_SOFT (m_state == S_VALID, "getNext() has not been called successfully");
82 return getPath();
83 }
84
85
86
87 std::string DiskList ::
88 fileName () const
89 {
90 // no invariant used
91 std::string result = path();
92 std::string::size_type split = result.rfind ('/');
93 if (split != std::string::npos)
94 result = result.substr (split + 1);
95 return result;
96 }
97
98
99
100 DiskList *DiskList ::
101 openDir () const
102 {
103 RCU_READ_INVARIANT (this);
104 RCU_REQUIRE2_SOFT (m_state == S_VALID, "getNext() has not been called successfully");
105 return doOpenDir();
106 }
107
108
109
110 std::string DiskList ::
111 dirname () const
112 {
113 RCU_READ_INVARIANT (this);
114 return getDirname ();
115 }
116}
#define RCU_INVARIANT(x)
Definition Assert.h:201
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_REQUIRE2_SOFT(x, y)
Definition Assert.h:155
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
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:78
virtual std::string getDirname() const =0
the base path for the directory listed
@ S_VALID
holding a valid entry
Definition DiskList.h:169
@ S_DONE
finished reading entries
Definition DiskList.h:170
@ S_BROKEN
an error occured
Definition DiskList.h:171
@ S_BLANK
just initialized
Definition DiskList.h:168
State m_state
the current state
Definition DiskList.h:174
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:45
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15