]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEDS/SALOMEDS_GenericAttribute.cxx
Salome HOME
Copyrights update
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_GenericAttribute.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 //  File   : SALOMEDS_GenericAttribute.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25
26 #include <string>
27 #include <TCollection_AsciiString.hxx> 
28
29 #include "SALOMEDS_GenericAttribute.hxx"
30 #include "SALOMEDSImpl_SObject.hxx"
31 #include "SALOMEDS_SObject.hxx"
32 #include "SALOMEDS_ClientAttributes.hxx"
33
34 #ifdef WIN32
35 #include <process.h>
36 #else
37 #include <sys/types.h>
38 #include <unistd.h>
39 #endif
40
41 #include "OpUtil.hxx"
42
43 using namespace std; 
44
45 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
46 {
47   _isLocal = true;
48   _local_impl = theGA;
49   _corba_impl = SALOMEDS::GenericAttribute::_nil();
50 }
51
52 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA)
53 {
54 #ifdef WIN32
55   long pid =  (long)_getpid();
56 #else
57   long pid =  (long)getpid();
58 #endif  
59
60   long addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
61   if(_isLocal) {
62     _local_impl = ((SALOMEDSImpl_GenericAttribute*)(addr));
63     _corba_impl = SALOMEDS::GenericAttribute::_nil();
64   }
65   else {
66     _local_impl = NULL;
67     _corba_impl = SALOMEDS::GenericAttribute::_duplicate(theGA);
68   }
69 }
70
71 SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute() 
72 {
73   if (!_isLocal) {
74     _corba_impl->Destroy();
75   }
76 }
77
78 void SALOMEDS_GenericAttribute::CheckLocked() 
79 {
80   if(_isLocal) {
81     try {
82       _local_impl->CheckLocked();
83     }
84     catch(...) {
85       throw SALOMEDS::GenericAttribute::LockProtection();
86     }
87   }
88   else {
89     _corba_impl->CheckLocked();
90   }
91 }
92
93 std::string SALOMEDS_GenericAttribute::Type()
94 {
95   std::string aType;
96   if(_isLocal) {
97     aType = _local_impl->Type().ToCString();
98   }
99   else {
100     aType = _corba_impl->Type();
101   }
102   return aType;
103 }
104
105 std::string SALOMEDS_GenericAttribute::GetClassType()
106 {
107   std::string aType;
108   if(_isLocal) {
109     aType = _local_impl->GetClassType().ToCString();
110   }
111   else {
112     aType = _corba_impl->GetClassType();
113   }
114   return aType;
115 }
116
117 _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject()
118 {
119   SALOMEDSClient_SObject* aSO = NULL;
120   if(_isLocal) {
121     aSO = new SALOMEDS_SObject(_local_impl->GetSObject());
122   }
123   else {
124     aSO = new SALOMEDS_SObject(_corba_impl->GetSObject());
125   }
126
127   return _PTR(SObject)(aSO);
128 }
129
130
131 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
132 {
133   SALOMEDS_GenericAttribute* aGA = NULL;
134   std::string aTypeOfAttribute = theGA->GetClassType().ToCString();
135   __CreateGenericClientAttributeLocal
136   return aGA;  
137 }
138
139 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA)
140 {
141   SALOMEDS_GenericAttribute* aGA = NULL;
142   std::string aTypeOfAttribute = theGA->GetClassType();
143   __CreateGenericClientAttributeCORBA
144   return aGA;  
145 }
146