Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JVersion.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JVERSION__
2 #define __JDETECTOR__JVERSION__
3 
4 #include <istream>
5 #include <ostream>
6 #include <string>
7 
8 #include "JLang/JEquals.hh"
9 #include "JIO/JSerialisable.hh"
10 #include "JIO/JSTDIO.hh"
11 
12 
13 /**
14  * \author mdejong
15  */
16 
17 namespace JDETECTOR {}
18 namespace JPP { using namespace JDETECTOR; }
19 
20 namespace JDETECTOR {
21 
22  using JLANG::JEquals;
23  using JIO::JReader;
24  using JIO::JWriter;
25 
26 
27  /**
28  * Auxiliary class for version identifier.
29  */
30  struct JVersion :
31  public JEquals<JVersion>
32  {
33  /**
34  * Default constructor.
35  */
37  __variant()
38  {}
39 
40 
41  /**
42  * Constructor.
43  *
44  * \param variant variant
45  */
46  JVersion(const std::string& variant) :
47  __variant(variant)
48  {}
49 
50 
51  /**
52  * Get version.
53  *
54  * \return version
55  */
56  const JVersion& getVersion() const
57  {
58  return static_cast<const JVersion&>(*this);
59  }
60 
61 
62  /**
63  * Get version.
64  *
65  * \return version
66  */
68  {
69  return static_cast<JVersion&>(*this);
70  }
71 
72 
73  /**
74  * Set version.
75  *
76  * \param version version
77  */
79  {
80  static_cast<JVersion&>(*this) = version;
81  }
82 
83 
84  /**
85  * Get variant.
86  *
87  * \return variant
88  */
89  const std::string& getVariant() const
90  {
91  return this->__variant;
92  }
93 
94 
95  /**
96  * Set variant.
97  *
98  * \param variant variant
99  */
100  void setVariant(const std::string& variant)
101  {
102  this->__variant = variant;
103  }
104 
105 
106  /**
107  * Equal method.
108  *
109  * \param version version
110  * \result true if this version equal to given version; else false
111  */
112  inline bool equals(const JVersion& version) const
113  {
114  return this->getVariant() == version.getVariant();
115  }
116 
117 
118  /**
119  * Read version from input.
120  *
121  * \param in input stream
122  * \param version version
123  * \return input stream
124  */
125  friend inline std::istream& operator>>(std::istream& in, JVersion& version)
126  {
127  return in >> version.__variant;
128  }
129 
130 
131  /**
132  * Write version to output.
133  *
134  * \param out output stream
135  * \param version version
136  * \return output stream
137  */
138  friend inline std::ostream& operator<<(std::ostream& out, const JVersion& version)
139  {
140  return out << version.__variant;
141  }
142 
143 
144  /**
145  * Read version from input.
146  *
147  * \param in reader
148  * \param version version
149  * \return reader
150  */
152  {
153  return in >> version.__variant;
154  }
155 
156 
157  /**
158  * Write version to output.
159  *
160  * \param out writer
161  * \param version version
162  * \return writer
163  */
164  friend inline JWriter& operator<<(JWriter& out, const JVersion& version)
165  {
166  return out << version.__variant;
167  }
168 
169  protected:
170  std::string __variant;
171  };
172 
173 
174  /**
175  * Less-than operator for versions.
176  *
177  * \param first first version
178  * \param second second version
179  * \return true if first version before second; else false
180  */
181  bool inline operator<(const JVersion& first, const JVersion& second)
182  {
183  return first.getVariant() < second.getVariant();
184  }
185 }
186 
187 #endif
Interface for binary output.
JVersion()
Default constructor.
Definition: JVersion.hh:36
friend std::istream & operator>>(std::istream &in, JVersion &version)
Read version from input.
Definition: JVersion.hh:125
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1578
void setVersion(const JVersion &version)
Set version.
Definition: JVersion.hh:78
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
bool equals(const JVersion &version) const
Equal method.
Definition: JVersion.hh:112
JVersion & getVersion()
Get version.
Definition: JVersion.hh:67
std::string __variant
Definition: JVersion.hh:170
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
void setVariant(const std::string &variant)
Set variant.
Definition: JVersion.hh:100
Interface for binary input.
const std::string & getVariant() const
Get variant.
Definition: JVersion.hh:89
JVersion(const std::string &variant)
Constructor.
Definition: JVersion.hh:46
friend std::ostream & operator<<(std::ostream &out, const JVersion &version)
Write version to output.
Definition: JVersion.hh:138
friend JReader & operator>>(JReader &in, JVersion &version)
Read version from input.
Definition: JVersion.hh:151
Auxiliary class for version identifier.
Definition: JVersion.hh:30
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
version
Definition: JCalibratePMT.sh:7
friend JWriter & operator<<(JWriter &out, const JVersion &version)
Write version to output.
Definition: JVersion.hh:164
STD extensions for binary I/O.
const JVersion & getVersion() const
Get version.
Definition: JVersion.hh:56