IAddInfoLayoutFactory.hpp
1 #pragma once
2 
3 #include "DM/config.hpp"
4 #include "DM/ColumnTypes.hpp"
5 #include "DM/Handle.hpp"
6 #include "DM/IAddInfoLayout.hpp"
7 #include "DM/AutoLink.hpp" //enable autolink
8 
9 
10 DM_NAMESPACE_BEGIN
11 
12 class IDatamanager; //forward declaration
13 
14 
15 /// \brief Interface to a factory object for creating AddInfo layouts
16 class DM_API IAddInfoLayoutFactory : public ObjectBase
17 {
18 public:
19  static IAddInfoLayoutFactory* New();
20  //static AddInfoLayoutHandle getEmptyTableLayout();
21 
22  static AddInfoLayoutHandle getPredefinedLayout(const char *label);
23  static AddInfoLayoutHandle merge(AddInfoLayoutHandle layout1, AddInfoLayoutHandle layout2);
24 
25 protected:
26  virtual ~IAddInfoLayoutFactory() {}
27 
28 public:
29  /// \brief clear added entries from the factory
30  virtual void clear() = 0;
31 
32  /// \brief add a user-defined attribute
33  /// User-defined attribute always have to start with a '_'. For adding predefined attributes please use the corresponding ColumnSemantic value
34  /// \param[in] type type of the user-defined attribute
35  /// \param[in] name name of the user-defined attribute
36  /// \return reference to the factory object (allows calling multiple addColumn in a row)
37  virtual IAddInfoLayoutFactory& addColumn(ColumnType type, const char *name) = 0;
38  virtual IAddInfoLayoutFactory& addColumn(ColumnType type, const char *name, unsigned arraySize) = 0;
39  /// \brief add a pre-defined attribute
40  /// \param[in] semantic semantic value of the corresponding attribute
41  /// \return reference to the factory object (allows calling multiple addColumn in a row)
42  virtual IAddInfoLayoutFactory& addColumn(ColumnSemantic semantic) = 0;
43 
44  /// \brief add a column from an existing layout
45  /// \param[in] layout existing layout
46  /// \param[in] idx index of column that should be added
47  virtual IAddInfoLayoutFactory& addColumn(const DM::IAddInfoLayout &layout, unsigned idx) = 0;
48 
49  /// \brief add all columns of an existing layout
50  /// \param[in] layout existing layout
51  virtual IAddInfoLayoutFactory& addColumn(const DM::IAddInfoLayout &layout) = 0;
52 
53  /// \brief add pre- or user-defined attribute based on attributes stored within a datamanager
54  /// In contrast to the other addColumn functions, this function supports adding user- and per-defined attributes.
55  /// Whereas the type of pre-defined attributes is fixed, for user-defined attributes the type has to be specified. For accessing
56  /// user-defined attributes in a datamanager, the corresponding type has to be known since it is not allow
57  /// combining identical named columns with different types within one layout. Therefore the function takes a damanager reference
58  /// as first parameter and checks the type all used-defined attributes within the datamanager. If there is a match of the attribute
59  /// name, the type as in the datamanager is used. Otherwise the column is not or with the given default type added.
60  ///
61  /// \param[in] dm const reference to a datamanager object
62  /// \param[in] name attribute name
63  /// \param[in] forceAdding adds the attribute even if it's not within the datamanager
64  /// \param[in] defaultType in case of user-defined attribute that are not in the manager the specified type will be used
65  /// \param[in] caseSensitive check if the name should be compared case sensitive (or not) to the datamanager attributes
66  /// \return type of the attribute (or ColumnType::none if no attribute was added) and the flag if the attribute exists within the manager
67  virtual std::pair<ColumnType,bool> addColumn(const IDatamanager &dm, const char *name, bool forceAdding = true, ColumnType defaultType = ColumnType::float_, bool caseSensitive = false) = 0;
68 
69 
70  virtual AddInfoLayoutHandle getLayout(bool clear = true) = 0;
71 
72  virtual AddInfoLayoutHandle getEmptyLayout() const = 0;
73 };
74 
76 
77 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
Interface to a factory object for creating AddInfo layouts.
Definition: IAddInfoLayoutFactory.hpp:16
Definition: Handle.hpp:427
ColumnType
Supported attribute type.
Definition: ColumnTypes.hpp:8
Interface to an Datamanager (ODM) object.
Definition: IDatamanager.hpp:57
Smart pointer class using reference counting with support for DM objects (see ObjectBase)
Definition: Handle.hpp:75
Definition: M/c++_api/inc/DM/ObjectBase.hpp:8