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_i.cxx
24 // Author : Sergey RUIN
27 #include "utilities.h"
28 #include "SALOMEDS_GenericAttribute_i.hxx"
29 #include "SALOMEDS_Attributes.hxx"
30 #include "SALOMEDS.hxx"
31 #include "SALOMEDSImpl_SObject.hxx"
32 #include "SALOMEDSImpl_Study.hxx"
33 #include "Utils_ExceptHandlers.hxx"
34 #include "Basics_Utils.hxx"
40 #include <sys/types.h>
44 UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
46 SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(DF_Attribute* theImpl, CORBA::ORB_ptr theOrb)
48 _orb = CORBA::ORB::_duplicate(theOrb);
52 SALOMEDS_GenericAttribute_i::~SALOMEDS_GenericAttribute_i()
56 void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection)
58 SALOMEDS::Locker lock;
59 Unexpect aCatch(GALockProtection);
61 if (_impl && !CORBA::is_nil(_orb)) {
63 SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(_impl);
66 throw SALOMEDS::GenericAttribute::LockProtection();
71 SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
73 SALOMEDS::Locker lock;
74 if (!_impl || _impl->Label().IsNull()) return SALOMEDS::SObject::_nil();
75 SALOMEDSImpl_SObject so_impl = SALOMEDSImpl_Study::SObject(_impl->Label());
76 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (so_impl, _orb);
81 char* SALOMEDS_GenericAttribute_i::Type()
83 SALOMEDS::Locker lock;
85 std::string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl);
86 return CORBA::string_dup(type.c_str());
89 return CORBA::string_dup("");
92 char* SALOMEDS_GenericAttribute_i::GetClassType()
94 SALOMEDS::Locker lock;
96 std::string class_type = SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl);
97 return CORBA::string_dup(class_type.c_str());
100 return CORBA::string_dup("");
104 SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute
105 (DF_Attribute* theAttr,
106 CORBA::ORB_ptr theOrb)
108 SALOMEDS::Locker lock;
110 std::string aClassType = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr)->GetClassType();
111 char* aTypeOfAttribute = (char*)aClassType.c_str();
112 SALOMEDS::GenericAttribute_var anAttribute;
113 SALOMEDS_GenericAttribute_i* attr_servant = NULL;
114 __CreateGenericCORBAAttribute
116 return anAttribute._retn();
119 //===========================================================================
121 //===========================================================================
122 CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
125 long pid = (long)_getpid();
127 long pid = (long)getpid();
129 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
130 return reinterpret_cast<CORBA::LongLong>(_impl);