Salome HOME
Merge branch 'master' into agr/start_procedure
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributePythonObject.cxx
index 4a3561fb34c88b3952522c499b68d752a879922f..1fbdb157167d115b2ff338783c5b83c1edccf019 100644 (file)
@@ -1,14 +1,35 @@
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 //  File   : SALOMEDS_AttributePythonObject.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
+//
 #include "SALOMEDS_AttributePythonObject.hxx"
+#include "SALOMEDS.hxx"
 
 #include <string>
-#include <TCollection_AsciiString.hxx> 
-#include <TCollection_ExtendedString.hxx>
 
-SALOMEDS_AttributePythonObject::SALOMEDS_AttributePythonObject(const Handle(SALOMEDSImpl_AttributePythonObject)& theAttr)
+SALOMEDS_AttributePythonObject::SALOMEDS_AttributePythonObject(SALOMEDSImpl_AttributePythonObject* theAttr)
 :SALOMEDS_GenericAttribute(theAttr)
 {}
 
@@ -22,7 +43,10 @@ SALOMEDS_AttributePythonObject::~SALOMEDS_AttributePythonObject()
 bool SALOMEDS_AttributePythonObject::IsScript()
 {
   bool ret;
-  if(_isLocal) ret = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->IsScript();
+  if (_isLocal) {
+    SALOMEDS::Locker lock;
+    ret = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(_local_impl)->IsScript();
+  }
   else ret = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->IsScript();
   return ret;
 }
@@ -30,15 +54,20 @@ bool SALOMEDS_AttributePythonObject::IsScript()
 std::string SALOMEDS_AttributePythonObject::GetObject()
 {
   std::string aValue;
-  if(_isLocal) 
-    aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->GetObject()).ToCString();
+  if (_isLocal) {
+    SALOMEDS::Locker lock;
+    aValue = dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(_local_impl)->GetObject().c_str();
+  }
   else aValue = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->GetObject();
   return aValue;
 }
+
 void SALOMEDS_AttributePythonObject::SetObject(const std::string& theSequence, bool IsScript)
 {
-  CheckLocked();
-  if(_isLocal) Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->SetObject((char*)theSequence.c_str(), IsScript);
+  if (_isLocal) {
+    CheckLocked();
+    SALOMEDS::Locker lock;
+    dynamic_cast<SALOMEDSImpl_AttributePythonObject*>(_local_impl)->SetObject(theSequence, IsScript);
+  }
   else SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->SetObject(theSequence.c_str(), IsScript);
 }