1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/
20 // File : SALOMEDS_GenericAttribute.cxx
21 // Author : Sergey RUIN
27 #include <TCollection_AsciiString.hxx>
29 #include "SALOMEDS_GenericAttribute.hxx"
30 #include "SALOMEDSImpl_SObject.hxx"
31 #include "SALOMEDS_SObject.hxx"
32 #include "SALOMEDS_ClientAttributes.hxx"
33 #include "SALOMEDS.hxx"
38 #include <sys/types.h>
46 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
50 _corba_impl = SALOMEDS::GenericAttribute::_nil();
53 SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ptr theGA)
56 long pid = (long)_getpid();
58 long pid = (long)getpid();
61 long addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
63 _local_impl = ((SALOMEDSImpl_GenericAttribute*)(addr));
64 _corba_impl = SALOMEDS::GenericAttribute::_nil();
68 _corba_impl = SALOMEDS::GenericAttribute::_duplicate(theGA);
72 SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute()
75 _corba_impl->Destroy();
79 void SALOMEDS_GenericAttribute::CheckLocked()
82 SALOMEDS::Locker lock;
84 _local_impl->CheckLocked();
87 throw SALOMEDS::GenericAttribute::LockProtection();
91 _corba_impl->CheckLocked();
95 std::string SALOMEDS_GenericAttribute::Type()
99 SALOMEDS::Locker lock;
100 aType = _local_impl->Type().ToCString();
103 aType = _corba_impl->Type();
108 std::string SALOMEDS_GenericAttribute::GetClassType()
112 SALOMEDS::Locker lock;
113 aType = _local_impl->GetClassType().ToCString();
116 aType = _corba_impl->GetClassType();
121 _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject()
123 SALOMEDSClient_SObject* aSO = NULL;
125 SALOMEDS::Locker lock;
126 aSO = new SALOMEDS_SObject(_local_impl->GetSObject());
129 aSO = new SALOMEDS_SObject(_corba_impl->GetSObject());
132 return _PTR(SObject)(aSO);
136 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute
137 (const Handle(SALOMEDSImpl_GenericAttribute)& theGA)
139 SALOMEDS::Locker lock;
141 SALOMEDS_GenericAttribute* aGA = NULL;
142 std::string aTypeOfAttribute = theGA->GetClassType().ToCString();
143 __CreateGenericClientAttributeLocal
147 SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA)
149 SALOMEDS_GenericAttribute* aGA = NULL;
150 std::string aTypeOfAttribute = theGA->GetClassType();
151 __CreateGenericClientAttributeCORBA