SheafSystem  0.0.0.0
data_converter.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class data_converter
19 
20 #ifndef DATA_CONVERTER_H
21 #define DATA_CONVERTER_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef ANY_H
28 #include "SheafSystem/any.h"
29 #endif
30 
31 #ifndef PRIMITIVE_TYPE_H
32 #include "SheafSystem/primitive_type.h"
33 #endif
34 
35 #ifndef STD_HDF5_H
36 #include "SheafSystem/std_hdf5.h"
37 #endif
38 
39 #ifndef STD_STRING_H
40 #include "SheafSystem/std_string.h"
41 #endif
42 
43 namespace sheaf
44 {
45 
50 class SHEAF_DLL_SPEC data_converter : public any
51 {
52 
53 public:
54 
55  // CANONICAL MEMBERS
56 
62  virtual data_converter* clone() const;
63 
67  virtual ~data_converter();
68 
72  virtual bool invariant() const;
73 
77  virtual bool is_ancestor_of(const any* other) const;
78 
79  // DATA_CONVERTER INTERFACE
80 
89  data_converter(hid_t xexternal_type,
90  hid_t xinternal_type,
91  // const scoped_index& xinternal_index);
92  int xinternal_index);
93 
94 
95 
99  inline bool conversion_required() const
100  {
101  return _conversion_required;
102  } ;
103 
104 
105 
109  inline hid_t external_type() const
110  {
111  return _external_type;
112  } ;
113 
114 
115 
119  inline size_t external_size() const
120  {
121  return _external_size;
122  };
123 
124  // INTERFACE FOR SIMPLE TYPES
125 
130  void externalize(const void* xint_buf,
131  size_t xint_buf_ub,
132  void* xext_buf,
133  size_t xext_buf_ub,
134  int xitem_ct);
135 
140  void externalize(void* xext_buf,
141  size_t xext_buf_ub,
142  int xitem_ct);
143 
148  void externalize(const void* xint_buf,
149  size_t xint_buf_ub);
150 
151 
152 
156  inline hid_t internal_type() const
157  {
158  return _internal_type;
159  } ;
160 
161 
162 
166  inline hid_t internal_index() const
167  {
168  return _internal_index;
169  } ;
170 
171 
172 
176  inline size_t internal_size() const
177  {
178  return _internal_size;
179  };
180 
181 
182 
186  inline size_t internal_alignment() const
187  {
188  return _internal_alignment;
189  };
190 
195  void internalize(const void* xext_buf,
196  size_t xext_buf_ub,
197  void* xint_buf,
198  size_t xint_buf_ub,
199  int xitem_ct);
200 
206  void internalize(void* xbuf, size_t xbuf_ub, int xitem_ct);
207 
212  void internalize(void* xbuf, size_t xbuf_ub);
213 
214 
215 
219  inline bool internal_size_greater() const
220  {
221  return _internal_size > _external_size;
222  };
223 
224 
225 
229  inline bool external_size_greater() const
230  {
231  return _external_size > _internal_size;
232  };
233 
234 
235 
239  inline size_t max_size() const
240  {
241  return _internal_size > _external_size ? _internal_size : _external_size;
242  } ;
243 
244 
245 
249  inline void* result() const
250  {
251  return _result;
252  };
253 
254 
255 
259  inline size_t result_size() const
260  {
261  return _result_size;
262  } ;
263 
264 
265 
270  {
271  return _internal_index == NAMESPACE_RELATIVE_MEMBER_INDEX;
272  };
273 
274 
275 
280  {
281  return _internal_index == NAMESPACE_RELATIVE_SUBPOSET_INDEX;
282  };
283 
284 
285 
289  inline bool is_string_type() const
290  {
291  return _internal_index == C_STRING;
292  };
293 
297  static size_t string_length(const char* xbuf);
298 
303  size_t string_length_total(const void* xbuf, int xitem_ct) const;
304 
305 
306 private:
307 
312  data_converter();
313 
318  data_converter(const data_converter& xother);
319 
323  hid_t _external_type;
324 
328  size_t _external_size;
329 
333  hid_t _internal_type;
334 
338  size_t _internal_size;
339 
340 
344  int _internal_index;
345 
349  size_t _internal_alignment;
350 
354  void* _result;
355 
359  size_t _result_size;
360 
366  hid_t _transfer_plist;
367 
371  bool _conversion_required;
372 
373 };
374 
375 } // namespace sheaf
376 
377 #endif // ifndef DATA_CONVERTER_H
378 
379 
380 
381 
382 
383 
bool external_size_greater() const
True if the external size is greater than the internal size.
hid_t external_type() const
The external type identifier.
size_t internal_size() const
The size in bytes of the internal type.
bool is_string_type() const
True if this is a converter for a string type.
bool conversion_required() const
True if internal and external types are not identical.
size_t internal_alignment() const
The alignment of the internal type.
bool is_namespace_relative_member_index_type() const
True if this is a converter for a naemspace_relative_member_index type.
Abstract base class with useful features for all objects.
Definition: any.h:39
hid_t internal_index() const
The primitives poset member index for the internal type.
size_t result_size() const
The allocated size of the result buffer.
size_t external_size() const
The size in bytes of the external type.
bool is_namespace_relative_subposet_index_type() const
True if this is a converter for a namespace_relative_subposet_index type.
bool internal_size_greater() const
True if the internal size is greater than the external size.
Function object to convert between internal and external data formats.
Namespace for the sheaves component of the sheaf system.
size_t max_size() const
The maximum of internal_size() and external_size().
hid_t internal_type() const
The HDF type identifier for the internal type.
void * result() const
The result of the conversion.