Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JSTDObjectOutput.hh
Go to the documentation of this file.
1#ifndef __JLANG__JSTDOBJECTOUTPUT__
2#define __JLANG__JSTDOBJECTOUTPUT__
3
4#include <iterator>
5
7
8
9/**
10 * \author mdejong
11 */
12
13namespace JLANG {}
14namespace JPP { using namespace JLANG; }
15
16namespace JLANG {
17
18 /**
19 * Implementation of object output for STD compatible output iterator.
20 *
21 * This class implements the JLANG::JObjectOutput interface for the corresponding data type.
22 */
23 template<class JOutputIterator_t>
25 public virtual JObjectOutput<typename JOutputIterator_t::container_type::value_type>
26 {
27 public:
28
29 typedef typename JOutputIterator_t::container_type::value_type value_type;
30
31
32 /**
33 * Constructor.
34 *
35 * \param out output iterator
36 */
37 JSTDObjectOutput(const JOutputIterator_t& out) :
38 out(out)
39 {}
40
41
42 /**
43 * Object output.
44 *
45 * \param object object
46 * \return true
47 */
48 virtual bool put(const value_type& object) override
49 {
50 *out = object;
51 ++out;
52
53 return true;
54 }
55
56 protected:
57 JOutputIterator_t out;
58 };
59
60
61 /**
62 * Helper method to create STD compatible object output.
63 *
64 * \param out object output
65 * \return pointer to object output
66 */
67 template<class T>
70 {
71 return new JSTDObjectOutput(out);
72 }
73
74
75 /**
76 * Helper method to create STD compatible object output.
77 *
78 * \param out output iterator
79 * \return pointer to object output
80 */
81 template<class T>
83 getSTDObjectOutput(const T& out)
84 {
85 return new JSTDObjectOutput<T>(out);
86 }
87
88
89 /**
90 * Helper method to create STD compatible object output.
91 *
92 * \param out output container
93 * \return pointer to object output
94 */
95 template<class T>
98 {
99 return new JSTDObjectOutput(std::inserter(out, out.end()));
100 }
101}
102
103#endif
Template interface of object output for single data type.
Implementation of object output for STD compatible output iterator.
JOutputIterator_t::container_type::value_type value_type
virtual bool put(const value_type &object) override
Object output.
JSTDObjectOutput(const JOutputIterator_t &out)
Constructor.
Auxiliary classes and methods for language specific functionality.
JSTDObjectOutput< T > * getSTDObjectOutput(const JSTDObjectOutput< T > &out)
Helper method to create STD compatible object output.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).