Salome HOME
Issue #1540: Added attribute for array of double.
[modules/shaper.git] / src / Model / Model_AttributeDoubleArray.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeDoubleArray.h
4 // Created:     08 July 2016
5 // Author:      Dmitry Bobylev
6
7 #ifndef Model_AttributeDoubleArray_H_
8 #define Model_AttributeDoubleArray_H_
9
10 #include "Model.h"
11
12 #include <ModelAPI_AttributeDoubleArray.h>
13
14 #include <TDF_Label.hxx>
15 #include <TDataStd_RealArray.hxx>
16
17 #include <string>
18
19 /// \class Model_AttributeDoubleArray
20 /// \ingroup DataModel
21 /// \brief API for the attribute that contains several double in the array inside.
22 class Model_AttributeDoubleArray: public ModelAPI_AttributeDoubleArray
23 {
24 public:
25   /// Returns the size of the array (zero means that it is empty)
26   MODEL_EXPORT virtual int size();
27
28   /// Sets the new size of the array. The previous data is erased.
29   MODEL_EXPORT virtual void setSize(const int theSize);
30
31   /// Defines the value of the array by index [0; size-1]
32   MODEL_EXPORT virtual void setValue(const int theIndex,
33                                      const double theValue);
34
35   /// Returns the value by the index
36   MODEL_EXPORT virtual double value(const int theIndex);
37
38 protected:
39   /// Initializes attibutes
40   Model_AttributeDoubleArray(TDF_Label& theLabel);
41
42 private:
43   /// The OCCT array that keeps all values.
44   Handle_TDataStd_RealArray myArray;
45
46   /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
47   TDF_Label myLab;
48
49   friend class Model_Data;
50 };
51
52 #endif