MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Attributes.hpp
Go to the documentation of this file.
1 #ifndef ATTRIBUTES_HPP
2 #define ATTRIBUTES_HPP
3 
9 #include <Config.hpp>
10 
11 #include <Mesh.hpp>
12 
13 namespace mgx {
18  class AttribBase
19  {
23  AttribBase(const QString& name) : _name(name)
24 
25 
28  virtual ~AttribBase();
29 
33  const QString& name() { return _name; }
34 
35  private:
36  QString _name;
37  }
38 
43  template <IndexT, ValueT>
44  class Attrib : AttribBase
45  {
49  typedef std::pari<IndexT, ValueT> AttribPair;
50 
55  Attrib(const QString& name, ValueT& defVal) : AttribBase(name), _defVal(defVal)
56 
57  public:
58  std::unordered_map<IndexT, ValueT>& data() { return _data; };
59  const std::unordered_map<IndexT, ValueT>& data() { return _data; };
60 
61  private:
62  std::unordered_map<IndexT, ValueT> _data;
63  ValueT _defVal;
64  }
65 
66  class AttribSet
67  {
68  AttribBase *get(const QString &s);
69  AttribBase *exists(const QString &s);
70  AttribBase *add(const QString &s);
71  bool erase(const QString &s);
72 
73  private:
74  std::vector<AttribBase> _attribs;
75  }
76 }
77 
78 #endif
IndexT
Type of the pair used in the attribute map.
AttribBase(const QString &name) const QString & name()
Default constructor of named attribute.
Definition: Attributes.hpp:54
Attrib(const QString &name, ValueT &defVal)
Constructor.
Definition: Attributes.hpp:55
Base class for attributes system.
Definition: Attributes.hpp:18
Derived template class for attributes system.
Definition: Attributes.hpp:18
This files contains the definition of a mesh for the Process API.