Jpp  master_rocky
the software that should make you happy
Public Member Functions | Protected Attributes | Friends | List of all members
JDETECTOR::JLocation Class Reference

Logical location of module. More...

#include <JLocation.hh>

Inheritance diagram for JDETECTOR::JLocation:
JLANG::JComparable< JFirst_t, JSecond_t > JACOUSTICS::JGEOMETRY::JDetector::module_type JACOUSTICS::JHit JDETECTOR::JHydrophone JDETECTOR::JModule JDETECTOR::JPMTChannel JDETECTOR::JTransmitter JCALIBRATE::JModel JMONITOR::JClusterBuilder

Public Member Functions

 JLocation ()
 Default constructor. More...
 
 JLocation (const int string, const int floor)
 Constructor. More...
 
const JLocationgetLocation () const
 Get location. More...
 
JLocationgetLocation ()
 Get location. More...
 
void setLocation (const JLocation &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 JLocation &location) const
 Less than method. More...
 

Protected Attributes

int string
 
int floor
 

Friends

std::istream & operator>> (std::istream &in, JLocation &location)
 Read module location from input. More...
 
std::ostream & operator<< (std::ostream &out, const JLocation &location)
 Write module location to output. More...
 
JReaderoperator>> (JReader &in, JLocation &location)
 Read module location from input. More...
 
JWriteroperator<< (JWriter &out, const JLocation &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 38 of file JLocation.hh.

Constructor & Destructor Documentation

◆ JLocation() [1/2]

JDETECTOR::JLocation::JLocation ( )
inline

Default constructor.

Definition at line 45 of file JLocation.hh.

45  :
46  string(-1),
47  floor (-1)
48  {}

◆ JLocation() [2/2]

JDETECTOR::JLocation::JLocation ( const int  string,
const int  floor 
)
inline

Constructor.

Parameters
stringstring
floorfloor

Definition at line 57 of file JLocation.hh.

59  {
60  this->string = string;
61  this->floor = floor;
62  }

Member Function Documentation

◆ getLocation() [1/2]

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

Get location.

Returns
location

Definition at line 70 of file JLocation.hh.

71  {
72  return static_cast<const JLocation&>(*this);
73  }
Logical location of module.
Definition: JLocation.hh:40

◆ getLocation() [2/2]

JLocation& JDETECTOR::JLocation::getLocation ( )
inline

Get location.

Returns
location

Definition at line 81 of file JLocation.hh.

82  {
83  return static_cast<JLocation&>(*this);
84  }

◆ setLocation()

void JDETECTOR::JLocation::setLocation ( const JLocation location)
inline

Set location.

Parameters
locationlocation

Definition at line 92 of file JLocation.hh.

93  {
94  static_cast<JLocation&>(*this) = location;
95  }

◆ toString() [1/2]

std::string JDETECTOR::JLocation::toString ( ) const
inline

Convert module location to string.

Returns
string

Definition at line 103 of file JLocation.hh.

104  {
105  return toString("% %");
106  }
std::string toString() const
Convert module location to string.
Definition: JLocation.hh:103

◆ toString() [2/2]

std::string JDETECTOR::JLocation::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 119 of file JLocation.hh.

120  {
121  JLANG::JString buffer(fmt);
122 
123  buffer.replace(target, string, 1);
124  buffer.replace(target, floor, 1);
125 
126  return buffer;
127  }
Wrapper class around STL string class.
Definition: JString.hh:29
Target.
Definition: JHead.hh:300

◆ getString()

int JDETECTOR::JLocation::getString ( ) const
inline

Get string number.

Returns
string number

Definition at line 135 of file JLocation.hh.

136  {
137  return string;
138  }

◆ getFloor()

int JDETECTOR::JLocation::getFloor ( ) const
inline

Get floor number.

Returns
floor number

Definition at line 146 of file JLocation.hh.

147  {
148  return floor;
149  }

◆ less()

bool JDETECTOR::JLocation::less ( const JLocation location) const
inline

Less than method.

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

Definition at line 158 of file JLocation.hh.

159  {
160  if (this->getString() == location.getString())
161  return this->getFloor() < location.getFloor();
162  else
163  return this->getString() < location.getString();
164  }
int getFloor() const
Get floor number.
Definition: JLocation.hh:146
int getString() const
Get string number.
Definition: JLocation.hh:135

Friends And Related Function Documentation

◆ operator>> [1/2]

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

Read module location from input.

Parameters
ininput stream
locationmodule location
Returns
input stream

Definition at line 174 of file JLocation.hh.

175  {
176  in >> location.string;
177  in >> location.floor;
178 
179  return in;
180  }

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  out,
const JLocation location 
)
friend

Write module location to output.

Parameters
outoutput stream
locationmodule location
Returns
output stream

Definition at line 190 of file JLocation.hh.

191  {
192  using namespace std;
193 
194  out << setw(4) << location.string;
195  out << ' ';
196  out << setw(2) << location.floor;
197 
198  return out;
199  }
Definition: JSTDTypes.hh:14

◆ operator>> [2/2]

JReader& operator>> ( JReader in,
JLocation location 
)
friend

Read module location from input.

Parameters
inreader
locationmodule location
Returns
reader

Definition at line 209 of file JLocation.hh.

210  {
211  in >> location.string;
212  in >> location.floor;
213 
214  return in;
215  }

◆ operator<< [2/2]

JWriter& operator<< ( JWriter out,
const JLocation location 
)
friend

Write module location to output.

Parameters
outwriter
locationmodule location
Returns
writer

Definition at line 225 of file JLocation.hh.

226  {
227  out << location.string;
228  out << location.floor;
229 
230  return out;
231  }

Member Data Documentation

◆ string

int JDETECTOR::JLocation::string
protected

Definition at line 235 of file JLocation.hh.

◆ floor

int JDETECTOR::JLocation::floor
protected

Definition at line 236 of file JLocation.hh.


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