Salome HOME
0020523: String notebook support
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributePythonObject.cxx
index 71990e4db97ca5287ac73ee138ea2d6a2a37e0fa..e6b49f0ab4ba77b8ed65a6e095099c37a8559169 100644 (file)
@@ -1,33 +1,34 @@
-// Copyright (C) 2005  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.
-// 
-// 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.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/
+//  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.
+//
+//  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)
 {}
 
@@ -41,7 +42,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;
 }
@@ -49,15 +53,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);
 }