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