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