Salome HOME
00d5354a460fd2d064f2bb45e14811d221acc5dd
[modules/geom.git] / src / GEOM / GEOM_Object.hxx
1 #ifndef _GEOM_Object_HeaderFile
2 #define _GEOM_Object_HeaderFile
3
4 #ifndef _Standard_TypeMismatch_HeaderFile
5 #include <Standard_TypeMismatch.hxx>
6 #endif
7 #ifndef _Standard_HeaderFile
8 #include <Standard.hxx>
9 #endif
10 #ifndef _Standard_Macro_HeaderFile
11 #include <Standard_Macro.hxx>
12 #endif
13 #ifndef _Standard_HeaderFile
14 #include <Standard.hxx>
15 #endif
16 #ifndef _Handle_MMgt_TShared_HeaderFile
17 #include <Handle_MMgt_TShared.hxx>
18 #endif  
19 #ifndef _MMgt_TShared_HeaderFile
20 #include <MMgt_TShared.hxx>
21 #endif  
22 #ifndef _Standard_GUID_HeaderFile
23 #include <Standard_GUID.hxx>
24 #endif
25 #ifndef _TopoDS_Shape_HeaderFile
26 #include <TopoDS_Shape.hxx>
27 #endif
28 #ifndef _TDF_Label_HeaderFile
29 #include <TDF_Label.hxx>
30 #endif
31 #ifndef _TColStd_HSequenceOfTransient_HeaderFile
32 #include <TColStd_HSequenceOfTransient.hxx>
33 #endif
34 #ifndef _TCollection_AsciiString_HeaderFile
35 #include <TCollection_AsciiString.hxx>
36 #endif
37
38 class Handle_TColStd_HSequenceOfTransient;
39 class Standard_Transient;
40 class Handle_Standard_Type;
41 class Handle(MMgt_TShared);
42 class GEOM_Object;
43
44
45 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
46
47 class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
48   public:
49     inline void* operator new(size_t,void* anAddress) 
50       {
51         return anAddress;
52       }
53     inline void* operator new(size_t size) 
54       { 
55         return Standard::Allocate(size); 
56       }
57     inline void  operator delete(void *anAddress) 
58       { 
59         if (anAddress) Standard::Free((Standard_Address&)anAddress); 
60       }
61
62     Handle(GEOM_Object)():Handle(MMgt_TShared)() {} 
63     Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle) 
64      {
65      }
66
67     Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) 
68      {
69      }
70
71     Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
72      {
73       Assign(aHandle.Access());
74       return *this;
75      }
76
77     Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
78      {
79       Assign((Standard_Transient *)anItem);
80       return *this;
81      }
82
83     GEOM_Object* operator->() 
84      {
85       return (GEOM_Object *)ControlAccess();
86      }
87
88     GEOM_Object* operator->() const 
89      {
90       return (GEOM_Object *)ControlAccess();
91      }
92
93    Standard_EXPORT ~Handle(GEOM_Object)() {};
94  
95    Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
96 };
97
98
99
100 #include <Standard_GUID.hxx>
101 #include <TDataStd_TreeNode.hxx>
102 #include "GEOM_Function.hxx"
103 #include "GEOM_Engine.hxx"
104
105
106 class GEOM_Object : public MMgt_TShared
107 {
108  friend class GEOM_Engine;     
109
110  public:
111   inline void* operator new(size_t,void* anAddress) 
112     {
113       return anAddress;
114     }
115   inline void* operator new(size_t size) 
116     { 
117       return Standard::Allocate(size); 
118     }
119   inline void  operator delete(void *anAddress) 
120     { 
121       if (anAddress) Standard::Free((Standard_Address&)anAddress); 
122     }
123   
124   // Type management
125   //
126   Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
127   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Object) ; }
128   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); } 
129
130  private:
131    GEOM_Object(TDF_Label& theLabel);  
132
133  public:
134   Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType);
135   Standard_EXPORT ~GEOM_Object() {;}
136
137   //Finds a GEOM_Object on the label theLabel
138   Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel);
139
140   //Finds a GEOM_Object by a reference, stored on the label theLabel
141   Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
142
143   //Returns a GEOM_Object common GUID
144   Standard_EXPORT static const Standard_GUID& GetObjectID();
145
146   //Returns a GUID associated with a sub shape object
147   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
148
149   //###########################################################
150   //Access to properties 
151   //###########################################################
152
153   //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
154   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; } 
155   
156   //Returns a label of this GEOM_Object
157   Standard_EXPORT TDF_Label GetEntry() { return _label; }
158   
159   //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
160   Standard_EXPORT int GetType();      
161
162   //Sets the type of this GEOM_Object
163   Standard_EXPORT void SetType(int theType);
164   
165   //Returns an ID of the OCAF document where this GEOM_Object is stored
166   Standard_EXPORT int GetDocID(); 
167
168   //Returns a value (as TopoDS_Shape) of this GEOM_Object 
169   Standard_EXPORT TopoDS_Shape GetValue();
170
171   //Sets a name of this GEOM_Object
172   Standard_EXPORT void SetName(const char* theName);
173
174   //Returns a name of this GEOM_Object
175   Standard_EXPORT char* GetName();
176
177   //Sets an auxiliary data
178   Standard_EXPORT void SetAuxData(const char* theData);
179
180   //Returns an auxiliary data
181   Standard_EXPORT TCollection_AsciiString GetAuxData();
182
183   //###########################################################  
184   // Sub shape methods
185   //###########################################################
186   
187   //Returns false if the object is a sub shape of another object
188   Standard_EXPORT bool IsMainShape();
189
190  //###########################################################  
191  // CORBA related methods
192  //###########################################################
193  
194  //Sets an IOR of CORBA GEOM_Object_i which refers to this object
195  Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
196
197  //Returns an IOR of CORBA GEOM_Object_i which refers to this object
198  Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
199
200   //###########################################################
201   //Functions methods
202   //###########################################################
203
204   //Adds a function with a driver GUID = theGUID and a type theFunctionType to the function tree of this GEOM_Object
205   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
206   
207   //Returns a number of functions of this GEOM_Object
208   Standard_EXPORT int GetNbFunctions(); 
209   
210   //Returns a function with given number theFunctionNumber
211   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
212   
213   //Return the last function of this GEOM_Object
214   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
215
216   //Returns all dependencies of the object
217   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
218
219   //Returns the dependencies of the last function
220   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
221
222  //###########################################################  
223  // Internal methods
224  //###########################################################
225
226  //Returns a label which could be used to store some additional data
227  Standard_EXPORT TDF_Label GetFreeLabel();
228  
229
230  private:
231
232   Handle(TDataStd_TreeNode) _root;
233   TDF_Label    _label;
234   TCollection_AsciiString _ior;
235 };
236
237 #endif