]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_AttributeTables.h
Salome HOME
Update line endings according to coding rules
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeTables.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeTables.h
4 // Created:     14 Nov 2016
5 // Author:      Mikhail Ponikarov
6
7 #ifndef ModelAPI_AttributeTables_H_
8 #define ModelAPI_AttributeTables_H_
9
10 #include <ModelAPI.h>
11 #include <ModelAPI_Attribute.h>
12
13 #include <string>
14
15 /// \class ModelAPI_AttributeTables
16 /// \ingroup DataModel
17 /// \brief API for the attribute that contains tables of some values type.
18 ///
19 /// The type of values can be changed. But all the values in the tables must have the same one
20 /// type. The currently allowed types now are: Boolean, Integer, Double, String.
21 /// By default there is only one table, but it may be increased/decreased by adding/removing
22 /// tables one by one.
23 /// The number of rows and columns are equal in all tables. If table, row or column is added,
24 /// the previous values are kept unchanged. New cells are filled by zero, false or empty strings.
25 class ModelAPI_AttributeTables: public ModelAPI_Attribute
26 {
27 public:
28   /// Type of the value in the table
29   enum ValueType {
30     BOOLEAN,
31     INTEGER,
32     DOUBLE,
33     STRING
34   };
35
36   struct Value {
37     bool myBool;
38     int myInt;
39     double myDouble;
40     std::string myStr;
41   };
42
43   /// Returns the number of rows in the table
44   MODELAPI_EXPORT virtual int rows() = 0;
45   /// Returns the number of columns in the table
46   MODELAPI_EXPORT virtual int columns() = 0;
47   /// Returns the number of tables
48   MODELAPI_EXPORT virtual int tables() = 0;
49
50   /// Sets the new size of the tables set. This method tries to keep old values if number of
51   /// rows, columns or tables is increased.
52   MODELAPI_EXPORT virtual void setSize(
53     const int theRows, const int theColumns, const int theTables = 1) = 0;
54
55   /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
56   MODELAPI_EXPORT virtual void setType(ValueType theType) = 0;
57   /// Defines the tyoe of values in the table. If it differs from the current, erases the content.
58   MODELAPI_EXPORT virtual const ValueType& type() const = 0;
59   /// Defines the value by the index in the tables set (indexes are zero-based).
60   MODELAPI_EXPORT virtual void setValue(
61     const Value theValue, const int theRow, const int theColumn, const int theTable = 0) = 0;
62   /// Returns the value by the index (indexes are zero-based).
63   MODELAPI_EXPORT virtual Value value(
64     const int theRow, const int theColumn, const int theTable = 0) = 0;
65
66   /// Returns the type of this class of attributes
67   MODELAPI_EXPORT static std::string typeId()
68   {
69     return "Tables";
70   }
71   /// Returns the type of this class of attributes, not static method
72   MODELAPI_EXPORT virtual std::string attributeType();
73   /// To virtually destroy the fields of successors
74   MODELAPI_EXPORT virtual ~ModelAPI_AttributeTables();
75
76 protected:
77   /// Objects are created for features automatically
78   MODELAPI_EXPORT ModelAPI_AttributeTables();
79 };
80
81 /// Pointer on double attribute
82 typedef std::shared_ptr<ModelAPI_AttributeTables> AttributeTablesPtr;
83
84 #endif