Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
JDETECTOR::JGetDetectorVersion Struct Reference

Auxiliary class to map detector version to numerical value. More...

#include <JDetectorVersion.hh>

Inheritance diagram for JDETECTOR::JGetDetectorVersion:
std::map< std::string, JDetectorVersion::JVersion_t >

Public Member Functions

 JGetDetectorVersion ()
 Default constructor. More...
 
JDetectorVersion::JVersion_t operator() (const std::string &version) const
 Get numerical value. More...
 
JDetectorVersion::JVersion_t operator() (const JDetectorVersion &version) const
 Get numerical value. More...
 
int operator[] (const std::string &version) const
 Get index of detector version. More...
 
int operator[] (const JDetectorVersion &version) const
 Get index of detector version. More...
 
int operator[] (const JDetectorVersion::JVersion_t &value) const
 Get index of detector version. More...
 

Detailed Description

Auxiliary class to map detector version to numerical value.

Definition at line 131 of file JDetectorVersion.hh.

Constructor & Destructor Documentation

JDETECTOR::JGetDetectorVersion::JGetDetectorVersion ( )
inline

Default constructor.

Definition at line 137 of file JDetectorVersion.hh.

138  {
139  using namespace JPP;
140 
141 #define MAKE_ENTRY(A) std::make_pair(to_upper(getClassname(#A)), A)
142 
143  this->insert(MAKE_ENTRY(JDetectorVersion::V1));
144  this->insert(MAKE_ENTRY(JDetectorVersion::V2));
145  this->insert(MAKE_ENTRY(JDetectorVersion::V3));
146  this->insert(MAKE_ENTRY(JDetectorVersion::V4));
147  this->insert(MAKE_ENTRY(JDetectorVersion::V5));
148 
149 #undef MAKE_ENTRY
150  }
Version with UTC time and UTM position data.
Version with PMT status field and comments.
Version with quaternion and time offset per module.
#define MAKE_ENTRY(A)
Version with module status field.

Member Function Documentation

JDetectorVersion::JVersion_t JDETECTOR::JGetDetectorVersion::operator() ( const std::string version) const
inline

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 159 of file JDetectorVersion.hh.

160  {
161  using namespace JPP;
162 
163  const_iterator i = this->find(to_upper(version));
164 
165  if (i != this->end()) {
166  return i->second;
167  } else {
168  THROW(JTypeInformationException, "Invalid version <" << version << ">");
169  }
170  }
version
Definition: JEditTuneHV.sh:5
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
std::string to_upper(const std::string &value)
Convert all character to upper case.
JDetectorVersion::JVersion_t JDETECTOR::JGetDetectorVersion::operator() ( const JDetectorVersion version) const
inline

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 179 of file JDetectorVersion.hh.

180  {
181  return (*this)(version.getVersion());
182  }
const std::string & getVersion() const
Get version.
int JDETECTOR::JGetDetectorVersion::operator[] ( const std::string version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 191 of file JDetectorVersion.hh.

192  {
193  using namespace std;
194  using namespace JPP;
195 
196  const_iterator i = this->find(to_upper(version));
197 
198  if (i != this->end())
199  return distance(this->begin(), i);
200  else
201  return -1;
202  }
version
Definition: JEditTuneHV.sh:5
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
std::string to_upper(const std::string &value)
Convert all character to upper case.
int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 211 of file JDetectorVersion.hh.

212  {
213  return (*this)[version.getVersion()];
214  }
const std::string & getVersion() const
Get version.
int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion::JVersion_t value) const
inline

Get index of detector version.

Parameters
valuenumerical value
Returns
index

Definition at line 223 of file JDetectorVersion.hh.

224  {
225  using namespace std;
226 
227  for (const_iterator i = this->begin(); i != this->end(); ++i) {
228  if (i->second == value) {
229  return distance(this->begin(), i);
230  }
231  }
232 
233  return -1;
234  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.

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