Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPMTPhysicalAddress.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTPHYSICALADDRESS__
2 #define __JDETECTOR__JPMTPHYSICALADDRESS__
3 
4 #include <istream>
5 #include <ostream>
6 #include <sstream>
7 
8 #include "JLang/JComparable.hh"
9 #include "JIO/JSerialisable.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JDETECTOR {}
17 namespace JPP { using namespace JDETECTOR; }
18 
19 namespace JDETECTOR {
20 
21  using JLANG::JComparable;
22  using JIO::JReader;
23  using JIO::JWriter;
24 
25 
26  /**
27  * Data structure for PMT physical address.
28  */
30  public JComparable<JPMTPhysicalAddress>
31  {
32  public:
33  /**
34  * Default constructor.
35  */
37  {
38  this->ring = '\0';
39  this->position = -1;
40  }
41 
42 
43  /**
44  * Constructor.
45  *
46  * \param ring ring
47  * \param position position
48  */
50  const int position)
51  {
52  this->ring = ring;
53  this->position = position;
54  }
55 
56 
57  /**
58  * Less than method.
59  *
60  * \param address PMT physical address
61  * \result true if this address before given address; else false
62  */
63  inline bool less(const JPMTPhysicalAddress& address) const
64  {
65  if (this->ring == address.ring)
66  return this->position < address.position;
67  else
68  return this->ring < address.ring;
69  }
70 
71 
72  /**
73  * Read PMT physical address from input.
74  *
75  * \param in input stream
76  * \param object PMT physical address
77  * \return input stream
78  */
79  friend inline std::istream& operator>>(std::istream& in, JPMTPhysicalAddress& object)
80  {
81  in >> object.ring;
82  in >> object.position;
83 
84  return in;
85  }
86 
87 
88  /**
89  * Write PMT physical address to output.
90  *
91  * \param out output stream
92  * \param object PMT physical address
93  * \return output stream
94  */
95  friend inline std::ostream& operator<<(std::ostream& out, const JPMTPhysicalAddress& object)
96  {
97  out << object.ring;
98  out << object.position;
99 
100  return out;
101  }
102 
103 
104  /**
105  * Read PMT physical address from input.
106  *
107  * \param in reader
108  * \param object PMT physical address
109  * \return reader
110  */
111  friend inline JReader& operator>>(JReader& in, JPMTPhysicalAddress& object)
112  {
113  in >> object.ring;
114  in >> object.position;
115 
116  return in;
117  }
118 
119 
120  /**
121  * Write PMT physical address to output.
122  *
123  * \param out writer
124  * \param object PMT physical address
125  * \return writer
126  */
127  friend inline JWriter& operator<<(JWriter& out, const JPMTPhysicalAddress& object)
128  {
129  out << object.ring;
130  out << object.position;
131 
132  return out;
133  }
134 
135 
136  /**
137  * Convert PMT physical address to string.
138  *
139  * \return string
140  */
141  std::string toString() const
142  {
143  std::ostringstream os;
144 
145  os << *this;
146 
147  return os.str();
148  }
149 
150 
151  char ring; //!< ring number ['A','F']
152  int position; //!< position within ring [1,6]
153  };
154 }
155 
156 #endif
Interface for binary output.
JPMTPhysicalAddress(const char ring, const int position)
Constructor.
friend std::ostream & operator<<(std::ostream &out, const JPMTPhysicalAddress &object)
Write PMT physical address to output.
friend JReader & operator>>(JReader &in, JPMTPhysicalAddress &object)
Read PMT physical address from input.
friend std::istream & operator>>(std::istream &in, JPMTPhysicalAddress &object)
Read PMT physical address from input.
char ring
ring number [&#39;A&#39;,&#39;F&#39;]
Interface for binary input.
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:24
friend JWriter & operator<<(JWriter &out, const JPMTPhysicalAddress &object)
Write PMT physical address to output.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
std::string toString() const
Convert PMT physical address to string.
int position
position within ring [1,6]
JPMTPhysicalAddress()
Default constructor.
Data structure for PMT physical address.
bool less(const JPMTPhysicalAddress &address) const
Less than method.