1 // Copyright (C) 2007-2023 CEA, EDF, 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, or (at your option) any later version.
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_Study_i.hxx"
30 #include "SALOMEDS_Attributes.hxx"
31 #include "SALOMEDS.hxx"
32 #include "SALOMEDSImpl_SObject.hxx"
33 #include "SALOMEDSImpl_Study.hxx"
34 #include "Utils_ExceptHandlers.hxx"
35 #include "Basics_Utils.hxx"
41 #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) :
48 GenericObj_i(SALOMEDS_Study_i::GetThePOA())
50 _orb = CORBA::ORB::_duplicate(theOrb);
54 SALOMEDS_GenericAttribute_i::~SALOMEDS_GenericAttribute_i()
58 //============================================================================
60 \brief Get default POA for the servant object.
62 This function is implicitly called from "_this()" function.
63 Default POA can be set via the constructor.
65 \return reference to the default POA for the servant
67 //============================================================================
68 PortableServer::POA_ptr SALOMEDS_GenericAttribute_i::_default_POA()
70 myPOA = PortableServer::POA::_duplicate(SALOMEDS_Study_i::GetThePOA());
71 //MESSAGE("SALOMEDS_GenericAttribute_i::_default_POA: " << myPOA);
72 return PortableServer::POA::_duplicate(myPOA);
75 void SALOMEDS_GenericAttribute_i::CheckLocked()
77 SALOMEDS::Locker lock;
78 Unexpect aCatch(GALockProtection);
80 if (_impl && !CORBA::is_nil(_orb)) {
82 SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(_impl);
85 throw SALOMEDS::GenericAttribute::LockProtection();
90 SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
92 SALOMEDS::Locker lock;
93 if (!_impl || _impl->Label().IsNull()) return SALOMEDS::SObject::_nil();
94 SALOMEDSImpl_SObject so_impl = SALOMEDSImpl_Study::SObject(_impl->Label());
95 SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (so_impl, _orb);
100 char* SALOMEDS_GenericAttribute_i::Type()
102 SALOMEDS::Locker lock;
104 std::string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl);
105 return CORBA::string_dup(type.c_str());
108 return CORBA::string_dup("");
111 char* SALOMEDS_GenericAttribute_i::GetClassType()
113 SALOMEDS::Locker lock;
115 std::string class_type = SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl);
116 return CORBA::string_dup(class_type.c_str());
119 return CORBA::string_dup("");
123 SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute
124 (DF_Attribute* theAttr,
125 CORBA::ORB_ptr theOrb)
127 SALOMEDS::Locker lock;
129 std::string aClassType = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr)->GetClassType();
130 char* aTypeOfAttribute = (char*)aClassType.c_str();
131 SALOMEDS::GenericAttribute_var anAttribute;
132 SALOMEDS_GenericAttribute_i* attr_servant = NULL;
133 SALOME_UNUSED(attr_servant);
134 __CreateGenericCORBAAttribute
136 return anAttribute._retn();
139 //===========================================================================
141 //===========================================================================
142 CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
145 long pid = (long)_getpid();
147 long pid = (long)getpid();
149 isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
150 return reinterpret_cast<CORBA::LongLong>(_impl);