Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
JDetectorVersion::JVersion_t operator() (const std::string &version) const
 Get numerical value.
 
JDetectorVersion::JVersion_t operator() (const JDetectorVersion &version) const
 Get numerical value.
 
int operator[] (const std::string &version) const
 Get index of detector version.
 
int operator[] (const JDetectorVersion &version) const
 Get index of detector version.
 
int operator[] (const JDetectorVersion::JVersion_t &value) const
 Get index of detector version.
 

Detailed Description

Auxiliary class to map detector version to numerical value.

Definition at line 142 of file JDetectorVersion.hh.

Constructor & Destructor Documentation

◆ JGetDetectorVersion()

JDETECTOR::JGetDetectorVersion::JGetDetectorVersion ( )
inline

Default constructor.

Definition at line 148 of file JDetectorVersion.hh.

149 {
150 using namespace JPP;
151
152#define MAKE_ENTRY(A) std::make_pair(to_upper(getClassname(#A)), A)
153
154 this->insert(MAKE_ENTRY(JDetectorVersion::V1));
155 this->insert(MAKE_ENTRY(JDetectorVersion::V2));
156 this->insert(MAKE_ENTRY(JDetectorVersion::V3));
157 this->insert(MAKE_ENTRY(JDetectorVersion::V4));
158 this->insert(MAKE_ENTRY(JDetectorVersion::V5));
159
160#undef MAKE_ENTRY
161 }
#define MAKE_ENTRY(A)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
@ V2
Version with UTC time and UTM position data.
@ V5
Version with module status field.
@ V4
Version with quaternion and time offset per module.
@ V3
Version with PMT status field and comments.

Member Function Documentation

◆ operator()() [1/2]

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

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 170 of file JDetectorVersion.hh.

171 {
172 using namespace JPP;
173
174 const_iterator i = this->find(to_upper(version));
175
176 if (i != this->end()) {
177 return i->second;
178 } else {
179 THROW(JTypeInformationException, "Invalid version <" << version << ">");
180 }
181 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for absence of type information.
std::string to_upper(const std::string &value)
Convert all character to upper case.

◆ operator()() [2/2]

JDetectorVersion::JVersion_t JDETECTOR::JGetDetectorVersion::operator() ( const JDetectorVersion & version) const
inline

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 190 of file JDetectorVersion.hh.

191 {
192 return (*this)(version.getVersion());
193 }

◆ operator[]() [1/3]

int JDETECTOR::JGetDetectorVersion::operator[] ( const std::string & version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 202 of file JDetectorVersion.hh.

203 {
204 using namespace std;
205 using namespace JPP;
206
207 const_iterator i = this->find(to_upper(version));
208
209 if (i != this->end())
210 return distance(this->begin(), i);
211 else
212 return -1;
213 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.

◆ operator[]() [2/3]

int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion & version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 222 of file JDetectorVersion.hh.

223 {
224 return (*this)[version.getVersion()];
225 }

◆ operator[]() [3/3]

int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion::JVersion_t & value) const
inline

Get index of detector version.

Parameters
valuenumerical value
Returns
index

Definition at line 234 of file JDetectorVersion.hh.

235 {
236 using namespace std;
237
238 for (const_iterator i = this->begin(); i != this->end(); ++i) {
239 if (i->second == value) {
240 return distance(this->begin(), i);
241 }
242 }
243
244 return -1;
245 }

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