SHAPER  9.15.0
ModelAPI_AttributeTables.h
1 // Copyright (C) 2014-2025 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef ModelAPI_AttributeTables_H_
21 #define ModelAPI_AttributeTables_H_
22 
23 #include <ModelAPI.h>
24 #include <ModelAPI_Attribute.h>
25 
26 #include <string>
27 
39 {
40 public:
42  enum ValueType {
43  BOOLEAN,
44  INTEGER,
45  DOUBLE,
46  STRING
47  };
48 
49  struct Value {
50  bool myBool;
51  int myInt;
52  double myDouble;
53  std::string myStr;
54  };
55 
57  MODELAPI_EXPORT virtual int rows() = 0;
59  MODELAPI_EXPORT virtual int columns() = 0;
61  MODELAPI_EXPORT virtual int tables() = 0;
62 
65  MODELAPI_EXPORT virtual void setSize(
66  const int theRows, const int theColumns, const int theTables = 1) = 0;
67 
69  MODELAPI_EXPORT virtual void setType(ValueType theType) = 0;
71  MODELAPI_EXPORT virtual const ValueType& type() const = 0;
73  MODELAPI_EXPORT virtual void setValue(
74  const Value theValue, const int theRow, const int theColumn, const int theTable = 0) = 0;
76  MODELAPI_EXPORT virtual Value value(
77  const int theRow, const int theColumn, const int theTable = 0) = 0;
78 
80  MODELAPI_EXPORT virtual std::string valueStr(
81  const int theRow, const int theColumn, const int theTable = 0) = 0;
82 
84  MODELAPI_EXPORT static std::string typeId()
85  {
86  return "Tables";
87  }
89  MODELAPI_EXPORT virtual std::string attributeType();
91  MODELAPI_EXPORT virtual ~ModelAPI_AttributeTables();
92 
93 protected:
95  MODELAPI_EXPORT ModelAPI_AttributeTables();
96 };
97 
99 typedef std::shared_ptr<ModelAPI_AttributeTables> AttributeTablesPtr;
100 
101 #endif
API for the attribute that contains tables of some values type.
Definition: ModelAPI_AttributeTables.h:39
virtual MODELAPI_EXPORT void setType(ValueType theType)=0
Defines the tyoe of values in the table. If it differs from the current, erases the content.
virtual MODELAPI_EXPORT void setValue(const Value theValue, const int theRow, const int theColumn, const int theTable=0)=0
Defines the value by the index in the tables set (indexes are zero-based).
virtual MODELAPI_EXPORT int rows()=0
Returns the number of rows in the table.
MODELAPI_EXPORT ModelAPI_AttributeTables()
Objects are created for features automatically.
Definition: ModelAPI_AttributeTables.cpp:34
virtual MODELAPI_EXPORT int tables()=0
Returns the number of tables.
virtual MODELAPI_EXPORT Value value(const int theRow, const int theColumn, const int theTable=0)=0
Returns the value by the index (indexes are zero-based).
virtual MODELAPI_EXPORT std::string attributeType()
Returns the type of this class of attributes, not static method.
Definition: ModelAPI_AttributeTables.cpp:23
virtual MODELAPI_EXPORT std::string valueStr(const int theRow, const int theColumn, const int theTable=0)=0
Returns the value in the format of string (useful for the python connection)
ValueType
Type of the value in the table.
Definition: ModelAPI_AttributeTables.h:42
virtual MODELAPI_EXPORT const ValueType & type() const =0
Defines the tyoe of values in the table. If it differs from the current, erases the content.
virtual MODELAPI_EXPORT void setSize(const int theRows, const int theColumns, const int theTables=1)=0
Sets the new size of the tables set.
virtual MODELAPI_EXPORT ~ModelAPI_AttributeTables()
To virtually destroy the fields of successors.
Definition: ModelAPI_AttributeTables.cpp:29
virtual MODELAPI_EXPORT int columns()=0
Returns the number of columns in the table.
static MODELAPI_EXPORT std::string typeId()
Returns the type of this class of attributes.
Definition: ModelAPI_AttributeTables.h:84
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
Definition: ModelAPI_AttributeTables.h:49