Salome HOME
d7562acf75dc68096bb94f1798d8cfdca2be1c55
[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 // IDL headers
41 #include <SALOMEconfig.h>
42 #include CORBA_SERVER_HEADER(SALOMEDS)
43
44 class SALOMEDS_Study_i;
45 class SALOMEDS_GenericAttribute_i;
46
47
48 namespace SALOMEDS
49 {
50   const char* Str(const TCollection_ExtendedString& theString);
51
52   std::string GetType(const Handle(TDF_Attribute)& theAttr);
53
54   Standard_GUID GetGUID(const char* theType);
55
56 }
57
58
59 class SALOMEDS_SObject_i: public virtual POA_SALOMEDS::SObject,
60                           public virtual PortableServer::RefCountServantBase 
61 {
62 public:
63   static SALOMEDS_SObject_i* New(SALOMEDS_Study_i* theStudy,
64                                  const TDF_Label& theLabel);
65
66   virtual SALOMEDS::SObject_ptr GetFather() ;
67   virtual SALOMEDS::SComponent_ptr GetFatherComponent();
68   virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out theSObject);
69   virtual CORBA::Boolean FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject);
70
71   virtual SALOMEDS::Study_ptr GetStudy();
72   virtual SALOMEDS::ListOfAttributes* GetAllAttributes();
73
74   virtual CORBA::Object_ptr GetObject();
75
76   virtual char* GetID();
77   virtual CORBA::Short Tag();
78   virtual CORBA::Short Depth();
79
80   virtual char* Name();
81   virtual void Name(const char* theName);
82
83   virtual char* GetName();
84   virtual char* GetComment();
85   virtual char* GetIOR();
86
87   CORBA::Boolean 
88   FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
89                 const char* theTypeOfAttribute);
90   
91   SALOMEDS::GenericAttribute_ptr 
92   FindOrCreateAttribute(const char* theTypeOfAttribute);
93
94   void RemoveAttribute(const char* theTypeOfAttribute);
95
96   SALOMEDS_Study_i* GetStudyServant(){ return _study;}
97
98   CORBA::ORB_var GetORB() const;
99
100   PortableServer::POA_var GetPOA() const;
101   
102 protected:
103   friend class SALOMEDS_GenericAttribute_i;
104
105   SALOMEDS_GenericAttribute_i* 
106   _FindGenAttribute(const Handle(TDF_Attribute)& theAttr);
107
108   SALOMEDS_GenericAttribute_i* 
109   _CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
110                       const char* theTypeOfAttribute);
111
112   SALOMEDS_GenericAttribute_i* 
113   _FindGenAttribute(const char* theTypeOfAttribute);
114
115   SALOMEDS::GenericAttribute_ptr 
116   _FindCORBAAttribute(const char* theTypeOfAttribute);
117
118   Handle(TDF_Attribute) 
119     _AddAttribute(const char* theTypeOfAttribute);
120
121   SALOMEDS_Study_i* _study;
122   std::string _name;
123   TDF_Label _lab;
124
125   typedef std::string TAttributeID;
126   typedef SALOMEDS_GenericAttribute_i* TAttrHolder;
127   typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
128   TAttrMap myAttrMap;
129
130   SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy, 
131                      const TDF_Label& theLabel);
132   
133   ~SALOMEDS_SObject_i();
134
135 private:
136   SALOMEDS_SObject_i(); // Not implemented
137   void operator=(const SALOMEDS_SObject_i&); // Not implemented
138
139 };
140
141
142 #endif