Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JAbstractObjectReader.hh
Go to the documentation of this file.
1#ifndef __JLANG__JABSTRACTOBJECTREADER__
2#define __JLANG__JABSTRACTOBJECTREADER__
3
5
6
7/**
8 * \author mdejong
9 */
10
11namespace JLANG {}
12namespace JPP { using namespace JLANG; }
13
14namespace JLANG {
15
16 /**
17 * Abstract interface for object reading.
18 *
19 * This class implements the JObjectIterator interface by transferring
20 * the interface methods to a helper object via a single interface method getHelper().
21 */
22 template<class T>
24 public virtual JObjectIterator<T>
25 {
26
28
29
30 /**
31 * Check validity of helper.
32 *
33 * \return true if helper not null; else false
34 */
35 bool is_valid() const
36 {
37 return this->getHelper() != NULL;
38 }
39
40
41 /**
42 * Get helper.
43 *
44 * \return pointer to helper
45 */
46 virtual JObjectIterator<T>* getHelper() const = 0;
47
48
49 /**
50 * Check availability of next element.
51 *
52 * \return true if the iteration has more elements; else false
53 */
54 virtual bool hasNext() override
55 {
56 return (this->is_valid() && this->getHelper()->hasNext());
57 }
58
59
60 /**
61 * Get next element.
62 *
63 * \return pointer to element
64 */
65 virtual const pointer_type& next() override
66 {
67 if (this->is_valid())
68 return this->getHelper()->next();
69 else
70 return ps;
71 }
72
73
74 /**
75 * Skip items.
76 *
77 * \param ns number of items to skip
78 * \return number of items skipped
79 */
80 virtual skip_type skip(const skip_type ns) override
81 {
82 if (this->is_valid())
83 return this->getHelper()->skip(ns);
84 else
85 return 0;
86 }
87
88 private:
90 };
91
92
93 /**
94 * Abstract interface for object reading with rewinding.
95 *
96 * This class implements the JRewindableObjectIterator interface by transferring
97 * the interface methods to a helper object via a single interface method getHelper().
98 */
99 template<class T>
101 public virtual JRewindableObjectIterator<T>,
102 public JAbstractObjectReader <T>
103 {
104 /**
105 * Get helper.
106 *
107 * \return pointer to helper
108 */
109 virtual JRewindableObjectIterator<T>* getHelper() const override = 0;
110
111
112 /**
113 * Rewind.
114 */
115 virtual void rewind() override
116 {
117 if (this->is_valid()) {
118 this->getHelper()->rewind();
119 }
120 }
121 };
122
123
124 /**
125 * Abstract interface for object reading with named access.
126 *
127 * This class implements the JAccessibleObjectIterator interface by transferring
128 * the interface methods to a helper object via a single interface method getHelper().
129 */
130 template<class T>
132 public virtual JAccessibleObjectIterator<T>,
133 public JAbstractObjectReader <T>
134 {
135 /**
136 * Get helper.
137 *
138 * \return pointer to helper
139 */
140 virtual JAccessibleObjectIterator<T>* getHelper() const override = 0;
141
142
143 /**
144 * Check is device is open.
145 *
146 * \return true if open; else false
147 */
148 virtual bool is_open() const override
149 {
150 if (this->is_valid())
151 return this->getHelper()->is_open();
152 else
153 return false;
154 }
155
156
157 /**
158 * Open device.
159 *
160 * \param file_name file name
161 */
162 virtual void open(const char* file_name) override
163 {
164 if (this->is_valid()) {
165 this->getHelper()->open(file_name);
166 }
167 }
168
169
170 /**
171 * Close device.
172 */
173 virtual void close() override
174 {
175 if (this->is_valid()) {
176 this->getHelper()->close();
177 }
178 }
179 };
180}
181
182#endif
Interface for object iteration with named access.
Interface of object iteration for a single data type.
Interface for object iteration with rewinding.
Auxiliary classes and methods for language specific functionality.
unsigned int skip_type
Type definition for number of objects to skip.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Abstract interface for object reading with named access.
virtual void close() override
Close device.
virtual JAccessibleObjectIterator< T > * getHelper() const override=0
Get helper.
virtual bool is_open() const override
Check is device is open.
virtual void open(const char *file_name) override
Open device.
Abstract interface for object reading.
JObjectIterator< T >::pointer_type pointer_type
virtual skip_type skip(const skip_type ns) override
Skip items.
bool is_valid() const
Check validity of helper.
virtual const pointer_type & next() override
Get next element.
virtual bool hasNext() override
Check availability of next element.
virtual JObjectIterator< T > * getHelper() const =0
Get helper.
Abstract interface for object reading with rewinding.
virtual JRewindableObjectIterator< T > * getHelper() const override=0
Get helper.