Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JDETECTOR::JModuleLocation Class Reference

Logical location of module. More...

#include <JModuleLocation.hh>

Inheritance diagram for JDETECTOR::JModuleLocation:
JLANG::JComparable< JFirst_t, JSecond_t > JDETECTOR::JModule JDETECTOR::JPMTChannel JCALIBRATE::JFitK40 JMONITOR::JClusterBuilder

Public Member Functions

 JModuleLocation ()
 Default constructor. More...
 
 JModuleLocation (const int string, const int floor)
 Constructor. More...
 
const JModuleLocationgetLocation () const
 Get location. More...
 
JModuleLocationgetLocation ()
 Get location. More...
 
void setLocation (const JModuleLocation &location)
 Set location. More...
 
std::string toString () const
 Convert module location to string. More...
 
std::string toString (const std::string &fmt, const std::string target="%") const
 Convert module loation to string. More...
 
int getString () const
 Get string number. More...
 
int getFloor () const
 Get floor number. More...
 
bool less (const JModuleLocation &location) const
 Less than method. More...
 

Protected Attributes

int string
 
int floor
 

Friends

std::istream & operator>> (std::istream &in, JModuleLocation &location)
 Read module location from input. More...
 
std::ostream & operator<< (std::ostream &out, const JModuleLocation &location)
 Write module location to output. More...
 
JReaderoperator>> (JReader &in, JModuleLocation &location)
 Read module location from input. More...
 
JWriteroperator<< (JWriter &out, const JModuleLocation &location)
 Write module location to output. More...
 

Detailed Description

Logical location of module.

The logical location of a module consists of a string and floor number. This class implements the JLANG::JComparable interface.

Definition at line 36 of file JModuleLocation.hh.

Constructor & Destructor Documentation

JDETECTOR::JModuleLocation::JModuleLocation ( )
inline

Default constructor.

Definition at line 43 of file JModuleLocation.hh.

43  :
44  string(-1),
45  floor (-1)
46  {}
JDETECTOR::JModuleLocation::JModuleLocation ( const int  string,
const int  floor 
)
inline

Constructor.

Parameters
stringstring
floorfloor

Definition at line 55 of file JModuleLocation.hh.

57  {
58  this->string = string;
59  this->floor = floor;
60  }

Member Function Documentation

const JModuleLocation& JDETECTOR::JModuleLocation::getLocation ( ) const
inline

Get location.

Returns
location

Definition at line 68 of file JModuleLocation.hh.

69  {
70  return static_cast<const JModuleLocation&>(*this);
71  }
Logical location of module.
JModuleLocation& JDETECTOR::JModuleLocation::getLocation ( )
inline

Get location.

Returns
location

Definition at line 79 of file JModuleLocation.hh.

80  {
81  return static_cast<JModuleLocation&>(*this);
82  }
Logical location of module.
void JDETECTOR::JModuleLocation::setLocation ( const JModuleLocation location)
inline

Set location.

Parameters
locationlocation

Definition at line 90 of file JModuleLocation.hh.

91  {
92  static_cast<JModuleLocation&>(*this) = location;
93  }
Logical location of module.
std::string JDETECTOR::JModuleLocation::toString ( ) const
inline

Convert module location to string.

Returns
string

Definition at line 101 of file JModuleLocation.hh.

102  {
103  return toString("% %");
104  }
std::string toString() const
Convert module location to string.
std::string JDETECTOR::JModuleLocation::toString ( const std::string &  fmt,
const std::string  target = "%" 
) const
inline

Convert module loation to string.

The targets target in the format string fmt are consecutively replaced by floor and string.

Parameters
fmtformat
targettarget
Returns
string

Definition at line 117 of file JModuleLocation.hh.

118  {
119  JLANG::JString buffer(fmt);
120 
121  buffer.replace(target, string, 1);
122  buffer.replace(target, floor, 1);
123 
124  return buffer;
125  }
Wrapper class around STL string class.
Definition: JString.hh:28
int JDETECTOR::JModuleLocation::getString ( ) const
inline

Get string number.

Returns
string number

Definition at line 133 of file JModuleLocation.hh.

134  {
135  return string;
136  }
int JDETECTOR::JModuleLocation::getFloor ( ) const
inline

Get floor number.

Returns
floor number

Definition at line 144 of file JModuleLocation.hh.

145  {
146  return floor;
147  }
bool JDETECTOR::JModuleLocation::less ( const JModuleLocation location) const
inline

Less than method.

Parameters
locationmodule location
Returns
true if first location before second location; else false

Definition at line 156 of file JModuleLocation.hh.

157  {
158  if (this->getString() == location.getString())
159  return this->getFloor() < location.getFloor();
160  else
161  return this->getString() < location.getString();
162  }
int getFloor() const
Get floor number.
int getString() const
Get string number.

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JModuleLocation location 
)
friend

Read module location from input.

Parameters
ininput stream
locationmodule location
Returns
input stream

Definition at line 172 of file JModuleLocation.hh.

173  {
174  in >> location.string;
175  in >> location.floor;
176 
177  return in;
178  }
std::ostream& operator<< ( std::ostream &  out,
const JModuleLocation location 
)
friend

Write module location to output.

Parameters
outoutput stream
locationmodule location
Returns
output stream

Definition at line 188 of file JModuleLocation.hh.

189  {
190  using namespace std;
191 
192  out << setw(3) << location.string;
193  out << ' ';
194  out << setw(2) << location.floor;
195 
196  return out;
197  }
JReader& operator>> ( JReader in,
JModuleLocation location 
)
friend

Read module location from input.

Parameters
inreader
locationmodule location
Returns
reader

Definition at line 207 of file JModuleLocation.hh.

208  {
209  in >> location.string;
210  in >> location.floor;
211 
212  return in;
213  }
JWriter& operator<< ( JWriter out,
const JModuleLocation location 
)
friend

Write module location to output.

Parameters
outwriter
locationmodule location
Returns
writer

Definition at line 223 of file JModuleLocation.hh.

224  {
225  out << location.string;
226  out << location.floor;
227 
228  return out;
229  }

Member Data Documentation

int JDETECTOR::JModuleLocation::string
protected

Definition at line 233 of file JModuleLocation.hh.

int JDETECTOR::JModuleLocation::floor
protected

Definition at line 234 of file JModuleLocation.hh.


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