Jpp  debug
the software that should make you happy
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
JACOUSTICS::JDetectorMechanics Struct Reference

Auxiliary data structure for mechanical model parameters of strings in a given detector. More...

#include <JMechanics.hh>

Inheritance diagram for JACOUSTICS::JDetectorMechanics:
std::map< int, JMechanics >

Public Types

enum  { WILDCARD = -1 }
 

Public Member Functions

void load (const std::string &file_name)
 Load mechanical model parameters from file. More...
 
void load (const int id)
 Load mechanical model parameters for given detector identifier. More...
 
const JMechanicsoperator() (const int string) const
 Get mechanical parameters for given string. More...
 

Static Public Member Functions

static std::string getFilename (const int id)
 Get file name with mechanical model parameters for given detector identifier. More...
 

Public Attributes

JComment comment
 

Friends

std::istream & operator>> (std::istream &in, JDetectorMechanics &object)
 Read detector mechanics from input. More...
 
std::ostream & operator<< (std::ostream &out, const JDetectorMechanics &object)
 Write detector mechanics to output. More...
 

Detailed Description

Auxiliary data structure for mechanical model parameters of strings in a given detector.

Note that the JDetectorMechanics::WILDCARD acts as default value for the string number.

Definition at line 112 of file JMechanics.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
WILDCARD 

wild card for string number.

Definition at line 115 of file JMechanics.hh.

115  {
116  WILDCARD = -1 //!< wild card for string number.
117  };
@ WILDCARD
wild card for string number.
Definition: JMechanics.hh:116

Member Function Documentation

◆ getFilename()

static std::string JACOUSTICS::JDetectorMechanics::getFilename ( const int  id)
inlinestatic

Get file name with mechanical model parameters for given detector identifier.

Parameters
iddetector identifier
Returns
file name

Definition at line 126 of file JMechanics.hh.

127  {
128  return MAKE_STRING("mechanics_" << FILL(8,'0') << id << ".txt");
129  }
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:330

◆ load() [1/2]

void JACOUSTICS::JDetectorMechanics::load ( const std::string &  file_name)
inline

Load mechanical model parameters from file.

Parameters
file_namefile name

Definition at line 137 of file JMechanics.hh.

138  {
139  std::ifstream in(file_name.c_str());
140 
141  if (!in) {
142  THROW(JFileOpenException, "File not opened for reading: " << file_name);
143  }
144 
145  in >> *this;
146 
147  in.close();
148  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for opening of file.
Definition: JException.hh:360

◆ load() [2/2]

void JACOUSTICS::JDetectorMechanics::load ( const int  id)
inline

Load mechanical model parameters for given detector identifier.

Parameters
iddetector identifier

Definition at line 156 of file JMechanics.hh.

157  {
158  load(getFilename(id));
159  }
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:137
static std::string getFilename(const int id)
Get file name with mechanical model parameters for given detector identifier.
Definition: JMechanics.hh:126

◆ operator()()

const JMechanics& JACOUSTICS::JDetectorMechanics::operator() ( const int  string) const
inline

Get mechanical parameters for given string.

Parameters
stringstring number
Returns
mechanical parameters

Definition at line 168 of file JMechanics.hh.

169  {
170  static const JMechanics mechanics;
171 
172  const_iterator p;
173 
174  if ((p = this->find(string)) != this->end())
175  return p->second;
176  else if ((p = this->find(WILDCARD)) != this->end())
177  return p->second;
178  else
179  return mechanics;
180  }
Auxiliary data structure for parameters of mechanical model.
Definition: JMechanics.hh:41

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JDetectorMechanics object 
)
friend

Read detector mechanics from input.

Parameters
ininput stream
objectdetector mechanics
Returns
input stream

Definition at line 190 of file JMechanics.hh.

191  {
192  using namespace JPP;
193 
194  JStringStream is(in);
195 
196  if (getFileStatus(is.str().c_str())) {
197  is.load();
198  }
199 
200  object.clear();
201 
202  is >> object.comment;
203 
204  int string;
205  JMechanics mechanics;
206 
207  while (is >> string >> mechanics) {
208  object[string] = mechanics;
209  }
210 
211  return in;
212  }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JDetectorMechanics object 
)
friend

Write detector mechanics to output.

Parameters
outoutput stream
objectdetector mechanics
Returns
output stream

Definition at line 222 of file JMechanics.hh.

223  {
224  using namespace std;
225 
226  out << object.comment;
227 
228  for (JDetectorMechanics::const_iterator i = object.begin(); i != object.end(); ++i) {
229  out << setw(4) << i->first << ' ' << i->second << endl;
230  }
231 
232  return out;
233  }
Definition: JSTDTypes.hh:14

Member Data Documentation

◆ comment

JComment JACOUSTICS::JDetectorMechanics::comment

Definition at line 235 of file JMechanics.hh.


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