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