Jpp  16.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JObjectID.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JOBJECTID__
2 #define __JLANG__JOBJECTID__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JLang/JComparable.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JLANG {}
15 namespace JPP { using namespace JLANG; }
16 
17 namespace JLANG {
18 
19  /**
20  * Auxiliary class for object identification.
21  */
22  class JObjectID :
23  public JComparable<JObjectID>,
24  public JComparable<JObjectID, int>
25  {
26  public:
27  /**
28  * Default constructor.
29  */
31  __id(-1)
32  {}
33 
34 
35  /**
36  * Constructor.
37  *
38  * \param id identifier
39  */
40  JObjectID(const int id) :
41  __id(id)
42  {}
43 
44 
45  /**
46  * Get identifier.
47  *
48  * \return identifier
49  */
50  int getID() const
51  {
52  return __id;
53  }
54 
55 
56  /**
57  * Get identifier.
58  *
59  * \return identifier
60  */
61  int& getID()
62  {
63  return __id;
64  }
65 
66 
67  /**
68  * Set identifier.
69  *
70  * \param id identifier
71  */
72  void setID(const int id)
73  {
74  this->__id = id;
75  }
76 
77 
78  /**
79  * Less than method.
80  *
81  * \param object object identifier
82  * \return true if this identifier less than given identifier; else false
83  */
84  inline bool less(const JObjectID& object) const
85  {
86  return this->getID() < object.getID();
87  }
88 
89 
90  /**
91  * Less than method.
92  *
93  * \param id identifier
94  * \return true if this identifier less than given identifier; else false
95  */
96  inline bool less(const int id) const
97  {
98  return this->getID() < id;
99  }
100 
101 
102  /**
103  * More than method.
104  *
105  * \param id identifier
106  * \return true if this identifier greater than given identifier; else false
107  */
108  inline bool more(const int id) const
109  {
110  return this->getID() > id;
111  }
112 
113 
114  /**
115  * Read object identifier from input.
116  *
117  * \param in input stream
118  * \param object object identifier
119  * \return input stream
120  */
121  friend inline std::istream& operator>>(std::istream& in, JObjectID& object)
122  {
123  return in >> object.__id;
124  }
125 
126 
127  /**
128  * Write object identifier to output.
129  *
130  * \param out output stream
131  * \param object object identifier
132  * \return output stream
133  */
134  friend inline std::ostream& operator<<(std::ostream& out, const JObjectID& object)
135  {
136  return out << object.__id;
137  }
138 
139  protected:
140  int __id;
141  };
142 
143 
144  /**
145  * Get undefined object identifier.
146  *
147  * \return undefined object identifier
148  */
150  {
151  static JObjectID id;
152 
153  return id;
154  }
155 }
156 
157 #endif
JObjectID(const int id)
Constructor.
Definition: JObjectID.hh:40
JObjectID()
Default constructor.
Definition: JObjectID.hh:30
int getID() const
Get identifier.
Definition: JObjectID.hh:50
bool more(const int id) const
More than method.
Definition: JObjectID.hh:108
bool less(const JObjectID &object) const
Less than method.
Definition: JObjectID.hh:84
int & getID()
Get identifier.
Definition: JObjectID.hh:61
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:24
friend std::istream & operator>>(std::istream &in, JObjectID &object)
Read object identifier from input.
Definition: JObjectID.hh:121
Auxiliary class for object identification.
Definition: JObjectID.hh:22
void setID(const int id)
Set identifier.
Definition: JObjectID.hh:72
const JObjectID & getUndefinedObjectID()
Get undefined object identifier.
Definition: JObjectID.hh:149
friend std::ostream & operator<<(std::ostream &out, const JObjectID &object)
Write object identifier to output.
Definition: JObjectID.hh:134
bool less(const int id) const
Less than method.
Definition: JObjectID.hh:96
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42