Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SObject_i.hxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_SObject_i.hxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef __SALOMEDS_SOBJECT_I_H__
30 #define __SALOMEDS_SOBJECT_I_H__
31
32 #include <map>
33 #include <string>
34
35 // Cascade headers
36 #include <TDF_Label.hxx>
37 #include <TDocStd_Document.hxx>
38 #include <Standard_GUID.hxx>
39
40 #include "SALOMEDS_Study_i.hxx"
41
42 // IDL headers
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SALOMEDS)
45
46 class SALOMEDS_GenericAttribute_i;
47
48
49 namespace SALOMEDS
50 {
51   const char* Str(const TCollection_ExtendedString& theString);
52
53   std::string GetType(const Handle(TDF_Attribute)& theAttr);
54
55   Standard_GUID GetGUID(const char* theType);
56
57 }
58
59
60 class SALOMEDS_SObject_i: public virtual POA_SALOMEDS::SObject,
61                           public virtual PortableServer::RefCountServantBase 
62 {
63 public:
64   static 
65   SALOMEDS_Study_i::TSObjectHolder 
66   New(SALOMEDS_Study_i* theStudy,
67       const TDF_Label& theLabel);
68
69   static 
70   SALOMEDS_SObject_i* 
71   NewPtr(SALOMEDS_Study_i* theStudy,
72          const TDF_Label& theLabel);
73
74   static 
75   SALOMEDS::SObject_var 
76   NewRef(SALOMEDS_Study_i* theStudy,
77          const TDF_Label& theLabel);
78
79   virtual SALOMEDS::SObject_ptr GetFather() ;
80   virtual SALOMEDS::SComponent_ptr GetFatherComponent();
81   virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out theSObject);
82   virtual CORBA::Boolean FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject);
83
84   virtual SALOMEDS::Study_ptr GetStudy();
85   virtual SALOMEDS::ListOfAttributes* GetAllAttributes();
86
87   virtual CORBA::Object_ptr GetObject();
88
89   virtual char* GetID();
90   virtual CORBA::Short Tag();
91   virtual CORBA::Short Depth();
92
93   virtual char* Name();
94   virtual void Name(const char* theName);
95
96   virtual char* GetName();
97   virtual char* GetComment();
98   virtual char* GetIOR();
99
100   CORBA::Boolean 
101   FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
102                 const char* theTypeOfAttribute);
103   
104   SALOMEDS::GenericAttribute_ptr 
105   FindOrCreateAttribute(const char* theTypeOfAttribute);
106
107   void RemoveAttribute(const char* theTypeOfAttribute);
108   void OnRemove();
109
110   SALOMEDS_Study_i* GetStudyServant(){ return _study;}
111
112   TDF_Label GetLabel(){ return _lab;}
113   TDF_Label GetFatherLabel(){ return _lab.Father();}
114   TDF_Label GetFatherComponentLabel();
115
116   CORBA::ORB_var GetORB() const;
117
118   PortableServer::POA_var GetPOA() const;
119   
120 protected:
121   friend class SALOMEDS_GenericAttribute_i;
122
123   typedef std::string TAttributeID;
124   typedef std::pair<SALOMEDS_GenericAttribute_i*,SALOMEDS::GenericAttribute_var> TAttrHolder;
125   typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
126   TAttrMap myAttrMap;
127
128   TAttrHolder 
129   _FindGenAttribute(const Handle(TDF_Attribute)& theAttr);
130
131   TAttrHolder 
132   _CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
133                       const char* theTypeOfAttribute);
134
135   TAttrHolder 
136   _FindGenAttribute(const char* theTypeOfAttribute);
137
138   Handle(TDF_Attribute) 
139     _AddAttribute(const char* theTypeOfAttribute);
140
141   SALOMEDS_Study_i* _study;
142   std::string _name;
143   TDF_Label _lab;
144
145   SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy, 
146                      const TDF_Label& theLabel);
147   
148   ~SALOMEDS_SObject_i();
149
150 private:
151   SALOMEDS_SObject_i(); // Not implemented
152   void operator=(const SALOMEDS_SObject_i&); // Not implemented
153
154 };
155
156
157 #endif