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