1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_GenericAttribute.cxx
24 // Author : Sergey RUIN
29 #include "SALOMEDS_GenericAttribute.hxx"
30 #include "SALOMEDSImpl_SObject.hxx"
31 #include "SALOMEDS_SObject.hxx"
32 #include "SALOMEDS_ClientAttributes.hxx"
33 #include "SALOMEDS.hxx"
35 #include "Basics_Utils.hxx"
40 #include <sys/types.h>
44 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDSImpl_GenericAttribute* theGA)
48 _corba_impl = SALOMEDS::GenericAttribute::_nil();
51 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA)
54 long pid = (long)_getpid();
56 long pid = (long)getpid();
59 CORBA::LongLong addr = theGA->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
61 _local_impl = reinterpret_cast<SALOMEDSImpl_GenericAttribute*>(addr);
62 _corba_impl = SALOMEDS::GenericAttribute::_nil();
66 _corba_impl = SALOMEDS::GenericAttribute::_duplicate(theGA);
70 SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute()
73 _corba_impl->UnRegister();
77 void SALOMEDS_GenericAttribute::CheckLocked()
80 SALOMEDS::Locker lock;
82 _local_impl->CheckLocked();
85 throw SALOMEDS::GenericAttribute::LockProtection();
89 _corba_impl->CheckLocked();
93 std::string SALOMEDS_GenericAttribute::Type()
97 SALOMEDS::Locker lock;
98 aType = _local_impl->Type();
101 aType = (CORBA::String_var)_corba_impl->Type();
106 std::string SALOMEDS_GenericAttribute::GetClassType()
110 SALOMEDS::Locker lock;
111 aType = _local_impl->GetClassType();
114 aType = (CORBA::String_var)_corba_impl->GetClassType();
119 _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject()
121 SALOMEDSClient_SObject* aSO = NULL;
123 SALOMEDS::Locker lock;
124 aSO = new SALOMEDS_SObject(_local_impl->GetSObject());
127 aSO = new SALOMEDS_SObject((SALOMEDS::SObject_var)_corba_impl->GetSObject());
130 return _PTR(SObject)(aSO);
134 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDSImpl_GenericAttribute* theGA)
136 SALOMEDS::Locker lock;
138 SALOMEDS_GenericAttribute* aGA = NULL;
140 std::string aTypeOfAttribute = theGA->GetClassType();
141 __CreateGenericClientAttributeLocal
146 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA)
148 SALOMEDS_GenericAttribute* aGA = NULL;
149 if(!CORBA::is_nil(theGA)) {
150 CORBA::String_var astr=theGA->GetClassType();
151 std::string aTypeOfAttribute = astr.in();
152 __CreateGenericClientAttributeCORBA