Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JLocation_t.hh
Go to the documentation of this file.
1#ifndef __JDB__JLOCATION_T_
2#define __JDB__JLOCATION_T_
3
4#include <ostream>
5
7#include "JLang/JManip.hh"
8
9
10/**
11 * \author mdejong
12 */
13namespace JDATABASE {}
14namespace JPP { using namespace JDATABASE; }
15
16namespace JDATABASE {
17
19
20
21 /**
22 * Auxiliary data structure for location of product in detector.
23 */
24 struct JLocation_t :
25 public JComparable<JLocation_t>
26 {
27 /**
28 * Default constructor.\n
29 * The default corresponds to an invalid location.
30 */
32 string (-1),
33 floor (-1),
34 position(-1)
35 {}
36
37
38 /**
39 * Constructor.
40 *
41 * \param string string
42 * \param floor floor
43 * \param position position
44 */
45 JLocation_t(const int string,
46 const int floor,
47 const int position) :
48 string (string),
49 floor (floor),
51 {}
52
53
54 /**
55 * Check validity of location.
56 *
57 * \return true if valid; else false
58 */
59 bool is_valid() const
60 {
61 return *this != JLocation_t();
62 }
63
64
65 /**
66 * Less-than method.
67 *
68 * \param location location
69 * \return true if this location less than given location; else false
70 */
71 bool less(const JLocation_t& location) const
72 {
73 if (this->string == location.string) {
74
75 if (this->floor == location.floor)
76 return this->position < location.position;
77 else
78 return this->floor < location.floor;
79
80 } else {
81
82 return this->string < location.string;
83 }
84 }
85
86
87 /**
88 * Write location to output stream.
89 *
90 * \param out output stream
91 * \param object location
92 * \return output stream
93 */
94 friend inline std::ostream& operator<<(std::ostream& out, const JLocation_t& object)
95 {
96 using namespace std;
97 using namespace JPP;
98
99 return out << FILL(4,'0') << object.string << '.'
100 << FILL(2,'0') << object.floor << '.'
101 << FILL(2,'0') << object.position << FILL();
102 }
103
104
105 int string; //!< position in detector
106 int floor; //!< position in string
107 int position; //!< position in floor
108 };
109}
110
111#endif
I/O manipulators.
Auxiliary classes and methods for database I/O.
Definition JAHRS.hh:14
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Auxiliary data structure for location of product in detector.
JLocation_t()
Default constructor.
int string
position in detector
JLocation_t(const int string, const int floor, const int position)
Constructor.
bool is_valid() const
Check validity of location.
friend std::ostream & operator<<(std::ostream &out, const JLocation_t &object)
Write location to output stream.
int floor
position in string
int position
position in floor
bool less(const JLocation_t &location) const
Less-than method.
Template definition of auxiliary base class for comparison of data structures.