Salome HOME
4cd9fe3ff974c525aec31c18ebcecc626f7240ce
[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
23 #ifndef _GEOM_Function_HeaderFile
24 #define _GEOM_Function_HeaderFile
25
26 #ifndef _Standard_TypeMismatch_HeaderFile
27 #include <Standard_TypeMismatch.hxx>
28 #endif
29 #ifndef _Standard_HeaderFile
30 #include <Standard.hxx>
31 #endif
32 #ifndef _Standard_Macro_HeaderFile
33 #include <Standard_Macro.hxx>
34 #endif
35 #ifndef _Handle_MMgt_TShared_HeaderFile
36 #include <Handle_MMgt_TShared.hxx>
37 #endif  
38 #ifndef _MMgt_TShared_HeaderFile
39 #include <MMgt_TShared.hxx>
40 #endif  
41 #ifndef _Standard_GUID_HeaderFile
42 #include <Standard_GUID.hxx>
43 #endif
44 #ifndef _TopoDS_Shape_HeaderFile
45 #include <TopoDS_Shape.hxx>
46 #endif
47 #ifndef _TDF_Label_HeaderFile
48 #include <TDF_Label.hxx>
49 #endif
50 #ifndef _TDF_LabelSequence_HeaderFile
51 #include <TDF_LabelSequence.hxx>
52 #endif
53 #ifndef _TColStd_HArray1OfExtendedString_HeaderFile
54 #include <TColStd_HArray1OfExtendedString.hxx>
55 #endif
56
57 class Handle_TColStd_HArray1OfReal;
58 class Handle_TColStd_HArray1OfInteger;
59 class Handle_TColStd_HSequenceOfTransient;
60 class Handle_TColStd_HArray1OfExtendedString;
61
62 class Standard_Transient;
63 class Handle_Standard_Type;
64 class Handle(MMgt_TShared);
65 class GEOM_Function;
66
67 #include <TCollection_AsciiString.hxx>
68
69
70 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Function);
71
72 class Handle(GEOM_Function) : public Handle(MMgt_TShared) {
73   public:
74     inline void* operator new(size_t,void* anAddress) 
75       {
76         return anAddress;
77       }
78     inline void* operator new(size_t size) 
79       { 
80         return Standard::Allocate(size); 
81       }
82     inline void  operator delete(void *anAddress) 
83       { 
84         if (anAddress) Standard::Free((Standard_Address&)anAddress); 
85       }
86
87     Handle(GEOM_Function)():Handle(MMgt_TShared)() {} 
88     Handle(GEOM_Function)(const Handle(GEOM_Function)& aHandle) : Handle(MMgt_TShared)(aHandle) 
89      {
90      }
91
92     Handle(GEOM_Function)(const GEOM_Function* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) 
93      {
94      }
95
96     Handle(GEOM_Function)& operator=(const Handle(GEOM_Function)& aHandle)
97      {
98       Assign(aHandle.Access());
99       return *this;
100      }
101
102     Handle(GEOM_Function)& operator=(const GEOM_Function* anItem)
103      {
104       Assign((Standard_Transient *)anItem);
105       return *this;
106      }
107
108     GEOM_Function* operator->() 
109      {
110       return (GEOM_Function *)ControlAccess();
111      }
112
113     GEOM_Function* operator->() const 
114      {
115       return (GEOM_Function *)ControlAccess();
116      }
117
118    Standard_EXPORT ~Handle(GEOM_Function)() {};
119  
120    Standard_EXPORT static const Handle(GEOM_Function) DownCast(const Handle(Standard_Transient)& AnObject);
121 };
122
123 class GEOM_Function : public MMgt_TShared
124 {
125
126 public:
127
128     inline void* operator new(size_t,void* anAddress) 
129       {
130         return anAddress;
131       }
132     inline void* operator new(size_t size) 
133       { 
134         return Standard::Allocate(size); 
135       }
136     inline void  operator delete(void *anAddress) 
137       { 
138         if (anAddress) Standard::Free((Standard_Address&)anAddress); 
139       }
140
141     // Type management
142     //
143     Standard_EXPORT friend Handle_Standard_Type& GEOM_Function_Type_();
144     Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Function) ; }
145     Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_Function) == AType || MMgt_TShared::IsKind(AType)); } 
146
147
148 private:
149   GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; }
150
151 public:
152
153   //Returns a GUID for a function tree  
154   Standard_EXPORT static const Standard_GUID& GetFunctionTreeID();
155
156   //Returns the ID which is associated with a reference to another function  
157   Standard_EXPORT static const Standard_GUID& GetDependencyID();
158
159   //Finds and returns a function located on a label theEntry
160   Standard_EXPORT static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry);
161
162
163   Standard_EXPORT GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType); 
164   Standard_EXPORT ~GEOM_Function() {;}
165
166   Standard_EXPORT TDF_Label GetOwnerEntry();
167
168   //Access to properties 
169
170   //Returns a result of the function built by the function Driver
171   Standard_EXPORT TopoDS_Shape GetValue();
172
173   //Sets the function result
174   Standard_EXPORT void SetValue(TopoDS_Shape& theShape);
175
176   //Returns a function entry in the OCAF document
177   Standard_EXPORT TDF_Label& GetEntry() { return _label; }
178
179   //Returns the type of the function
180   Standard_EXPORT int GetType();    
181
182   //Returns a function Driver GUID
183   Standard_EXPORT Standard_GUID GetDriverGUID();
184
185   //Returns aPython description of the function
186   Standard_EXPORT TCollection_AsciiString GetDescription();
187
188   //Sets aPython description of the function  
189   Standard_EXPORT void SetDescription(const TCollection_AsciiString& theDescription);  
190
191   //Access to arguments
192
193   //Sets a real argument at position thePosition
194   Standard_EXPORT void SetReal(int thePosition, double theValue);
195
196   //Returns a real argument at position thePosition
197   Standard_EXPORT double GetReal(int thePosition);
198
199   //Sets a real array argument at position thePosition
200   Standard_EXPORT void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray);
201
202   //Returns a real array argument at position thePosition
203   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition);
204
205   //Sets an integer argument at position thePosition
206   Standard_EXPORT void SetInteger(int thePosition, int theValue);
207
208   //Returns an integer argument at position thePosition
209   Standard_EXPORT int GetInteger(int thePosition);  
210   
211   //Sets an integer array argument at position thePosition
212   Standard_EXPORT void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray);
213
214   //Returns an integer array argument at position thePosition
215   Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition);
216
217   //Sets a reference to other function argument at position thePosition
218   Standard_EXPORT void SetReference(int thePosition, Handle(GEOM_Function) theReference);
219
220   //Sets a string argument at position thePosition
221   Standard_EXPORT void SetString(int thePosition, const TCollection_AsciiString& theValue);
222
223   //Returns a string argument at position thePosition
224   Standard_EXPORT TCollection_AsciiString GetString(int thePosition);  
225   
226   //Returns a reference to other function argument at position thePosition
227   Standard_EXPORT Handle(GEOM_Function) GetReference(int thePosition); 
228
229   //Set an array of ExtendedString
230   Standard_EXPORT void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray);
231     
232   //Returns the array of ExtendedString
233   Standard_EXPORT Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition);
234
235   //Returns a GUID for a references tree  
236   Standard_EXPORT static const Standard_GUID& GetReferencesTreeID();
237
238   //Sets a list of references to other function arguments at position thePosition
239   Standard_EXPORT void SetReferenceList (int thePosition,
240                          const Handle(TColStd_HSequenceOfTransient)& theRefList);
241
242   //Returns a list of references to other function arguments at position thePosition
243   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition); 
244
245   //Sets a TopoDS_Shape argument at position thePosition
246   //void SetShape(int thePosition, const TopoDS_Shape& theShape);
247     
248   //Returns a TopoDS_Shape argument at position thePosition
249   //TopoDS_Shape GetShape(int thePosition);  
250   
251   //Returns true if the last method succided 
252   Standard_EXPORT bool IsDone() { return _isDone; }
253
254   //Returns a sequence of the external dependencies of this function
255   Standard_EXPORT void GetDependency(TDF_LabelSequence& theSeq);
256
257   //Returns top label of this function's history tree
258   Standard_EXPORT TDF_Label GetHistoryEntry (const Standard_Boolean create = Standard_True);
259
260   //Returns history label, corresponding to the label,
261   //on which a reference on argument is stored
262   Standard_EXPORT TDF_Label GetArgumentHistoryEntry (const TDF_Label&       theArgumentRefEntry,
263                                      const Standard_Boolean create = Standard_True);
264
265 private:
266
267   
268   TDF_Label    _label;
269   bool _isDone;
270 };
271
272 #endif