Salome HOME
a22e94203d038bcb7b60c080628d15321ace0a6a
[modules/shaper.git] / src / XAO / XAO_Step.hxx
1 // Copyright (C) 2013-2023  CEA/DEN, EDF R&D
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 // Author : Frederic Pons (OpenCascade)
20
21 #ifndef __XAO_STEP_HXX__
22 #define __XAO_STEP_HXX__
23
24 #include "XAO.hxx"
25 #include "XAO_XaoUtils.hxx"
26
27 #ifdef WIN32
28 #pragma warning(disable:4290) // Warning Exception ...
29 #endif
30
31
32 namespace XAO
33 {
34     /**
35      * @class Step
36      * Base class for steps.
37      */
38     class XAO_EXPORT Step
39     {
40     protected:
41         /** Default constructor. */
42         Step() {}
43
44     public:
45         /**
46          * Destructor.
47          */
48         virtual ~Step() {}
49
50         /**
51          * Gets the type of the step.
52          * @return
53          */
54         virtual XAO::Type getType() = 0;
55
56         /**
57          * Gets the step index.
58          * @return the index of the step.
59          */
60         int getStep() { return m_step; }
61
62         /**
63          * Sets the number of the step.
64          * @param step the index to set.
65          */
66         void setStep(int step) { m_step = step; }
67
68         /**
69          * Gets the stamp of the index.
70          * @return the stamp of the index.
71          */
72         int getStamp() { return m_stamp; }
73
74         /**
75          * Sets the stamp of the index.
76          * @param stamp the stamp to set.
77          */
78         void setStamp(int stamp) { m_stamp = stamp; }
79
80         /**
81          * Gets the number of components of the step.
82          * @return the number of components.
83          */
84         int countComponents() { return m_nbComponents; }
85
86         /**
87          * Gets the number of elements for the step.
88          * @return the number of elements.
89          */
90         int countElements() { return m_nbElements; }
91
92         /**
93          * Gets the number of values for the step.
94          * @return the number of values.
95          */
96         int countValues() { return m_nbElements * m_nbComponents; }
97
98         /**
99          * Gets a value as a string.
100          * @param element the index of the element.
101          * @param component the index of the component.
102          * @return the value as a string.
103          */
104         virtual const std::string getStringValue(int element, int component) = 0;
105
106         /**
107          * Sets a value as a string
108          * @param element the index of the element.
109          * @param component the index of the component.
110          * @param value the string value.
111          * @throw XAO_Exception if the value is not valid.
112          */
113         virtual void setStringValue(int element, int component, const std::string& value) = 0;
114
115     protected:
116         /**
117          * Checks that given element index is in the range of element indexes.
118          * @param element the index to check.
119          */
120         void checkElementIndex(int element);
121         /**
122          * Checks that given component index is in the range of component indexes.
123          * @param component the index to check.
124          */
125         void checkComponentIndex(int component);
126
127         /**
128          * Checks that the given number of elements is correct.
129          * @param nbElements the number of elements to check.
130          */
131         void checkNbElements(int nbElements);
132
133         /**
134          * Checks that the given number of components is correct.
135          * @param nbComponents the number of components to check.
136          */
137         void checkNbComponents(int nbComponents);
138
139         /**
140          * checks that the given number of values is correct.
141          * @param nbValues the number of values to check.
142          */
143         void checkNbValues(int nbValues);
144
145     protected:
146         /** the index of the step. */
147         int m_step;
148         /** The stamp of the step. */
149         int m_stamp;
150         /** The number of components. */
151         int m_nbComponents;
152         /** The number of elements. */
153         int m_nbElements;
154     };
155 }
156
157
158 #endif /* __XAO_STEP_HXX__ */