Loading [MathJax]/extensions/tex2jax.js
M/c++_api/inc/DM/IAddInfo.hpp
1 #pragma once
2 
3 #include "DM/config.hpp"
4 #include "DM/IAddInfoLayout.hpp"
5 
6 DM_NAMESPACE_BEGIN
7 
8 /// \brief AddInfo objects store a set of attributes
9 /**
10  Managing attributes, layout and views is a core feature of the DM library. Please refer to the
11  \ref dm_attributes section for implementation concepts and to the <a href="examples.html">examples</a>
12  section (attribute handling) for further details.
13 */
14 class DM_API IAddInfo : public IAddInfoLayout
15 {
16 protected:
17  virtual ~IAddInfo() {}
18 
19 public:
20  static IAddInfo* New(const IAddInfoLayout &layout);
21 
22  //IAddInfoLayout Interface ==================================================
23  virtual unsigned columns() const = 0;
24 
25  virtual const char* name(unsigned index) const = 0;
26  virtual ColumnType type(unsigned index) const = 0;
27  virtual ColumnSemantic semantic(unsigned index) const = 0;
28  virtual unsigned size(unsigned index) const = 0;
29  virtual bool exist(unsigned index) const = 0;
30 
31  virtual int index(const char*) const = 0;
32  virtual int index(ColumnSemantic) const = 0;
33 
34  //actual IAddInfo Inteface ==================================================
35  virtual const IAddInfoLayout& layout() const = 0;
36 
37  /// \brief is the current layout just a view onto the storage object
38  virtual bool isView() const = 0;
39 
40  ///returns a full copy of the current object
41  virtual IAddInfo* clone() const = 0;
42 
43  /// \brief creates a new addinfo object with the provide view layout that refers to the same storage object
44  /**
45  Whereas setView changes the current addinfo object, cloneView leafs the current object unchanged and creates
46  an new addinfo object using the provide view layout that internal refers to the same storage object. See the
47  attribute handling example in the <a href="examples.html">examples</a> section.
48 
49  @param[in] layout view layout that should be used
50  @param[in] readOnly flag if the layout of storage object should be changed, in case the view layout is not a true subset of the storage layout
51  @return new addinfo object
52  */
53  virtual IAddInfo *cloneView(const AddInfoLayoutHandle &layout, bool readOnly) const = 0;
54  /// \brief creates a new addinfo object with the provide view layout and secures that the storage object contains the dataLayout
55  /**
56  Whereas setView changes the current addinfo object, cloneView leafs the current object unchanged and creates
57  an new addinfo object using the provide view layout that internal refers to the same storage object. Furthermore it is checked
58  that all columns of the dataLayout exist in the storage object. If not the storage object is extended. See the
59  attribute handling example in the <a href="examples.html">examples</a> section.
60 
61  @param[in] viewLayout view layout that should be set
62  @param[in] dataLayout defines columns that have to exist in the storage object
63  */
64  virtual IAddInfo *cloneView(const AddInfoLayoutHandle &viewLayout, const AddInfoLayoutHandle &dataLayout) const = 0;
65  /// \brief creates a new addinfo object using the true storage layout that referring to the same storage object
66  virtual IAddInfo *cloneFullLayout() const = 0;
67 
68  /// \brief applies a certain layout view onto the current object
69  /**
70  In contrast to cloneView the function changes the visible layout of the current object. Since
71  geometry object uses smart pointers to addinfo object this may affect other code parts.
72  The read only parameter does not protect for writing attributes to the addinfo object. The parameter refers to
73  the layout of storage object. The view layout is not necessarily a subset of the storage layout. In such a configuration
74  the disjunct attributes can be added (readOnly = false) to the attribute storage (and storage layout) or not
75  (readOnly = true). In the later case the disjunct attributes still exists in the view layout, but you will not be able to
76  read or write them. Only the isNull check will be valid and, of course, it will always return true for disjunct attributes.
77  In case you want to read/write all attributes of the view layout the read only parameter should be set to false
78 
79  @param[in] layout view layout that should be set
80  @param[in] readOnly flag if the layout of storage object should be changed, in case the view layout is not a true subset of the storage layout
81  */
82  virtual void setView(const AddInfoLayoutHandle &layout, bool readOnly) = 0;
83  /// \brief removes any view layout and sets the true storage layout as (internal) layout
84  virtual void restoreFullLayout() = 0;
85 
86  virtual bool isNull(unsigned index) const = 0;
87  virtual void setNull(unsigned index,bool nullFlag = true) = 0;
88 
89  virtual void setInt8(unsigned index, int8_t) = 0;
90  virtual void setUInt8(unsigned index, uint8_t) = 0;
91 
92  virtual void setInt16(unsigned index, int16_t) = 0;
93  virtual void setUInt16(unsigned index, uint16_t) = 0;
94 
95  virtual void setInt32(unsigned index, int32_t) = 0;
96  virtual void setUInt32(unsigned index, uint32_t) = 0;
97 
98  virtual void setInt64(unsigned index, int64_t) = 0;
99 
100  virtual void setFloat(unsigned index, float) = 0;
101  virtual void setDouble(unsigned index, double) = 0;
102 
103  virtual void setCStr(unsigned index, const char *) = 0; ///< for setting column values of type eCOLTYPE_CSTR or eCOLTYPE_STRING
104  virtual void setBool(unsigned index, bool) = 0;
105 
106  virtual int8_t getInt8(unsigned index) const = 0;
107  virtual uint8_t getUInt8(unsigned index) const = 0;
108 
109  virtual int16_t getInt16(unsigned index) const = 0;
110  virtual uint16_t getUInt16(unsigned index) const = 0;
111 
112  virtual int32_t getInt32(unsigned index) const = 0;
113  virtual uint32_t getUInt32(unsigned index) const = 0;
114 
115  virtual int64_t getInt64(unsigned index) const = 0;
116 
117  virtual float getFloat(unsigned index) const = 0;
118  virtual double getDouble(unsigned index) const = 0;
119 
120  virtual const char* getCStr(unsigned index) const = 0; ///< returns column values of type eCOLTYPE_CSTR or eCOLTYPE_STRING
121  virtual bool getBool(unsigned index) const = 0;
122 
123  //convenience functions for easier access to specific add info elements
124  virtual EchoClass getEchoClass() const = 0;
125 
126  //get function with implizit conversion
127 
128  virtual int8_t getAsInt8(unsigned index) const = 0;
129  virtual uint8_t getAsUInt8(unsigned index) const = 0;
130 
131  virtual int16_t getAsInt16(unsigned index) const = 0;
132  virtual uint16_t getAsUInt16(unsigned index) const = 0;
133 
134  virtual int32_t getAsInt32(unsigned index) const = 0;
135  virtual uint32_t getAsUInt32(unsigned index) const = 0;
136 
137  virtual int64_t getAsInt64(unsigned index) const = 0;
138 
139  virtual float getAsFloat(unsigned index) const = 0;
140  virtual double getAsDouble(unsigned index) const = 0;
141 
142  ///returns buffer length that is required to fully retrieve the column by getFromCStr (+1 for '\0' already included)
143  virtual unsigned getFromCStrLength(unsigned index) const = 0;
144  /// \brief stores column value in the provided character buffer
145  /// \param[in] index column index
146  /// \param[in,out] buffer character buffer
147  /// \param[in] bufferLen length of reserved character buffer
148  /// \return true if bufferLen was sufficient for storing the column value, otherwise false
149  virtual bool getFromCStr(unsigned index, char *buffer, unsigned bufferLen) const = 0;
150 
151  virtual void setFromInt8(unsigned index, int8_t) = 0;
152  virtual void setFromUInt8(unsigned index, uint8_t) = 0;
153 
154  virtual void setFromInt16(unsigned index, int16_t) = 0;
155  virtual void setFromUInt16(unsigned index, uint16_t) = 0;
156 
157  virtual void setFromInt32(unsigned index, int32_t) = 0;
158  virtual void setFromUInt32(unsigned index, uint32_t) = 0;
159 
160  virtual void setFromInt64(unsigned index, int64_t) = 0;
161 
162  virtual void setFromFloat(unsigned index, float) = 0;
163  virtual void setFromDouble(unsigned index, double) = 0;
164 
165  virtual void setFromCStr(unsigned index, const char *) = 0;
166 
167  static bool releaseMemory();
168 
169  /// \brief removes the specified attributes from current object
170  /**
171  @param[in] layout contains all attributes that should be erased from storage (and storage layout)
172  */
173  virtual void eraseLayout(const AddInfoLayoutHandle &layout) = 0;
174 
175 };
176 
178 
179 
180 DM_NAMESPACE_END
ColumnSemantic
Pre-defined attributes (attributes with semantic)
Definition: ColumnTypes.hpp:38
AddInfo layouts describe a set of attributes that can be attached to geometry objects.
Definition: IAddInfoLayout.hpp:18
AddInfo objects store a set of attributes.
Definition: M/c++_api/inc/DM/IAddInfo.hpp:14
Definition: Handle.hpp:427
virtual unsigned size(unsigned index) const =0
returns array size
ColumnType
Supported attribute type.
Definition: ColumnTypes.hpp:8
EchoClass
echo class types
Definition: ColumnTypes.hpp:138
Smart pointer class using reference counting with support for DM objects (see ObjectBase)
Definition: Handle.hpp:75