Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
JGIZMO::JRootObjectID Class Reference

Auxiliary class to handle file name, ROOT directory and object name. More...

#include <JRootObjectID.hh>

Public Member Functions

 JRootObjectID ()
 Default constructor. More...
 
 JRootObjectID (const std::string &file_name, const std::string &name)
 Constructor. More...
 
const std::string & getFilename () const
 Get file name. More...
 
TString getDirectory () const
 Get directory. More...
 
TString getObjectName () const
 Get object name. More...
 
TString getFullFilename () const
 Get full file name, including path. More...
 
TString getFullObjectName () const
 Get full object name, including path. More...
 
bool is_valid () const
 Check validity. More...
 
void clear ()
 Clear. More...
 

Static Public Attributes

static const char LABEL_L_BRACKET = '['
 left bracket for label More...
 
static const char LABEL_R_BRACKET = ']'
 right bracket for label More...
 
static const char FILENAME_SEPARATOR = ':'
 file name separator More...
 
static const char PATHNAME_SEPARATOR = '/'
 path name separator More...
 

Protected Attributes

std::string file_name
 
std::string directory
 
std::string name
 

Friends

bool operator== (const JRootObjectID &first, const JRootObjectID &second)
 Equal operator for object identifiers. More...
 
std::istream & operator>> (std::istream &in, JRootObjectID &object)
 Read object identifier from input. More...
 
std::ostream & operator<< (std::ostream &out, const JRootObjectID &object)
 Write object identifier to output. More...
 

Detailed Description

Auxiliary class to handle file name, ROOT directory and object name.

The general syntax is as follows:

  <file name>:[<directory/>]<object name>

where <directory> is optional and <object name> may be a regular expression (TRegexp).

Definition at line 36 of file JRootObjectID.hh.

Constructor & Destructor Documentation

JGIZMO::JRootObjectID::JRootObjectID ( )
inline

Default constructor.

Definition at line 49 of file JRootObjectID.hh.

50  {}
JGIZMO::JRootObjectID::JRootObjectID ( const std::string &  file_name,
const std::string &  name 
)
inline

Constructor.

Parameters
file_namefile name
nameobject name

Definition at line 59 of file JRootObjectID.hh.

60  :
62  directory(""),
63  name (name)
64  {}

Member Function Documentation

const std::string& JGIZMO::JRootObjectID::getFilename ( ) const
inline

Get file name.

Returns
file name

Definition at line 72 of file JRootObjectID.hh.

73  {
74  return file_name;
75  }
TString JGIZMO::JRootObjectID::getDirectory ( ) const
inline

Get directory.

Returns
directory

Definition at line 83 of file JRootObjectID.hh.

84  {
85  return TString(directory.c_str());
86  }
TString JGIZMO::JRootObjectID::getObjectName ( ) const
inline

Get object name.

Returns
object name

Definition at line 94 of file JRootObjectID.hh.

95  {
96  return TString(name.c_str());
97  }
TString JGIZMO::JRootObjectID::getFullFilename ( ) const
inline

Get full file name, including path.

Returns
file name

Definition at line 105 of file JRootObjectID.hh.

106  {
107  if (getDirectory() == "")
108  return getFilename();
109  else
111  }
const std::string & getFilename() const
Get file name.
TString getDirectory() const
Get directory.
static const char PATHNAME_SEPARATOR
path name separator
TString JGIZMO::JRootObjectID::getFullObjectName ( ) const
inline

Get full object name, including path.

Returns
object name

Definition at line 119 of file JRootObjectID.hh.

120  {
121  if (getDirectory() == "")
122  return getObjectName();
123  else
125  }
TString getDirectory() const
Get directory.
static const char PATHNAME_SEPARATOR
path name separator
TString getObjectName() const
Get object name.
bool JGIZMO::JRootObjectID::is_valid ( ) const
inline

Check validity.

Returns
true if valid ROOT object identifier; else false

Definition at line 133 of file JRootObjectID.hh.

134  {
135  return (file_name != "" &&
136  name != "");
137  }
void JGIZMO::JRootObjectID::clear ( )
inline

Clear.

Definition at line 142 of file JRootObjectID.hh.

143  {
144  file_name.clear();
145  directory.clear();
146  name .clear();
147  }

Friends And Related Function Documentation

bool operator== ( const JRootObjectID first,
const JRootObjectID second 
)
friend

Equal operator for object identifiers.

Parameters
firstfirst object identifier
secondsecond object identifier
Returns
true if first and second object identifier are equal; else false

Definition at line 157 of file JRootObjectID.hh.

158  {
159  return (first.getFilename() == second.getFilename() &&
160  first.getDirectory() == second.getDirectory() &&
161  first.getObjectName() == second.getObjectName());
162  }
const std::string & getFilename() const
Get file name.
TString getDirectory() const
Get directory.
TString getObjectName() const
Get object name.
std::istream& operator>> ( std::istream &  in,
JRootObjectID object 
)
friend

Read object identifier from input.

Parameters
ininput stream
objectobject identifier
Returns
input stream

Definition at line 172 of file JRootObjectID.hh.

173  {
174  using namespace std;
175 
176  object.clear();
177 
178  string buffer;
179 
180  for (int bracket = 0; in.peek() != EOF; ) {
181 
182  const char c = (char) in.get();
183 
184  if (c == LABEL_L_BRACKET) {
185 
186  ++bracket;
187 
188  } else if (c == LABEL_R_BRACKET) {
189 
190  --bracket;
191 
192  } else if (isspace(c)) {
193 
194  if (bracket <= 0) {
195  break;
196  }
197  }
198 
199  buffer.push_back(c);
200  }
201 
202  size_t pos = buffer.find(FILENAME_SEPARATOR);
203 
204  if (pos != string::npos) {
205 
206  object.file_name = buffer.substr(0, pos);
207  object.name = buffer.substr(pos + 1);
208 
209  pos = object.name.rfind(PATHNAME_SEPARATOR);
210 
211  if (pos != string::npos) {
212 
213  object.directory = object.name.substr(0, pos);
214  object.name = object.name.substr(pos + 1);
215  }
216 
217  } else if (!buffer.empty()) {
218 
219  throw JParseError("JRootObjectID error parsing " + buffer);
220  }
221 
222  return in;
223  }
static const char LABEL_L_BRACKET
left bracket for label
static const char LABEL_R_BRACKET
right bracket for label
static const char FILENAME_SEPARATOR
file name separator
static const char PATHNAME_SEPARATOR
path name separator
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
std::ostream& operator<< ( std::ostream &  out,
const JRootObjectID object 
)
friend

Write object identifier to output.

Parameters
outoutput stream
objectobject identifier
Returns
output stream

Definition at line 233 of file JRootObjectID.hh.

234  {
235  return out << object.getFilename() << FILENAME_SEPARATOR << object.getFullObjectName();
236  }
static const char FILENAME_SEPARATOR
file name separator

Member Data Documentation

const char JGIZMO::JRootObjectID::LABEL_L_BRACKET = '['
static

left bracket for label

Definition at line 40 of file JRootObjectID.hh.

const char JGIZMO::JRootObjectID::LABEL_R_BRACKET = ']'
static

right bracket for label

Definition at line 41 of file JRootObjectID.hh.

const char JGIZMO::JRootObjectID::FILENAME_SEPARATOR = ':'
static

file name separator

Definition at line 42 of file JRootObjectID.hh.

const char JGIZMO::JRootObjectID::PATHNAME_SEPARATOR = '/'
static

path name separator

Definition at line 43 of file JRootObjectID.hh.

std::string JGIZMO::JRootObjectID::file_name
protected

Definition at line 239 of file JRootObjectID.hh.

std::string JGIZMO::JRootObjectID::directory
protected

Definition at line 240 of file JRootObjectID.hh.

std::string JGIZMO::JRootObjectID::name
protected

Definition at line 241 of file JRootObjectID.hh.


The documentation for this class was generated from the following file: