Jpp  18.0.1-rc.1
the software that should make you happy
 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...
 
 JRootObjectID (const std::string &file_name, const std::string &dir, const std::string &name)
 Constructor. More...
 
 JRootObjectID (const std::string &full_name)
 Constructor. More...
 
const std::stringgetFilename () 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  {}
JGIZMO::JRootObjectID::JRootObjectID ( const std::string file_name,
const std::string dir,
const std::string name 
)
inline

Constructor.

Parameters
file_namefile name
dirdirectory name
nameobject name

Definition at line 74 of file JRootObjectID.hh.

76  :
78  directory(dir),
79  name (name)
80  {}
JGIZMO::JRootObjectID::JRootObjectID ( const std::string full_name)
inline

Constructor.

Parameters
full_namefull object name

Definition at line 88 of file JRootObjectID.hh.

89  {
90  std::istringstream(full_name) >> *this;
91  }

Member Function Documentation

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

Get file name.

Returns
file name

Definition at line 99 of file JRootObjectID.hh.

100  {
101  return file_name;
102  }
TString JGIZMO::JRootObjectID::getDirectory ( ) const
inline

Get directory.

Returns
directory

Definition at line 110 of file JRootObjectID.hh.

111  {
112  return TString(directory.c_str());
113  }
TString JGIZMO::JRootObjectID::getObjectName ( ) const
inline

Get object name.

Returns
object name

Definition at line 121 of file JRootObjectID.hh.

122  {
123  return TString(name.c_str());
124  }
TString JGIZMO::JRootObjectID::getFullFilename ( ) const
inline

Get full file name, including path.

Returns
file name

Definition at line 132 of file JRootObjectID.hh.

133  {
134  if (getDirectory() == "")
135  return getFilename();
136  else
138  }
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 146 of file JRootObjectID.hh.

147  {
148  if (getDirectory() == "")
149  return getObjectName();
150  else
152  }
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 160 of file JRootObjectID.hh.

161  {
162  return (file_name != "" &&
163  name != "");
164  }
void JGIZMO::JRootObjectID::clear ( )
inline

Clear.

Definition at line 169 of file JRootObjectID.hh.

170  {
171  file_name.clear();
172  directory.clear();
173  name .clear();
174  }

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 184 of file JRootObjectID.hh.

185  {
186  return (first.getFilename() == second.getFilename() &&
187  first.getDirectory() == second.getDirectory() &&
188  first.getObjectName() == second.getObjectName());
189  }
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 199 of file JRootObjectID.hh.

200  {
201  using namespace std;
202 
203  object.clear();
204 
205  string buffer;
206 
207  for (int bracket = 0; in.peek() != EOF; ) {
208 
209  const char c = (char) in.get();
210 
211  if (c == LABEL_L_BRACKET) {
212 
213  ++bracket;
214 
215  } else if (c == LABEL_R_BRACKET) {
216 
217  --bracket;
218 
219  } else if (isspace(c)) {
220 
221  if (bracket <= 0) {
222  break;
223  }
224  }
225 
226  buffer.push_back(c);
227  }
228 
229  size_t pos = buffer.find(FILENAME_SEPARATOR);
230 
231  if (pos != string::npos) {
232 
233  object.file_name = buffer.substr(0, pos);
234  object.name = buffer.substr(pos + 1);
235 
236  pos = object.name.rfind(PATHNAME_SEPARATOR);
237 
238  if (pos != string::npos) {
239 
240  object.directory = object.name.substr(0, pos);
241  object.name = object.name.substr(pos + 1);
242  }
243 
244  } else if (!buffer.empty()) {
245 
246  throw JParseError("JRootObjectID error parsing " + buffer);
247  }
248 
249  return in;
250  }
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
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
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 260 of file JRootObjectID.hh.

261  {
262  return out << object.getFilename() << FILENAME_SEPARATOR << object.getFullObjectName();
263  }
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 266 of file JRootObjectID.hh.

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

Definition at line 267 of file JRootObjectID.hh.

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

Definition at line 268 of file JRootObjectID.hh.


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