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
JDATABASE::JUPI Struct Reference

Universal product identifier (UPI). More...

#include <JUPI.hh>

Inheritance diagram for JDATABASE::JUPI:
JDATABASE::JPBS std::vector< int > JDETECTOR::JHVCalibration_t

Public Member Functions

 JUPI ()
 Default constructor. More...
 
 JUPI (const JPBS &pbs, const std::string &variant="")
 Constructor. More...
 
 JUPI (const std::string &upi)
 Constructor. More...
 
const JUPIgetUPI () const
 Get UPI. More...
 
const std::string & getVariant () const
 Get variant. More...
 
 ClassDefNV (JUPI, 1)
 
const JPBSgetPBS () const
 Get PBS. More...
 
bool is_valid () const
 Check validity. More...
 
 ClassDefNV (JPBS, 1)
 

Static Public Attributes

static const char DOT = '.'
 Separator between PBS values. More...
 
static const char SEPARATOR = '/'
 Separator between PBS and variant. More...
 

Protected Attributes

std::string variant
 

Friends

bool operator== (const JUPI &first, const JUPI &second)
 Equality. More...
 
bool operator< (const JUPI &first, const JUPI &second)
 Less-than operator. More...
 
std::istream & operator>> (std::istream &in, JUPI &object)
 Read UPI from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JUPI &object)
 Write UPI to output stream. More...
 

Detailed Description

Universal product identifier (UPI).

The UPI consists of a PBS and a variant, seperated by JPBS::SEPARATOR.
The ASCII format should therefore read "<int>[.<int>]+/<variant>".
The variant cannot start with any kind of white space.

Definition at line 30 of file JUPI.hh.

Constructor & Destructor Documentation

JDATABASE::JUPI::JUPI ( )
inline

Default constructor.

Definition at line 36 of file JUPI.hh.

37  {}
JDATABASE::JUPI::JUPI ( const JPBS pbs,
const std::string &  variant = "" 
)
inline

Constructor.

Parameters
pbsPBS
variantvariant

Definition at line 46 of file JUPI.hh.

46  :
47  JPBS (pbs),
49  {}
std::string variant
Definition: JUPI.hh:170
JPBS()
Default constructor.
Definition: JPBS.hh:45
JDATABASE::JUPI::JUPI ( const std::string &  upi)
inline

Constructor.

Parameters
upiUPI

Definition at line 57 of file JUPI.hh.

58  {
59  std::istringstream(upi) >> *this;
60  }

Member Function Documentation

const JUPI& JDATABASE::JUPI::getUPI ( ) const
inline

Get UPI.

Returns
UPI

Definition at line 68 of file JUPI.hh.

69  {
70  return static_cast<const JUPI&>(*this);
71  }
Universal product identifier (UPI).
Definition: JUPI.hh:30
const std::string& JDATABASE::JUPI::getVariant ( ) const
inline

Get variant.

Returns
variant

Definition at line 79 of file JUPI.hh.

80  {
81  return variant;
82  }
std::string variant
Definition: JUPI.hh:170
JDATABASE::JUPI::ClassDefNV ( JUPI  ,
 
)
const JPBS& JDATABASE::JPBS::getPBS ( ) const
inlineinherited

Get PBS.

Returns
PBS

Definition at line 105 of file JPBS.hh.

106  {
107  return static_cast<const JPBS&>(*this);
108  }
Product breakdown structure (PBS).
Definition: JPBS.hh:27
bool JDATABASE::JPBS::is_valid ( ) const
inlineinherited

Check validity.

Returns
true if valid; else false

Definition at line 116 of file JPBS.hh.

117  {
118  return !this->empty();
119  }
JDATABASE::JPBS::ClassDefNV ( JPBS  ,
 
)
inherited

Friends And Related Function Documentation

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

Equality.

Parameters
firstfirst UPI
secondsecond UPI
Returns
true if UPIs are equals; else false

Definition at line 92 of file JUPI.hh.

93  {
94  return (first.getPBS() == second.getPBS() &&
95  first.getVariant() == second.getVariant());
96  }
const JPBS & getPBS() const
Get PBS.
Definition: JPBS.hh:105
const std::string & getVariant() const
Get variant.
Definition: JUPI.hh:79
bool operator< ( const JUPI first,
const JUPI second 
)
friend

Less-than operator.

Parameters
firstfirst UPI
secondsecond UPI
Returns
true if first UPI higher in hierarchy or lesser variant; else false

Definition at line 106 of file JUPI.hh.

107  {
108  if (first.getPBS() == second.getPBS())
109  return first.getVariant() < second.getVariant();
110  else
111  return first.getPBS() < second.getPBS();
112  }
const JPBS & getPBS() const
Get PBS.
Definition: JPBS.hh:105
const std::string & getVariant() const
Get variant.
Definition: JUPI.hh:79
std::istream& operator>> ( std::istream &  in,
JUPI object 
)
friend

Read UPI from input stream.

Parameters
ininput stream
objectUPI
Returns
input stream

Definition at line 122 of file JUPI.hh.

123  {
124  using namespace std;
125 
126  object.variant.clear();
127 
128  if (in >> static_cast<JPBS&>(object)) {
129 
130  if (in.get() == (int) JPBS::SEPARATOR) {
131 
132  const int c = in.peek();
133 
134  if (c != EOF && !isspace(c))
135  in >> object.variant;
136  else
137  in.setstate(ios::failbit);
138 
139  } else {
140 
141  in.setstate(ios::failbit);
142  }
143  }
144 
145  return in;
146  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
static const char SEPARATOR
Separator between PBS and variant.
Definition: JPBS.hh:39
std::ostream& operator<< ( std::ostream &  out,
const JUPI object 
)
friend

Write UPI to output stream.

Parameters
outoutput stream
objectUPI
Returns
output stream

Definition at line 156 of file JUPI.hh.

157  {
158  using namespace std;
159 
160  ostringstream os;
161 
162  os << object.getPBS() << JPBS::SEPARATOR << object.getVariant();
163 
164  return out << os.str();
165  }
static const char SEPARATOR
Separator between PBS and variant.
Definition: JPBS.hh:39

Member Data Documentation

std::string JDATABASE::JUPI::variant
protected

Definition at line 170 of file JUPI.hh.

const char JDATABASE::JPBS::DOT = '.'
staticinherited

Separator between PBS values.

Definition at line 33 of file JPBS.hh.

const char JDATABASE::JPBS::SEPARATOR = '/'
staticinherited

Separator between PBS and variant.

Definition at line 39 of file JPBS.hh.


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