Jpp  15.0.1-rc.1-highqe
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JObjectOutput.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JOBJECTOUTPUT__
2 #define __JLANG__JOBJECTOUTPUT__
3 
4 #include "JLang/JTypeList.hh"
5 #include "JLang/JNullType.hh"
7 #include "JLang/JAccessible.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  * Template interface of object output for single data type.
21  */
22  template<class T>
23  class JObjectOutput {
24  protected:
25  /**
26  * Default constructor.
27  */
29  {}
30 
31 
32  public:
33  /**
34  * Virtual destructor.
35  */
36  virtual ~JObjectOutput()
37  {}
38 
39 
40  /**
41  * Object output.
42  *
43  * \param object object
44  * \return true if OK; else false
45  */
46  virtual bool put(const T& object) = 0;
47 
48 
49  /**
50  * Copy from object iterator.
51  *
52  * \param out object output
53  * \param in object iterator
54  * \return object output
55  */
56  friend inline JObjectOutput<T>& operator<<(JObjectOutput <T>& out,
58  {
59  while (in.hasNext()) {
60 
61  const T* p = in.next();
62 
63  if (p != NULL)
64  out.put(*p);
65  else
66  break;
67  }
68 
69  return out;
70  }
71  };
72 
73 
74  /**
75  * Implementation of object output for multiple data types.
76  *
77  * This class recursively defines the JObjectOutput interface
78  * for all data types by deriving from:
79  * - JObjectOutput<JHead_t>; and
80  * - JObjectOutput<JTail_t>.
81  */
82  template<class JHead_t, class JTail_t>
83  class JObjectOutput< JTypeList<JHead_t, JTail_t> > :
84  public virtual JObjectOutput<JHead_t>,
85  public virtual JObjectOutput<JTail_t>
86  {
87  public:
88 
90 
93 
94 
95  /**
96  * Copy from object iterator.
97  *
98  * Note that all data types of the output are copied from the input.
99  *
100  * \param out object output
101  * \param in object iterator
102  * \return object output
103  */
104  template<class JInputIterator_t>
105  friend inline JObjectOutput& operator<<(JObjectOutput<typelist>& out, JInputIterator_t& in)
106  {
107  static_cast<JObjectOutput<JHead_t>&>(out) << static_cast<JObjectIterator<JHead_t>&>(in);
108  static_cast<JObjectOutput<JTail_t>&>(out) << in;
109 
110  return out;
111  }
112  };
113 
114 
115  /**
116  * Terminator class of recursive JObjectOutput class.
117  */
118  template<class JHead_t>
119  class JObjectOutput< JTypeList<JHead_t, JNullType> > :
120  public virtual JObjectOutput<JHead_t>
121  {
122  public:
123 
125  };
126 
127 
128  /**
129  * Interface for object output with named access.
130  */
131  template<class T>
133  public virtual JObjectOutput<T>,
134  public virtual JAccessible
135  {};
136 
137 
138  /**
139  * Implementation of null output for single data type.
140  */
141  template<class T>
142  struct JNullOutput :
143  public virtual JObjectOutput<T>
144  {
145  /**
146  * Object output.
147  *
148  * \param object object
149  * \return false
150  */
151  virtual bool put(const T& object)
152  {
153  return false;
154  }
155  };
156 
157 
158  /**
159  * Implemenatation of null output for multiple data types.
160  *
161  * This class recursively implements the JLANG::JObjectOutput interface
162  * for all data types by deriving from:
163  * - JNullOutput<JHead_t>; and
164  * - JNullOutput<JTail_t>.
165  */
166  template<class JHead_t, class JTail_t>
167  struct JNullOutput< JTypeList<JHead_t, JTail_t> > :
168  public virtual JNullOutput<JHead_t>,
169  public virtual JNullOutput<JTail_t>
170  {};
171 
172 
173  /**
174  * Terminator class of recursive JNullOutput class.
175  */
176  template<class JHead_t>
177  struct JNullOutput< JTypeList<JHead_t, JNullType> > :
178  public virtual JNullOutput<JHead_t>
179  {};
180 
181 
182  /**
183  * Implementation for null output with null access.
184  */
185  template<class T>
187  public virtual JAccessibleObjectOutput<T>,
188  public virtual JNullOutput<T>,
189  public virtual JNullAccess
190  {};
191 }
192 
193 #endif
virtual bool put(const T &object)
Object output.
Interface for null access.
Definition: JAccessible.hh:65
Interface of object iteration for a single data type.
virtual ~JObjectOutput()
Virtual destructor.
Implementation for null output with null access.
Type list.
Definition: JTypeList.hh:22
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Auxiliary class for no type definition.
Definition: JNullType.hh:19
JObjectOutput()
Default constructor.
Implementation of null output for single data type.
Template interface of object output for single data type.
virtual bool put(const T &object)=0
Object output.
Interface for object output with named access.
Interface for named access of a device.
Definition: JAccessible.hh:20
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:41