1 // Copyright (C) 2007-2008 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
22 // File : SALOMEDS_GenericAttribute_i.cxx
23 // Author : Sergey RUIN
26 #include "utilities.h"
27 #include "SALOMEDS_GenericAttribute_i.hxx"
28 #include "SALOMEDS_Attributes.hxx"
29 #include "SALOMEDS.hxx"
30 #include "SALOMEDSImpl_SObject.hxx"
31 #include "SALOMEDSImpl_Study.hxx"
32 #include "Utils_ExceptHandlers.hxx"
33 #include "Basics_Utils.hxx"
39 #include <sys/types.h>
45 UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
47 SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, CORBA::ORB_ptr theOrb)
49 _orb = CORBA::ORB::_duplicate(theOrb);
53 void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection)
55 SALOMEDS::Locker lock;
56 Unexpect aCatch(GALockProtection);
58 if (_impl && !CORBA::is_nil(_orb)) {
60 SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(_impl);
63 throw SALOMEDS::GenericAttribute::LockProtection();
68 SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
70 SALOMEDS::Locker lock;
71 if (!_impl || _impl->Label().IsNull()) return SALOMEDS::SObject::_nil();
72 SALOMEDSImpl_SObject so_impl = SALOMEDSImpl_Study::SObject(_impl->Label());
73 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (so_impl, _orb);
78 char* SALOMEDS_GenericAttribute_i::Type()
80 SALOMEDS::Locker lock;
82 string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl);
83 return CORBA::string_dup(type.c_str());
89 char* SALOMEDS_GenericAttribute_i::GetClassType()
91 SALOMEDS::Locker lock;
93 string class_type = SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl);
94 return CORBA::string_dup(class_type.c_str());
101 SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute
102 (DF_Attribute* theAttr,
103 CORBA::ORB_ptr theOrb)
105 SALOMEDS::Locker lock;
107 string aClassType = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr)->GetClassType();
108 char* aTypeOfAttribute = (char*)aClassType.c_str();
109 SALOMEDS::GenericAttribute_var anAttribute;
110 SALOMEDS_GenericAttribute_i* attr_servant = NULL;
111 __CreateGenericCORBAAttribute
113 return anAttribute._retn();
116 //===========================================================================
118 //===========================================================================
119 CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
122 long pid = (long)_getpid();
124 long pid = (long)getpid();
126 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
127 return reinterpret_cast<CORBA::LongLong>(_impl);