Salome HOME
Issue 0013373: EDF PAL 273 : Option Single/Multi file dump
[modules/geom.git] / src / GEOM / GEOM_Function.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 #ifndef _GEOM_Function_HeaderFile
23 #define _GEOM_Function_HeaderFile
24
25 #ifndef _Standard_TypeMismatch_HeaderFile
26 #include <Standard_TypeMismatch.hxx>
27 #endif
28 #ifndef _Standard_HeaderFile
29 #include <Standard.hxx>
30 #endif
31 #ifndef _Standard_Macro_HeaderFile
32 #include <Standard_Macro.hxx>
33 #endif
34 #ifndef _Handle_MMgt_TShared_HeaderFile
35 #include <Handle_MMgt_TShared.hxx>
36 #endif
37 #ifndef _MMgt_TShared_HeaderFile
38 #include <MMgt_TShared.hxx>
39 #endif
40 #ifndef _Standard_GUID_HeaderFile
41 #include <Standard_GUID.hxx>
42 #endif
43 #ifndef _TopoDS_Shape_HeaderFile
44 #include <TopoDS_Shape.hxx>
45 #endif
46 #ifndef _TDF_Label_HeaderFile
47 #include <TDF_Label.hxx>
48 #endif
49 #ifndef _TDF_LabelSequence_HeaderFile
50 #include <TDF_LabelSequence.hxx>
51 #endif
52 #ifndef _TColStd_HArray1OfExtendedString_HeaderFile
53 #include <TColStd_HArray1OfExtendedString.hxx>
54 #endif
55
56 class Handle_TColStd_HArray1OfReal;
57 class Handle_TColStd_HArray1OfInteger;
58 class Handle_TColStd_HSequenceOfTransient;
59 class Handle_TColStd_HArray1OfExtendedString;
60
61 class Standard_Transient;
62 class Handle_Standard_Type;
63 class Handle(MMgt_TShared);
64 class GEOM_Function;
65
66 #include <TCollection_AsciiString.hxx>
67 #include <TDataStd_ListOfExtendedString.hxx>
68
69 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Function);
70
71 class Handle(GEOM_Function) : public Handle(MMgt_TShared) {
72   public:
73     inline void* operator new(size_t,void* anAddress)
74       {
75         return anAddress;
76       }
77     inline void* operator new(size_t size)
78       {
79         return Standard::Allocate(size);
80       }
81     inline void  operator delete(void *anAddress)
82       {
83         if (anAddress) Standard::Free((Standard_Address&)anAddress);
84       }
85
86     Handle(GEOM_Function)():Handle(MMgt_TShared)() {}
87     Handle(GEOM_Function)(const Handle(GEOM_Function)& aHandle) : Handle(MMgt_TShared)(aHandle)
88      {
89      }
90
91     Handle(GEOM_Function)(const GEOM_Function* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
92      {
93      }
94
95     Handle(GEOM_Function)& operator=(const Handle(GEOM_Function)& aHandle)
96      {
97       Assign(aHandle.Access());
98       return *this;
99      }
100
101     Handle(GEOM_Function)& operator=(const GEOM_Function* anItem)
102      {
103       Assign((Standard_Transient *)anItem);
104       return *this;
105      }
106
107     GEOM_Function* operator->()
108      {
109       return (GEOM_Function *)ControlAccess();
110      }
111
112     GEOM_Function* operator->() const
113      {
114       return (GEOM_Function *)ControlAccess();
115      }
116
117    Standard_EXPORT ~Handle(GEOM_Function)() {};
118
119    Standard_EXPORT static const Handle(GEOM_Function) DownCast(const Handle(Standard_Transient)& AnObject);
120 };
121
122 class GEOM_Function : public MMgt_TShared
123 {
124
125 public:
126
127     inline void* operator new(size_t,void* anAddress)
128       {
129         return anAddress;
130       }
131     inline void* operator new(size_t size)
132       {
133         return Standard::Allocate(size);
134       }
135     inline void  operator delete(void *anAddress)
136       {
137         if (anAddress) Standard::Free((Standard_Address&)anAddress);
138       }
139
140     // Type management
141     //
142     Standard_EXPORT friend Handle_Standard_Type& GEOM_Function_Type_();
143     Standard_EXPORT const Handle(Standard_Type)& DynamicType() const
144       { return STANDARD_TYPE(GEOM_Function) ; }
145     Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
146       { return (STANDARD_TYPE(GEOM_Function) == AType || MMgt_TShared::IsKind(AType)); }
147
148
149 private:
150   GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
151
152 public:
153
154   //Returns a GUID for a function tree
155   Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
156
157   //Returns the ID which is associated with a reference to another function
158   Standard_EXPORT static const Standard_GUID& GetDependencyID();
159
160   //Finds and returns a function located on a label theEntry
161   Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
162
163
164   Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType);
165   Standard_EXPORT ~GEOM_Function() {;}
166
167   Standard_EXPORT TDF_Label GetOwnerEntry();
168
169   //Access to properties
170
171   //Returns a result of the function built by the function Driver
172   Standard_EXPORT TopoDS_Shape GetValue();
173
174   //Sets the function result
175   Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
176
177   //Returns a function entry in the OCAF document
178   Standard_EXPORT TDF_Label& GetEntry() { return _label; }
179
180   //Returns the type of the function
181   Standard_EXPORT int GetType();
182
183   //Returns a function Driver GUID
184   Standard_EXPORT Standard_GUID GetDriverGUID();
185
186   //Returns aPython description of the function
187   Standard_EXPORT TCollection_AsciiString GetDescription();
188
189   //Sets aPython description of the function
190   Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);
191
192   //Access to arguments
193
194   //Sets a real argument at position thePosition
195   Standard_EXPORT void SetReal(int thePosition, double theValue);
196
197   //Returns a real argument at position thePosition
198   Standard_EXPORT double GetReal(int thePosition);
199
200   //Sets a real array argument at position thePosition
201   Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
202
203   //Returns a real array argument at position thePosition
204   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
205
206   //Sets an integer argument at position thePosition
207   Standard_EXPORT void SetInteger(int thePosition, int theValue);
208
209   //Returns an integer argument at position thePosition
210   Standard_EXPORT int GetInteger(int thePosition);
211
212   //Sets an integer array argument at position thePosition
213   Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
214
215   //Returns an integer array argument at position thePosition
216   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
217
218   //Sets a reference to other function argument at position thePosition
219   Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
220
221   //Sets a string argument at position thePosition
222   Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
223
224   //Returns a string argument at position thePosition
225   Standard_EXPORT TCollection_AsciiString GetString(int thePosition);
226
227   //Returns a reference to other function argument at position thePosition
228   Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition);
229
230   //Set an array of ExtendedString
231   Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
232
233   //Returns the array of ExtendedString
234   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
235
236   //Returns a GUID for a references tree
237   Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
238
239   //Sets a list of references to other function arguments at position thePosition
240   Standard_EXPORT void SetReferenceList (int thePosition,
241                          const Handle(TColStd_HSequenceOfTransient)& theRefList);
242
243   //Returns a list of references to other function arguments at position thePosition
244   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition);
245
246   //Sets a TopoDS_Shape argument at position thePosition
247   //void SetShape(int thePosition, const TopoDS_Shape& theShape);
248
249   //Returns a TopoDS_Shape argument at position thePosition
250   //TopoDS_Shape GetShape(int thePosition);
251
252   //Returns true if the last method succided
253   Standard_EXPORT bool IsDone() { return _isDone; }
254
255   //Returns a sequence of the external dependencies of this function
256   Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
257
258   // Add/Remove/Check/Get subshape references
259   Standard_EXPORT void AddSubShapeReference   (Handle(GEOM_Function) theSubShape);
260   Standard_EXPORT void RemoveSubShapeReference(Handle(GEOM_Function) theSubShape);
261   Standard_EXPORT bool HasSubShapeReferences();
262   Standard_EXPORT const TDataStd_ListOfExtendedString& GetSubShapeReferences();
263
264   //Returns top label of this function's history tree
265   Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
266
267   //Returns history label, corresponding to the label,
268   //on which a reference on argument is stored
269   Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label&       theArgumentRefEntry,
270                                                      const Standard_Boolean create = Standard_True);
271
272   //Returns top label of this function's naming tree
273   Standard_EXPORT TDF_Label GetNamingEntry (const Standard_Boolean create = Standard_True);
274
275 private:
276
277   TDF_Label _label;
278   bool      _isDone;
279 };
280
281 #endif