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/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_GenericAttribute_i.cxx
21 // Author : Sergey RUIN
25 #include "utilities.h"
26 #include "SALOMEDS_GenericAttribute_i.hxx"
27 #include "SALOMEDS_Attributes.hxx"
28 #include "SALOMEDS.hxx"
29 #include "SALOMEDSImpl_SObject.hxx"
30 #include "SALOMEDSImpl_Study.hxx"
31 #include "Utils_ExceptHandlers.hxx"
37 #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 return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl));
88 char* SALOMEDS_GenericAttribute_i::GetClassType()
90 SALOMEDS::Locker lock;
92 return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl));
99 SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute
100 (DF_Attribute* theAttr,
101 CORBA::ORB_ptr theOrb)
103 SALOMEDS::Locker lock;
105 string aClassType = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr)->GetClassType();
106 char* aTypeOfAttribute = (char*)aClassType.c_str();
107 SALOMEDS::GenericAttribute_var anAttribute;
108 SALOMEDS_GenericAttribute_i* attr_servant = NULL;
109 __CreateGenericCORBAAttribute
111 return anAttribute._retn();
114 //===========================================================================
116 //===========================================================================
117 CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
120 long pid = (long)_getpid();
122 long pid = (long)getpid();
124 isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
125 return ((CORBA::LongLong)_impl);