SheafSystem  0.0.0.0
primitive_attributes.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 primitive_attributes
19 
20 #ifndef PRIMITIVE_ATTRIBUTES_H
21 #define PRIMITIVE_ATTRIBUTES_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef PRIMITIVE_TYPE_H
28 #include "SheafSystem/primitive_type.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
34 template <typename T>
35 class block;
36 
40 class SHEAF_DLL_SPEC primitive_attributes
41 {
42 public:
43 
48  static const primitive_attributes& prototype(pod_index_type xid);
49 
53  static primitive_type id(const std::string& xname);
54 
59  {
60  return prototype(xid).id();
61  };
62 
67  {
68  return prototype(xid).size();
69  };
70 
75  {
76  return prototype(xid).alignment();
77  };
78 
82  static const std::string& name(pod_index_type xid)
83  {
84  return prototype(xid).name();
85  };
86 
90  static const std::string& aliases(pod_index_type xid)
91  {
92  return prototype(xid).aliases();
93  };
94 
98  static const std::string& hdf_type_name(pod_index_type xid)
99  {
100  return prototype(xid).hdf_type_name();
101  };
102 
106  static int hdf_type(pod_index_type xid)
107  {
108  return prototype(xid).hdf_type();
109  };
110 
115  {
116  return prototype(xid).default_value();
117  };
118 
123  {
124  return prototype(xid); // Return invokes conversion function
125  };
126 
127  // ===========================================================
128  // CONSTRUCTORS
129  // ===========================================================
130 
135 
140 
146 
151  primitive_attributes(const void* x);
152 
157  primitive_attributes(const char* x);
158 
163  template <typename T>
164  primitive_attributes(const T& x);
165 
169  primitive_attributes& operator=(const primitive_attributes&);
170 
175 
176 
177  // ===========================================================
178  // ATTRIBUTES
179  // ===========================================================
180 
185  {
186  return _id;
187  };
188 
192  size_type size() const
193  {
194  return _size;
195  };
196 
201  {
202  return _alignment;
203  };
204 
208  const std::string& name() const
209  {
210  return *_name;
211  };
212 
216  const std::string& aliases() const
217  {
218  return *_aliases;
219  };
220 
224  const std::string& hdf_type_name() const
225  {
226  return *_hdf_type_name;
227  };
228 
232  int hdf_type() const
233  {
234  return _hdf_type;
235  };
236 
241  {
242  return _default_value;
243  };
244 
248  operator primitive_descriptor() const;
249 
250 private:
251 
255  primitive_type _id;
256 
260  size_type _size;
261 
265  size_type _alignment;
266 
270  const std::string* _name;
271 
275  const std::string* _aliases;
276 
280  const std::string* _hdf_type_name;
281 
285  int _hdf_type;
286 
290  primitive_buffer_type _default_value;
291 
295  static block<primitive_attributes>& make_prototypes();
296 };
297 
298 // ===========================================================
299 // NON-MEMBER FUNCTIONS
300 // ===========================================================
301 
302 } // namespace sheaf
303 
304 #endif // ifndef PRIMITIVE_ATTRIBUTES_H
static primitive_descriptor descriptor(pod_index_type xid)
Primitive descriptor for the primitive type with id xid.
size_type alignment() const
The alignment for the primitive type associated with this.
size_type size() const
The size of the primitive type associated with this.
static primitive_type id(pod_index_type xid)
Converts pod_index_type xid to primitive_type.
static const std::string & hdf_type_name(pod_index_type xid)
The name in the hdf file of primitive type with id xid.
static primitive_buffer_type default_value(pod_index_type xid)
The default value for the primitive type associated with this.
primitive_type
Type ids for sheaf primitives.
Type of buffer large enough to hold any primitive type.
int hdf_type() const
The hdf type of the primitive type associated with this.
static const std::string & aliases(pod_index_type xid)
Other names for the primitive type with id xid.
const std::string & aliases() const
Other names for the primitive type associated with this.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
static primitive_type id(const std::string &xname)
Type id of the primitive type with name or alias xname.
Abstract object wrapper for an instance of a primitive type.
static int hdf_type(pod_index_type xid)
The hdf type of primitive type with id xid.
static size_type alignment(pod_index_type xid)
Alignment of the primitive type with id xid.
static const std::string & name(pod_index_type xid)
The name of primitive type with id xid.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
primitive_type id() const
The id for the primitive type associated with this.
Namespace for the sheaves component of the sheaf system.
primitive_buffer_type default_value() const
The default value for the primitive type associated with this.
static size_type size(pod_index_type xid)
Size of the primitive type with id xid.
An auto_block with a no-initialization initialization policy.
const std::string & hdf_type_name() const
The name in the hdf file of the primitive type associated with this.
const std::string & name() const
The name of the primitive type associated with this.