Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JStatic.hh
Go to the documentation of this file.
1 #ifndef __JLANG_JSTATIC__
2 #define __JLANG_JSTATIC__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JLang/JClass.hh"
8 #include "JLang/JEquals.hh"
9 
10 
11 namespace JLANG {}
12 namespace JPP { using namespace JLANG; }
13 
14 namespace JLANG {
15 
16  /**
17  * Template data structure for static member declaration.
18  */
19  template<class T, class JParent_t = void, int N = 0>
20  struct JStatic :
21  public JEquals<JStatic<T, JParent_t, N>, T>
22  {
23 
25 
26 
27  /**
28  * Constructor.
29  *
30  * \param value value
31  */
33  {
34  this->value = value;
35  }
36 
37 
38  /**
39  * Assignment operator
40  *
41  * \param value value
42  * \return this value
43  */
45  {
46  this->value = value;
47 
48  return *this;
49  }
50 
51 
52  /**
53  * Type conversion operator.
54  *
55  * \return value
56  */
57  operator const T& () const
58  {
59  return value;
60  }
61 
62 
63  /**
64  * Type conversion operator.
65  *
66  * \return value
67  */
68  operator T& ()
69  {
70  return value;
71  }
72 
73 
74  /**
75  * Smart pointer.
76  *
77  * \return value
78  */
79  const T* operator->() const
80  {
81  return &value;
82  }
83 
84 
85  /**
86  * Smart pointer.
87  *
88  * \return value
89  */
91  {
92  return &value;
93  }
94 
95 
96  /**
97  * Equals method.
98  *
99  * \param object object
100  * \return true if this object equals given object; else false
101  */
102  bool equals(const JStatic& object) const
103  {
104  return this->value == object.value;
105  }
106 
107 
108  /**
109  * Equals method.
110  *
111  * \param value value
112  * \return true if this value equals given value; else false
113  */
115  {
116  return this->value == value;
117  }
118 
119 
120  /**
121  * Read static object from input stream.
122  *
123  * \param in input stream
124  * \param object object
125  * \return input stream
126  */
127  friend inline std::istream& operator>>(std::istream& in, JStatic& object)
128  {
129  return in >> object.value;
130  }
131 
132 
133  /**
134  * Write static object to output stream.
135  *
136  * \param out output stream
137  * \param object object
138  * \return output stream
139  */
140  friend inline std::ostream& operator<<(std::ostream& out, const JStatic& object)
141  {
142  return out << object.value;
143  }
144 
145  private:
146  static T value;
147  };
148 
149 
150  /**
151  * Declaration of static data member.
152  */
153  template<class T, class JParent_t, int N>
155 
156 
157  /**
158  * Template specialisation of JStatic for static member declaration of pointer.
159  */
160  template<class T, class JParent_t, int N>
161  struct JStatic<T*, JParent_t, N> :
163  {
164 
166 
167  /**
168  * Assignment operator
169  *
170  * \param value value
171  * \return this value
172  */
173  JStatic& operator=(argument_type value)
174  {
175  this->value = value;
176 
177  return *this;
178  }
179 
180 
181  /**
182  * Smart pointer.
183  *
184  * \return value
185  */
186  const T* operator->() const
187  {
188  return value;
189  }
190 
191 
192  /**
193  * Smart pointer.
194  *
195  * \return value
196  */
198  {
199  return value;
200  }
201 
202 
203  /**
204  * Equals method.
205  *
206  * \param object object
207  * \return true if this object equals given object; else false
208  */
209  bool equals(const JStatic& object) const
210  {
211  return this->value == object.value;
212  }
213 
214 
215  /**
216  * Equals method.
217  *
218  * \param value value
219  * \return true if this value equals given value; else false
220  */
221  bool equals(argument_type value) const
222  {
223  return this->value == value;
224  }
225 
226  private:
227  static T* value;
228  };
229 
230 
231  /**
232  * Declaration of static data member.
233  */
234  template<class T, class JParent_t, int N>
236 }
237 
238 #endif
JStatic(argument_type value)
Constructor.
Definition: JStatic.hh:32
const T * operator->() const
Smart pointer.
Definition: JStatic.hh:79
bool equals(const JStatic &object) const
Equals method.
Definition: JStatic.hh:209
const T * operator->() const
Smart pointer.
Definition: JStatic.hh:186
T * operator->()
Smart pointer.
Definition: JStatic.hh:90
static T value
Declaration of static data member.
Definition: JStatic.hh:146
JClass< T >::argument_type argument_type
Definition: JStatic.hh:24
JClass< T * >::argument_type argument_type
Definition: JStatic.hh:165
T * operator->()
Smart pointer.
Definition: JStatic.hh:197
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
Template data structure for static member declaration.
Definition: JStatic.hh:20
friend std::istream & operator>>(std::istream &in, JStatic &object)
Read static object from input stream.
Definition: JStatic.hh:127
bool equals(argument_type value) const
Equals method.
Definition: JStatic.hh:221
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Template definition of auxiliary base class for comparison of data structures.
Definition: JEquals.hh:24
bool equals(const JStatic &object) const
Equals method.
Definition: JStatic.hh:102
static T * value
Declaration of static data member.
Definition: JStatic.hh:227
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
JStatic & operator=(argument_type value)
Assignment operator.
Definition: JStatic.hh:44
JStatic & operator=(argument_type value)
Assignment operator.
Definition: JStatic.hh:173
friend std::ostream & operator<<(std::ostream &out, const JStatic &object)
Write static object to output stream.
Definition: JStatic.hh:140
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 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:46
bool equals(argument_type value) const
Equals method.
Definition: JStatic.hh:114