From: san Date: Mon, 28 Feb 2005 15:18:52 +0000 (+0000) Subject: PAL8065 X-Git-Tag: V2_2_1rc~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4503035303c037c22e44c89752ae245966a9cb83;p=modules%2Fkernel.git PAL8065 --- diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 5a4adbf4e..fd05d197c 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -42,6 +42,7 @@ EXPORT_HEADERS= \ LIB = libSalomeDS.la LIB_SRC = \ + SALOMEDS.cxx \ SALOMEDS_StudyManager_i.cxx \ SALOMEDS_UseCaseBuilder_i.cxx \ SALOMEDS_UseCaseIterator_i.cxx \ diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx new file mode 100644 index 000000000..1cebce2ed --- /dev/null +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -0,0 +1,53 @@ +// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDS.cxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + + +#include + +using namespace SALOMEDS; + +// PAL8065: san -- Global recursive mutex for SALOMEDS methods +Utils_Mutex Locker::MutexDS; + +// PAL8065: san -- Global SALOMEDS locker +Locker::Locker() +: Utils_Locker( &MutexDS ) +{} + +Locker::~Locker() +{} + +void SALOMEDS::lock() +{ + Locker::MutexDS.lock(); +} + +void SALOMEDS::unlock() +{ + Locker::MutexDS.unlock(); +} diff --git a/src/SALOMEDS/SALOMEDS.hxx b/src/SALOMEDS/SALOMEDS.hxx new file mode 100644 index 000000000..06ee1825e --- /dev/null +++ b/src/SALOMEDS/SALOMEDS.hxx @@ -0,0 +1,67 @@ +// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDS.hxx +// Author : Sergey ANIKIN +// Module : SALOME +// $Header$ + + +#ifndef SALOMEDS_HeaderFile +#define SALOMEDS_HeaderFile + +#include + +namespace SALOMEDS +{ + // PAL8065: san -- Implementation of convenient locker based on simple recursive + // mutex for POSIX platforms. + // This class is to protect SALOMEDS CORBA methods which deal with OCC calls from + // parallel access by several threads + // To protect some method, an instance of Locker class should be created + // on the stack at the beginning of guarded code: + // + // Locker lock; + // + class Locker : public Utils_Locker + { + public: + Locker(); + virtual ~Locker(); + + private: + static Utils_Mutex MutexDS; + + friend void lock(); + friend void unlock(); + }; + + // Convenient functions to lock/unlock the global SALOMEDS mutex temporarily. + // In particular, "unlock-dosomething-lock" scheme should be used, when some non-SALOMEDS + // CORBA interface is called (component's engine), to avoid deadlocks in case of + // indirect recursion. + void lock(); + void unlock(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx index d84186658..0719f3337 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx @@ -30,11 +30,14 @@ #include #include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS.hxx" using namespace std; char* SALOMEDS_AttributeComment_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(TDataStd_Comment)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -42,15 +45,21 @@ char* SALOMEDS_AttributeComment_i::Value() void SALOMEDS_AttributeComment_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } char* SALOMEDS_AttributeComment_i::Store() { + SALOMEDS::Locker lock; + return Value(); } void SALOMEDS_AttributeComment_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx index 26f657821..3a9f5f1d5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -27,14 +27,19 @@ // $Header$ #include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() { + SALOMEDS::Locker lock; + return (Handle(SALOMEDS_DrawableAttribute)::DownCast(_myAttr)->Get() == 1); } void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { + SALOMEDS::Locker lock; + CheckLocked(); Standard_Integer val = 0; if (value != 0) val = 1; @@ -42,9 +47,13 @@ void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { } char* SALOMEDS_AttributeDrawable_i::Store() { + SALOMEDS::Locker lock; + return CORBA::string_dup(IsDrawable()?"1":"0"); } void SALOMEDS_AttributeDrawable_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetDrawable(value[0] == '1'); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx index 70601d33f..4487afc14 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -27,23 +27,32 @@ // $Header$ #include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() { + SALOMEDS::Locker lock; + return (Handle(SALOMEDS_ExpandableAttribute)::DownCast(_myAttr)->Get() == 1); } void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) { + SALOMEDS::Locker lock; + Standard_Integer val = 0; if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } char* SALOMEDS_AttributeExpandable_i::Store() { + SALOMEDS::Locker lock; + return CORBA::string_dup(IsExpandable()?"1":"0"); } void SALOMEDS_AttributeExpandable_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetExpandable(value[0] == '1'); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx index 9c60c8886..1dd93ea10 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SALOMEDS_AttributeExternalFileDef_i.hxx" +#include "SALOMEDS.hxx" #include #include @@ -35,6 +36,8 @@ using namespace std; char* SALOMEDS_AttributeExternalFileDef_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_ExternalFileDef)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -42,6 +45,8 @@ char* SALOMEDS_AttributeExternalFileDef_i::Value() void SALOMEDS_AttributeExternalFileDef_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); // Handle(SALOMEDS_ExternalFileDef)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); diff --git a/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx index b6237f309..c41320e90 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx @@ -27,6 +27,8 @@ // $Header$ #include "SALOMEDS_AttributeFileType_i.hxx" +#include "SALOMEDS.hxx" + #include #include @@ -34,6 +36,8 @@ using namespace std; char* SALOMEDS_AttributeFileType_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_FileType)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -41,6 +45,8 @@ char* SALOMEDS_AttributeFileType_i::Value() void SALOMEDS_AttributeFileType_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); // Handle(SALOMEDS_FileType)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); diff --git a/src/SALOMEDS/SALOMEDS_AttributeFlags_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeFlags_i.cxx index 43f2fd947..3e1f37267 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeFlags_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeFlags_i.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SALOMEDS_AttributeFlags_i.hxx" +#include "SALOMEDS.hxx" using namespace std; @@ -36,6 +37,8 @@ using namespace std; //======================================================================= CORBA::Long SALOMEDS_AttributeFlags_i::GetFlags() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Get(); } @@ -45,6 +48,8 @@ CORBA::Long SALOMEDS_AttributeFlags_i::GetFlags() //======================================================================= void SALOMEDS_AttributeFlags_i::SetFlags( CORBA::Long theFlags ) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Set( theFlags ); } @@ -54,6 +59,8 @@ void SALOMEDS_AttributeFlags_i::SetFlags( CORBA::Long theFlags ) //======================================================================= CORBA::Boolean SALOMEDS_AttributeFlags_i::Get( CORBA::Long theFlag ) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr )->Get() & theFlag ? true : false; } @@ -63,6 +70,8 @@ CORBA::Boolean SALOMEDS_AttributeFlags_i::Get( CORBA::Long theFlag ) //======================================================================= void SALOMEDS_AttributeFlags_i::Set( CORBA::Long theFlag, CORBA::Boolean theValue ) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_FlagsAttribute) anAttr = Handle(SALOMEDS_FlagsAttribute)::DownCast( _myAttr ); if ( theValue ) diff --git a/src/SALOMEDS/SALOMEDS_AttributeGraphic_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeGraphic_i.cxx index 7865b2501..3af2425ed 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeGraphic_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeGraphic_i.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SALOMEDS_AttributeGraphic_i.hxx" +#include "SALOMEDS.hxx" using namespace std; @@ -37,6 +38,8 @@ using namespace std; void SALOMEDS_AttributeGraphic_i::SetVisibility( CORBA::Long theViewId, CORBA::Boolean theValue ) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_GraphicAttribute) anAttr = Handle(SALOMEDS_GraphicAttribute)::DownCast( _myAttr ); if ( !anAttr.IsNull() ) @@ -49,6 +52,8 @@ void SALOMEDS_AttributeGraphic_i::SetVisibility( CORBA::Long theViewId, //======================================================================= CORBA::Boolean SALOMEDS_AttributeGraphic_i::GetVisibility( CORBA::Long theViewId ) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_GraphicAttribute) anAttr = Handle(SALOMEDS_GraphicAttribute)::DownCast( _myAttr ); return !anAttr.IsNull() ? anAttr->GetVisibility( theViewId ) : false; diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx index dec61d358..d9b905bd0 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SALOMEDS_AttributeIOR_i.hxx" +#include "SALOMEDS.hxx" #include #include "SALOMEDS_SObject_i.hxx" @@ -36,6 +37,8 @@ using namespace std; char* SALOMEDS_AttributeIOR_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -43,6 +46,8 @@ char* SALOMEDS_AttributeIOR_i::Value() void SALOMEDS_AttributeIOR_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant(); diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx index 8e40d8590..7244bef05 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx @@ -27,25 +27,34 @@ // $Header$ #include "SALOMEDS_AttributeInteger_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Long SALOMEDS_AttributeInteger_i::Value() { + SALOMEDS::Locker lock; + return Handle(TDataStd_Integer)::DownCast(_myAttr)->Get(); } void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } char* SALOMEDS_AttributeInteger_i::Store() { + SALOMEDS::Locker lock; + char* IntVal = new char[25]; sprintf(IntVal, "%d", Value()); return IntVal; } void SALOMEDS_AttributeInteger_i::Restore(const char* value) { + SALOMEDS::Locker lock; + char *err = NULL; CORBA::Long l = atol(value); SetValue(l); diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx index 77cef4678..b8e95836c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx @@ -27,25 +27,34 @@ // $Header$ #include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Long SALOMEDS_AttributeLocalID_i::Value() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_LocalIDAttribute)::DownCast(_myAttr)->Get(); } void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); } char* SALOMEDS_AttributeLocalID_i::Store() { + SALOMEDS::Locker lock; + char* IntVal = new char[25]; sprintf(IntVal, "%d", Value()); return IntVal; } void SALOMEDS_AttributeLocalID_i::Restore(const char* value) { + SALOMEDS::Locker lock; + char *err = NULL; CORBA::Long l = atol(value); SetValue(l); diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx index b495f26bf..8b37f454e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx @@ -27,26 +27,36 @@ // $Header$ #include "SALOMEDS_AttributeName_i.hxx" +#include "SALOMEDS.hxx" + #include #include using namespace std; char* SALOMEDS_AttributeName_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(TDataStd_Name)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); } void SALOMEDS_AttributeName_i::SetValue(const char* theValue) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString((char*)theValue)); } char* SALOMEDS_AttributeName_i::Store() { + SALOMEDS::Locker lock; + return Value(); } void SALOMEDS_AttributeName_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx index 5471006e5..e324dd61a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx @@ -27,23 +27,32 @@ // $Header$ #include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() { + SALOMEDS::Locker lock; + return (Handle(SALOMEDS_OpenedAttribute)::DownCast(_myAttr)->Get() == 1); } void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) { + SALOMEDS::Locker lock; + Standard_Integer val = 0; if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } char* SALOMEDS_AttributeOpened_i::Store() { + SALOMEDS::Locker lock; + return CORBA::string_dup(IsOpened()?"1":"0"); } void SALOMEDS_AttributeOpened_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetOpened(value[0] == '1'); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx index 67281220b..53b9eefa1 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx @@ -27,6 +27,8 @@ // $Header$ #include "SALOMEDS_AttributePersistentRef_i.hxx" +#include "SALOMEDS.hxx" + #include #include @@ -34,6 +36,8 @@ using namespace std; char* SALOMEDS_AttributePersistentRef_i::Value() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_PersRefAttribute)::DownCast(_myAttr)->Get(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -41,15 +45,21 @@ char* SALOMEDS_AttributePersistentRef_i::Value() void SALOMEDS_AttributePersistentRef_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } char* SALOMEDS_AttributePersistentRef_i::Store() { + SALOMEDS::Locker lock; + return Value(); } void SALOMEDS_AttributePersistentRef_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx index 8fc0f2be1..e2d8fa104 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx @@ -27,28 +27,38 @@ // $Header$ #include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get(); if (strcmp(TCollection_AsciiString(S).ToCString(), "None") == 0) return Standard_False; return Standard_True; } char* SALOMEDS_AttributePixMap_i::GetPixMap() { - CORBA::String_var S = CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get()).ToCString()); - return S._retn(); + SALOMEDS::Locker lock; + + CORBA::String_var S = CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get()).ToCString()); + return S._retn(); } void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); } char* SALOMEDS_AttributePixMap_i::Store() { + SALOMEDS::Locker lock; + return GetPixMap(); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx index 2faab629d..4c552be88 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx @@ -10,27 +10,37 @@ // $Header$ #include "SALOMEDS_AttributePythonObject_i.hxx" +#include "SALOMEDS.hxx" + #include #include using namespace std; void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(const_cast(theSequence), IsScript); } char* SALOMEDS_AttributePythonObject_i::GetObject() { + SALOMEDS::Locker lock; + char* aSeq = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->GetObject(); CORBA::String_var aStr = CORBA::string_dup(aSeq); return aStr._retn(); } CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript(); } char* SALOMEDS_AttributePythonObject_i::Store() { + SALOMEDS::Locker lock; + CORBA::String_var aString = GetObject(); char* aResult = new char[strlen(aString) + 2]; aResult[0] = IsScript()?'s':'n'; @@ -39,5 +49,7 @@ char* SALOMEDS_AttributePythonObject_i::Store() { } void SALOMEDS_AttributePythonObject_i::Restore(const char* theValue) { + SALOMEDS::Locker lock; + SetObject(&theValue[1], theValue[0]=='s'); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx index ca74454ee..54d642f7c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx @@ -27,6 +27,8 @@ // $Header$ #include "SALOMEDS_AttributeReal_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; @@ -56,15 +58,21 @@ static double read_double(const char* str) } CORBA::Double SALOMEDS_AttributeReal_i::Value() { + SALOMEDS::Locker lock; + return Handle(TDataStd_Real)::DownCast(_myAttr)->Get(); } void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value); } char* SALOMEDS_AttributeReal_i::Store() { + SALOMEDS::Locker lock; + // char* RealVal = new char[35]; // sprintf(RealVal, "%.20f", Value()); //return RealVal; @@ -72,6 +80,8 @@ char* SALOMEDS_AttributeReal_i::Store() { } void SALOMEDS_AttributeReal_i::Restore(const char* value) { + SALOMEDS::Locker lock; + //char *err = NULL; //CORBA::Double r = strtod(value, &err); //if (err != value) SetValue(r); diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx index 1ae041186..59d3d8e6e 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx @@ -27,23 +27,32 @@ // $Header$ #include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS.hxx" using namespace std; CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() { + SALOMEDS::Locker lock; + return (Handle(SALOMEDS_SelectableAttribute)::DownCast(_myAttr)->Get() == 1); } void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value) { + SALOMEDS::Locker lock; + Standard_Integer val = 0; if (value != 0) val = 1; Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); } char* SALOMEDS_AttributeSelectable_i::Store() { + SALOMEDS::Locker lock; + return CORBA::string_dup(IsSelectable()?"1":"0"); } void SALOMEDS_AttributeSelectable_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SetSelectable(value[0] == '1'); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx index 33b8fbd1e..1de8087bd 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx @@ -27,12 +27,16 @@ // $Header$ #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; for (int i = 0; i < other.length(); i++) { @@ -43,6 +47,8 @@ void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& othe SALOMEDS::LongSeq* SALOMEDS_AttributeSequenceOfInteger_i::CorbaSequence() { + SALOMEDS::Locker lock; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr); CorbaSeq->length(CasCadeSeq->Length()); @@ -54,33 +60,45 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeSequenceOfInteger_i::CorbaSequence() void SALOMEDS_AttributeSequenceOfInteger_i::Add(CORBA::Long value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Add(value); } void SALOMEDS_AttributeSequenceOfInteger_i::Remove(CORBA::Long index) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Remove(index); } void SALOMEDS_AttributeSequenceOfInteger_i::ChangeValue(CORBA::Long index, CORBA::Long value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->ChangeValue(index, value); } CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Value(CORBA::Short index) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Value(index); } CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Length() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length(); } char* SALOMEDS_AttributeSequenceOfInteger_i::Store() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr); Standard_Integer aLength = CasCadeSeq->Length(); char* aResult = new char[aLength * 25]; @@ -94,6 +112,8 @@ char* SALOMEDS_AttributeSequenceOfInteger_i::Store() { } void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; char* aCopy = strdup(value); diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx index 308ec01c0..45e7664f5 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx @@ -27,12 +27,16 @@ // $Header$ #include "SALOMEDS_AttributeSequenceOfReal_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; for (int i = 0; i < other.length(); i++) { @@ -43,6 +47,8 @@ void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other SALOMEDS::DoubleSeq* SALOMEDS_AttributeSequenceOfReal_i::CorbaSequence() { + SALOMEDS::Locker lock; + SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr); CorbaSeq->length(CasCadeSeq->Length()); @@ -54,33 +60,45 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeSequenceOfReal_i::CorbaSequence() void SALOMEDS_AttributeSequenceOfReal_i::Add(CORBA::Double value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Add(value); } void SALOMEDS_AttributeSequenceOfReal_i::Remove(CORBA::Long index) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Remove(index); } void SALOMEDS_AttributeSequenceOfReal_i::ChangeValue(CORBA::Long index, CORBA::Double value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->ChangeValue(index, value); } CORBA::Double SALOMEDS_AttributeSequenceOfReal_i::Value(CORBA::Short index) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Value(index); } CORBA::Long SALOMEDS_AttributeSequenceOfReal_i::Length() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length(); } char* SALOMEDS_AttributeSequenceOfReal_i::Store() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr); Standard_Integer aLength = CasCadeSeq->Length(); char* aResult = new char[aLength * 25]; @@ -94,6 +112,8 @@ char* SALOMEDS_AttributeSequenceOfReal_i::Store() { } void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; char* aCopy = strdup(value); diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx index b08b9d5c4..bf96a068c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -15,6 +15,7 @@ #include #include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS.hxx" #define CREATION_MODE_NOTDEFINED 0 #define CREATION_MODE_SCRATCH 1 @@ -23,12 +24,16 @@ using namespace std; void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); aProp->SetFirstName(const_cast(theName)); } char* SALOMEDS_AttributeStudyProperties_i::GetUserName() { + SALOMEDS::Locker lock; + TCollection_ExtendedString S = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreatorName(); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); return c_s._retn(); @@ -39,6 +44,8 @@ void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute, CORBA::Long theDay, CORBA::Long theMonth, CORBA::Long theYear) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); int aTmp; @@ -51,6 +58,8 @@ CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& CORBA::Long& theDay, CORBA::Long& theMonth, CORBA::Long& theYear) { + SALOMEDS::Locker lock; + Standard_Integer aMinute; Standard_Integer aHour; Standard_Integer aDay; @@ -69,6 +78,8 @@ CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& } void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH); @@ -77,6 +88,8 @@ void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) { } char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() { + SALOMEDS::Locker lock; + CORBA::String_var c_s; switch (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationMode()) { case CREATION_MODE_SCRATCH: c_s = "from scratch"; break; @@ -87,22 +100,32 @@ char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() { } void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetModified(theModified); } CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsModified(); } CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetModified(); } void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetLocked(theLocked); } CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsLocked(); } @@ -112,6 +135,8 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, CORBA::Long theDay, CORBA::Long theMonth, CORBA::Long theYear) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); aProp->SetUserName(const_cast(theName)); @@ -124,6 +149,8 @@ void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringS SALOMEDS::LongSeq_out theMonths, SALOMEDS::LongSeq_out theYears, CORBA::Boolean theWithCreator) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); @@ -157,6 +184,8 @@ void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringS } char* SALOMEDS_AttributeStudyProperties_i::Store() { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfExtendedString) aNames; Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); @@ -188,6 +217,8 @@ char* SALOMEDS_AttributeStudyProperties_i::Store() { } void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) { + SALOMEDS::Locker lock; + char* aCopy = strdup(value); if (aCopy[0] == 'f') SetCreationMode("from scratch"); else if (aCopy[0] == 'c') SetCreationMode("copy from"); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx index 380741f49..4ef3cbd66 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx @@ -15,6 +15,7 @@ #include #include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS.hxx" #include "Utils_ExceptHandlers.hxx" #include @@ -47,6 +48,8 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) } void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); CORBA::String_var aStr = CORBA::string_dup(theTitle); @@ -54,6 +57,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) { } char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); return c_s._retn(); @@ -62,6 +67,8 @@ char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() { void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -80,6 +87,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -90,6 +99,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbRows()); @@ -101,6 +112,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -112,6 +125,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, co void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -122,6 +137,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringS } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbColumns()); @@ -134,7 +151,9 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { - Unexpect aCatch (ATI_IncorrectIndex); + SALOMEDS::Locker lock; + + Unexpect aCatch (ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -149,6 +168,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -159,6 +180,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; aUnits->length(aTable->GetNbRows()); @@ -168,15 +191,21 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() { } CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbRows(); } CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbColumns(); } void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -194,6 +223,8 @@ void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -211,6 +242,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOME SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -227,6 +260,8 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -244,6 +279,8 @@ void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theD void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData) throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -261,6 +298,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -277,6 +316,8 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long the void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); @@ -290,12 +331,16 @@ void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::L } CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); } CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATI_IncorrectIndex); Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -312,6 +357,8 @@ CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, COR SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -328,12 +375,16 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::L void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); aTable->SetNbColumns(theNbColumns); } bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); istrstream aStream((char*)&theStream[0], theStream.length()); @@ -342,6 +393,8 @@ bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& t SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -361,6 +414,8 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() } char* SALOMEDS_AttributeTableOfInteger_i::Store() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -372,6 +427,8 @@ char* SALOMEDS_AttributeTableOfInteger_i::Store() { } void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); istrstream aStream(value, strlen(value)); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx index c550cf38b..a979fd5e2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -10,6 +10,7 @@ // $Header$ #include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS.hxx" #include #include @@ -46,6 +47,8 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) } void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); CORBA::String_var aStr = CORBA::string_dup(theTitle); @@ -53,6 +56,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) { } char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); return c_s._retn(); @@ -61,6 +66,8 @@ char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -79,6 +86,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const ch void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -89,6 +98,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& th } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbRows()); @@ -100,6 +111,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -111,6 +124,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -121,6 +136,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbColumns()); @@ -133,6 +150,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -148,6 +167,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const cha void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -158,6 +179,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& the } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; aUnits->length(aTable->GetNbRows()); @@ -168,15 +191,21 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() { CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbRows(); } CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbColumns(); } void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -189,6 +218,8 @@ void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -201,6 +232,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS: SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -217,6 +250,8 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -229,6 +264,8 @@ void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theDa void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -241,6 +278,8 @@ void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SAL SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -257,6 +296,8 @@ SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theC void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); @@ -265,12 +306,16 @@ void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Lo } CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); } CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -290,6 +335,8 @@ CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORB SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -306,12 +353,16 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); aTable->SetNbColumns(theNbColumns); } bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); istrstream aStream((char*)&theStream[0], theStream.length()); @@ -320,6 +371,8 @@ bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theS SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -339,6 +392,8 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() } char* SALOMEDS_AttributeTableOfReal_i::Store() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -350,6 +405,8 @@ char* SALOMEDS_AttributeTableOfReal_i::Store() { } void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); istrstream aStream(value, strlen(value)); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx index 8527cf8db..763b80322 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx @@ -19,6 +19,7 @@ #include #include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS.hxx" #include "Utils_ExceptHandlers.hxx" @@ -47,6 +48,8 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) } void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); CORBA::String_var aStr = CORBA::string_dup(theTitle); @@ -54,6 +57,8 @@ void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) { } char* SALOMEDS_AttributeTableOfString_i::GetTitle() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); return c_s._retn(); @@ -62,6 +67,8 @@ char* SALOMEDS_AttributeTableOfString_i::GetTitle() { void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -80,6 +87,8 @@ void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -90,6 +99,8 @@ void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbRows()); @@ -101,6 +112,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() { void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -112,6 +125,8 @@ void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, con void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -122,6 +137,8 @@ void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSe } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbColumns()); @@ -134,6 +151,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() { void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -149,6 +168,8 @@ void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const c void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -159,6 +180,8 @@ void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& t } SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; aUnits->length(aTable->GetNbRows()); @@ -169,15 +192,21 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits() { CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbRows() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbRows(); } CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbColumns(); } void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -190,6 +219,8 @@ void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theDat void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -202,6 +233,8 @@ void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMED SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -218,6 +251,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRo void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -230,6 +265,8 @@ void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& the void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData) throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectArgumentLength); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -242,6 +279,8 @@ void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const S SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -258,6 +297,8 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long th void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); CheckLocked(); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); @@ -267,12 +308,16 @@ void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Lo } CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + SALOMEDS::Locker lock; + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); } char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) { + SALOMEDS::Locker lock; + Unexpect aCatch(ATS_IncorrectIndex); Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -292,6 +337,8 @@ char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Lon SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::GetRowSetIndices(CORBA::Long theRow) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -308,12 +355,16 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::GetRowSetIndices(CORBA::Lo void SALOMEDS_AttributeTableOfString_i::SetNbColumns(CORBA::Long theNbColumns) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); aTable->SetNbColumns(theNbColumns); } bool SALOMEDS_AttributeTableOfString_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); istrstream aStream((char*)&theStream[0], theStream.length()); @@ -322,6 +373,8 @@ bool SALOMEDS_AttributeTableOfString_i::ReadFromFile(const SALOMEDS::TMPFile& th SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -333,6 +386,8 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() } char* SALOMEDS_AttributeTableOfString_i::Store() { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); ostrstream ostr; @@ -344,6 +399,8 @@ char* SALOMEDS_AttributeTableOfString_i::Store() { } void SALOMEDS_AttributeTableOfString_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); istrstream aStream(value, strlen(value)); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx index 70f7b81b9..0f44433b9 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx @@ -33,17 +33,22 @@ #include "SALOMEDS_AttributeTarget_i.hxx" #include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS.hxx" using namespace std; void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject) { + SALOMEDS::Locker lock; + TDF_Label aLabel; TDF_Tool::Label(_myAttr->Label().Data(),anObject->GetID(),aLabel,1); _myAttr->Append(aLabel); } SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() { + SALOMEDS::Locker lock; + TDF_LabelList aLList; _myAttr->Get(aLList); @@ -63,6 +68,8 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() { } void SALOMEDS_AttributeTarget_i::Remove(SALOMEDS::SObject_ptr anObject) { + SALOMEDS::Locker lock; + TDF_Label aLabel; CORBA::String_var anID = anObject->GetID(); TDF_Tool::Label(_myAttr->Label().Data(),anID.inout(),aLabel,1); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx index 32a79e68c..74135d0ab 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx @@ -27,11 +27,15 @@ // $Header$ #include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() { + SALOMEDS::Locker lock; + SALOMEDS::Color TextColor; Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->Array(); if (anArray.IsNull() || anArray->Length()!=3) { @@ -48,6 +52,8 @@ SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() { } void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3); anArray->SetValue(1, value.R); @@ -57,6 +63,8 @@ void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) { } char* SALOMEDS_AttributeTextColor_i::Store() { + SALOMEDS::Locker lock; + SALOMEDS::Color aColor = TextColor(); char *Val = new char[75]; sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); @@ -64,6 +72,8 @@ char* SALOMEDS_AttributeTextColor_i::Store() { } void SALOMEDS_AttributeTextColor_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SALOMEDS::Color aColor; float r, g, b; sscanf(value, "%f %f %f", &r, &g, &b); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx index 672d81c45..d447ee516 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx @@ -27,11 +27,15 @@ // $Header$ #include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() { + SALOMEDS::Locker lock; + SALOMEDS::Color TextHighlightColor; Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->Array(); if (anArray.IsNull() || anArray->Length()!=3) { @@ -48,6 +52,8 @@ SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() { } void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMEDS::Color& value) { + SALOMEDS::Locker lock; + CheckLocked(); Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3); anArray->SetValue(1, value.R); @@ -57,6 +63,8 @@ void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMED } char* SALOMEDS_AttributeTextHighlightColor_i::Store() { + SALOMEDS::Locker lock; + SALOMEDS::Color aColor = TextHighlightColor(); char *Val = new char[75]; sprintf(Val, "%f %f %f", (float)aColor.R, (float)aColor.G, (float)aColor.B); @@ -64,6 +72,8 @@ char* SALOMEDS_AttributeTextHighlightColor_i::Store() { } void SALOMEDS_AttributeTextHighlightColor_i::Restore(const char* value) { + SALOMEDS::Locker lock; + SALOMEDS::Color aColor; float r, g, b; sscanf(value, "%f %f %f", &r, &g, &b); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index 15449d603..81c00aaf2 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -30,6 +30,7 @@ #include #include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS.hxx" #include "utilities.h" @@ -55,118 +56,166 @@ static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value, } void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->SetFather(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather() { + SALOMEDS::Locker lock; + return _myAttr->HasFather(); } SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather() { + SALOMEDS::Locker lock; + SALOMEDS_AttributeTreeNode_i* aTreeNode = new SALOMEDS_AttributeTreeNode_i(_myAttr->Father(),_mySObject); return aTreeNode->_this(); } void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->SetPrevious(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious() { + SALOMEDS::Locker lock; + return _myAttr->HasPrevious(); } SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious() { + SALOMEDS::Locker lock; + SALOMEDS_AttributeTreeNode_i* aTreeNode = new SALOMEDS_AttributeTreeNode_i(_myAttr->Previous(),_mySObject); return aTreeNode->_this(); } void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->SetNext(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext() { + SALOMEDS::Locker lock; + return _myAttr->HasNext(); } SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext() { + SALOMEDS::Locker lock; + SALOMEDS_AttributeTreeNode_i* aTreeNode = new SALOMEDS_AttributeTreeNode_i(_myAttr->Next(),_mySObject); return aTreeNode->_this(); } void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->SetFirst(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst() { + SALOMEDS::Locker lock; + return _myAttr->HasFirst(); } SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst() { + SALOMEDS::Locker lock; + SALOMEDS_AttributeTreeNode_i* aTreeNode = new SALOMEDS_AttributeTreeNode_i(_myAttr->First(),_mySObject); return aTreeNode->_this(); } void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->SetTreeID(Standard_GUID(_myAttr->ID())); } char* SALOMEDS_AttributeTreeNode_i::GetTreeID() { + SALOMEDS::Locker lock; + char aGUID[40]; _myAttr->ID().ToCString(aGUID); return CORBA::string_dup(aGUID); } void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->Append(GetNode(theValue,_myAttr)); } void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->Prepend(GetNode(theValue,_myAttr)); } void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->InsertBefore(GetNode(theValue,_myAttr)); } void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->InsertAfter(GetNode(theValue,_myAttr)); } void SALOMEDS_AttributeTreeNode_i::Remove() { + SALOMEDS::Locker lock; + CheckLocked(); _myAttr->Remove(); } CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth() { + SALOMEDS::Locker lock; + return _myAttr->Depth(); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot() { + SALOMEDS::Locker lock; + return _myAttr->IsRoot(); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + return _myAttr->IsDescendant(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + return _myAttr->IsFather(GetNode(theValue,_myAttr)); } CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr theValue) { + SALOMEDS::Locker lock; + return _myAttr->IsChild(GetNode(theValue,_myAttr)); } @@ -177,6 +226,8 @@ char* SALOMEDS_AttributeTreeNode_i::Label() { } char* SALOMEDS_AttributeTreeNode_i::Store() { + SALOMEDS::Locker lock; + char* aStr[4]; if (HasFather()) aStr[0] = GetFather()->Label(); else aStr[0] = "!"; @@ -192,6 +243,8 @@ char* SALOMEDS_AttributeTreeNode_i::Store() { } void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) { + SALOMEDS::Locker lock; + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData(); diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx index 6a3d2d3cd..738365319 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx @@ -27,11 +27,15 @@ // $Header$ #include "SALOMEDS_AttributeUserID_i.hxx" +#include "SALOMEDS.hxx" + #include using namespace std; char* SALOMEDS_AttributeUserID_i::Value() { + SALOMEDS::Locker lock; + char aGUID[40]; Handle(TDataStd_UAttribute)::DownCast(_myAttr)->ID().ToCString(aGUID); CORBA::String_var c_s = CORBA::string_dup(aGUID); @@ -39,6 +43,8 @@ char* SALOMEDS_AttributeUserID_i::Value() { } void SALOMEDS_AttributeUserID_i::SetValue(const char* value) { + SALOMEDS::Locker lock; + CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str))); diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx index d256bb669..6bf85d269 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@ -28,6 +28,7 @@ #include +#include "SALOMEDS.hxx" #include "SALOMEDS_ChildIterator_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "utilities.h" @@ -64,6 +65,8 @@ SALOMEDS_ChildIterator_i::~SALOMEDS_ChildIterator_i() //============================================================================ void SALOMEDS_ChildIterator_i::Init() { + SALOMEDS::Locker lock; + _it.Initialize(_lab); } @@ -74,6 +77,8 @@ void SALOMEDS_ChildIterator_i::Init() //============================================================================ void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean theIsAllLevels) { + SALOMEDS::Locker lock; + _it.Initialize(_lab,theIsAllLevels); } @@ -84,6 +89,8 @@ void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean theIsAllLevels) //============================================================================ CORBA::Boolean SALOMEDS_ChildIterator_i::More() { + SALOMEDS::Locker lock; + return _it.More(); } @@ -94,6 +101,8 @@ CORBA::Boolean SALOMEDS_ChildIterator_i::More() //============================================================================ void SALOMEDS_ChildIterator_i::Next() { + SALOMEDS::Locker lock; + _it.Next(); } @@ -106,6 +115,8 @@ void SALOMEDS_ChildIterator_i::Next() SALOMEDS::SObject_ptr SALOMEDS_ChildIterator_i::Value() { + SALOMEDS::Locker lock; + return SALOMEDS_SObject_i::NewRef(_study,_it.Value())._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index b9a24946a..5e18368b6 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -12,6 +12,7 @@ #include "SALOMEDS_GenericAttribute_i.hxx" #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS_Study_i.hxx" +#include "SALOMEDS.hxx" using namespace std; @@ -42,18 +43,24 @@ void SALOMEDS_GenericAttribute_i::Restore(const char*) char* SALOMEDS_GenericAttribute_i::Type() { + SALOMEDS::Locker lock; + return CORBA::string_dup(SALOMEDS::GetType(_myBasicAttr).c_str()); } SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() { - return _mySObject->_this();; + SALOMEDS::Locker lock; + + return _mySObject->_this(); } void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) { + SALOMEDS::Locker lock; + _mySObject->GetStudyServant()->CheckLocked(); } diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx index adf77476a..61d750cd1 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx @@ -28,6 +28,7 @@ #include "SALOMEDS_SComponentIterator_i.hxx" #include "SALOMEDS_SComponent_i.hxx" +#include "SALOMEDS.hxx" using namespace std; @@ -61,6 +62,8 @@ SALOMEDS_SComponentIterator_i::~SALOMEDS_SComponentIterator_i() //============================================================================ void SALOMEDS_SComponentIterator_i::Init() { + SALOMEDS::Locker lock; + _it.Initialize (_lab); } @@ -71,6 +74,8 @@ void SALOMEDS_SComponentIterator_i::Init() //============================================================================ CORBA::Boolean SALOMEDS_SComponentIterator_i::More() { + SALOMEDS::Locker lock; + if (!_it.More()) return false; TDF_Label L = _it.Value(); @@ -86,6 +91,8 @@ CORBA::Boolean SALOMEDS_SComponentIterator_i::More() //============================================================================ void SALOMEDS_SComponentIterator_i::Next() { + SALOMEDS::Locker lock; + _it.Next(); } @@ -97,6 +104,8 @@ void SALOMEDS_SComponentIterator_i::Next() //============================================================================ SALOMEDS::SComponent_ptr SALOMEDS_SComponentIterator_i::Value() { + SALOMEDS::Locker lock; + return SALOMEDS_SComponent_i::NewRef(_study,_it.Value())._retn(); } diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx index c9cc82ac6..abb002152 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx @@ -28,6 +28,7 @@ #include "SALOMEDS_SComponent_i.hxx" #include "SALOMEDS_Study_i.hxx" +#include "SALOMEDS.hxx" #include "utilities.h" @@ -98,6 +99,8 @@ SALOMEDS_SComponent_i::~SALOMEDS_SComponent_i() //============================================================================ char* SALOMEDS_SComponent_i::ComponentDataType() { + SALOMEDS::Locker lock; + //DEB // MESSAGE("In SALOMEDS_SComponent_i::ComponentDataType"); // TCollection_AsciiString anEntry; @@ -123,6 +126,8 @@ char* SALOMEDS_SComponent_i::ComponentDataType() //============================================================================ CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR) { + SALOMEDS::Locker lock; + Handle(SALOMEDS_IORAttribute) ior; if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) ) return false; diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 35c5087af..198e1e79e 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -44,6 +44,7 @@ #include "SALOMEDS_SObject_i.hxx" //SALOMEDS Headers +#include #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS_StudyManager_i.hxx" #include "SALOMEDS_SComponent_i.hxx" @@ -102,7 +103,6 @@ inline bool operator<(const Standard_GUID& theLeft, const Standard_GUID& theRigh namespace SALOMEDS{ - const char* Str(const TCollection_ExtendedString& theString) { return TCollection_AsciiString(theString).ToCString(); @@ -274,6 +274,8 @@ namespace SALOMEDS{ } } + +//static SALOMEDS::Mutex SObjMutex; //============================================================================ SALOMEDS_Study_i::TSObjectHolder @@ -355,6 +357,8 @@ PortableServer::POA_var SALOMEDS_SObject_i::GetPOA() const //============================================================================ char* SALOMEDS_SObject_i::GetID() { + Locker lock; + TCollection_AsciiString anEntry; TDF_Tool::Entry(_lab,anEntry); return CORBA::string_dup(anEntry.ToCString()); @@ -376,6 +380,8 @@ TDF_Label SALOMEDS_SObject_i::GetFatherComponentLabel() SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent() { + Locker lock; + TDF_Label aSCompLabel = GetFatherComponentLabel(); return SALOMEDS_SComponent_i::NewRef(_study,aSCompLabel)._retn(); @@ -388,6 +394,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent() //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather() { + Locker lock; + return SALOMEDS_SObject_i::NewRef(_study,_lab.Father())._retn(); } @@ -408,6 +416,8 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy() //============================================================================ CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out theSObject) { + Locker lock; + Handle(TDF_Reference) aRef; if (!_lab.FindAttribute(TDF_Reference::GetID(),aRef)) return false; @@ -423,6 +433,8 @@ CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out theSOb //============================================================================ CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject) { + Locker lock; + TDF_Label aLabel = _lab.FindChild(theTag,false); if(aLabel.IsNull()) return false; @@ -438,6 +450,8 @@ CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long theTag, SALOMEDS::S //============================================================================ char* SALOMEDS_SObject_i::Name() { + Locker lock; + return CORBA::string_dup(_name.c_str()); } @@ -448,6 +462,8 @@ char* SALOMEDS_SObject_i::Name() //============================================================================ void SALOMEDS_SObject_i::Name(const char* theName) { + Locker lock; + _name = theName; } @@ -458,6 +474,8 @@ void SALOMEDS_SObject_i::Name(const char* theName) //============================================================================ CORBA::Short SALOMEDS_SObject_i::Tag() { + Locker lock; + return _lab.Tag(); } @@ -468,6 +486,8 @@ CORBA::Short SALOMEDS_SObject_i::Tag() //============================================================================ CORBA::Short SALOMEDS_SObject_i::Depth() { + Locker lock; + return _lab.Depth(); } @@ -478,6 +498,8 @@ CORBA::Short SALOMEDS_SObject_i::Depth() //============================================================================ CORBA::Object_ptr SALOMEDS_SObject_i::GetObject() { + Locker lock; + try { Handle(SALOMEDS_IORAttribute) anAttr; if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){ @@ -495,6 +517,8 @@ CORBA::Object_ptr SALOMEDS_SObject_i::GetObject() */ //============================================================================ char* SALOMEDS_SObject_i::GetName() { + Locker lock; + Handle(TDataStd_Name) anAttr; if(_lab.FindAttribute(TDataStd_Name::GetID(),anAttr)) return CORBA::string_dup(Str(anAttr->Get())); @@ -508,6 +532,8 @@ char* SALOMEDS_SObject_i::GetName() { */ //============================================================================ char* SALOMEDS_SObject_i::GetComment() { + Locker lock; + Handle(TDataStd_Comment) anAttr; if(_lab.FindAttribute(TDataStd_Comment::GetID(), anAttr)) return CORBA::string_dup(Str(anAttr->Get())); @@ -521,6 +547,8 @@ char* SALOMEDS_SObject_i::GetComment() { */ //============================================================================ char* SALOMEDS_SObject_i::GetIOR() { + Locker lock; + Handle(SALOMEDS_IORAttribute) anAttr; if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)) return CORBA::string_dup(Str(anAttr->Get())); @@ -544,6 +572,8 @@ SALOMEDS_SObject_i::_FindGenAttribute(const Handle(TDF_Attribute)& theAttr) SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() { + Locker lock; + SALOMEDS::ListOfAttributes_var aSeqOfAttr = new SALOMEDS::ListOfAttributes; if(_lab.NbAttributes() > 0){ Standard_Integer i = 0; @@ -635,6 +665,8 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, const char* theType) { + Locker lock; + TAttrHolder anAttr = _FindGenAttribute(theType); SALOMEDS::GenericAttribute_var anGenAttr = anAttr.second; if(!CORBA::is_nil(anGenAttr)){ @@ -699,6 +731,8 @@ Handle(TDF_Attribute) SALOMEDS::GenericAttribute_ptr SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType) { + Locker lock; + TAttrHolder anAttrHolder = _FindGenAttribute(theType); SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second; if(!anGenAttr->_is_nil()) @@ -723,6 +757,8 @@ SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType) //============================================================================ void SALOMEDS_SObject_i::RemoveAttribute(const char* theType) { + Locker lock; + _study->CheckLocked(); if(strcmp(theType, "AttributeIOR") == 0) { // postponed removing of CORBA objects Handle(SALOMEDS_IORAttribute) anAttr; diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 42aefe220..63b5b8bc0 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -41,6 +41,7 @@ #include "SALOMEDS_StudyPropertiesAttribute.hxx" #include "SALOMEDS_Tool.hxx" +#include "SALOMEDS.hxx" #include "Utils_CorbaException.hxx" #include "Utils_ExceptHandlers.hxx" @@ -115,6 +116,8 @@ PortableServer::POA_var SALOMEDS_StudyBuilder_i::GetPOA() const SALOMEDS::SComponent_ptr SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) { + SALOMEDS::Locker lock; + CheckLocked(); //Always create component under main label. TDF_Label L = _doc->Main(); @@ -147,6 +150,8 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr theComponent, CORBA::Object_ptr theObject) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(theComponent) || CORBA::is_nil(theObject)) @@ -170,6 +175,8 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr t void SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr theComponent) { + SALOMEDS::Locker lock; + CheckLocked(); RemoveObject(theComponent); } @@ -182,6 +189,8 @@ SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr theComponent) SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(theFatherObject)) @@ -220,6 +229,8 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, CORBA::Long theTag) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(theFatherObject)) @@ -247,6 +258,8 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject) { + SALOMEDS::Locker lock; + RemoveSObject(theSObject); } @@ -276,6 +289,8 @@ SALOMEDS_StudyBuilder_i::RemoveSObject(SALOMEDS::SObject_ptr theSObject, //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr theSObject) { + SALOMEDS::Locker lock; + if(SALOMEDS_SObject_i* aSObject = RemoveSObject(theSObject,false)){ SALOMEDS_ChildIterator_i aChildIter(_study,aSObject->GetLabel(),true); for(; aChildIter.More(); aChildIter.Next()){ @@ -313,9 +328,14 @@ static void Translate_persistentID_to_IOR(TDF_Label theLabel, TCollection_AsciiString ch(res); SALOMEDS::SObject_var aSObject = SALOMEDS_SObject_i::NewRef(theStudy,aCurrentLabel); - + + // PAL8065: san - Translate_persistentID_to_IOR() should always be called from some CORBA method + // protected with a lock + SALOMEDS::unlock(); CORBA::String_var anIOR = theDriver->LocalPersistentIDToIOR(aSObject,ch.ToCString(),theIsMultiFile,theIsASCII); + SALOMEDS::lock(); + SALOMEDS_IORAttribute::Set(aCurrentLabel,const_cast(anIOR.in()),theStudy); } @@ -334,6 +354,8 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent, SALOMEDS::Driver_ptr theDriver) throw(SALOME::SALOME_Exception) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBSalomeException); if(CORBA::is_nil(theSComponent)) @@ -414,9 +436,12 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent, std::string aDir(aHDFPath.ToCString()); aDir = aDir.substr(0,aDir.rfind('/') + 1); + SALOMEDS::unlock(); CORBA::Boolean aResult = (ASCIIfileState[0]=='A')? theDriver->LoadASCII(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M'): theDriver->Load(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M'); + SALOMEDS::lock(); + if(!aResult) { RemoveAttribute( theSComponent, "AttributeIOR" ); if (isASCII) { @@ -498,6 +523,8 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr theObject, const char* theTypeOfAttribute) { + SALOMEDS::Locker lock; + if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject)) return aSObject->FindOrCreateAttribute(theTypeOfAttribute); @@ -514,6 +541,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr theO SALOMEDS::GenericAttribute_out theAttr, const char* theTypeOfAttribute) { + SALOMEDS::Locker lock; + if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject)) return aSObject->FindAttribute(theAttr,theTypeOfAttribute); @@ -529,6 +558,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr theO void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr theSObject, const char* aTypeOfAttribute) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(theSObject)) @@ -558,6 +589,8 @@ void SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, SALOMEDS::SObject_ptr theReferencedObject) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(me) || CORBA::is_nil(theReferencedObject)) return; @@ -584,6 +617,8 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) { + SALOMEDS::Locker lock; + SALOMEDS::SObject_var theReferencedObject; if(!me->ReferencedObject(theReferencedObject)) return; //No reference is found @@ -613,6 +648,8 @@ void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me) //============================================================================ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) { + SALOMEDS::Locker lock; + CheckLocked(); if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory(); @@ -679,6 +716,8 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) //============================================================================ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID) { + SALOMEDS::Locker lock; + CheckLocked(); if(CORBA::is_nil(anObject)) @@ -697,6 +736,8 @@ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char //============================================================================ bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID) { + SALOMEDS::Locker lock; + if(CORBA::is_nil(anObject)) return false; @@ -714,6 +755,8 @@ bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* //============================================================================ void SALOMEDS_StudyBuilder_i::NewCommand() { + SALOMEDS::Locker lock; + // mpv: for SAL2114 - unset "lock changed" flag at the operation start Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { @@ -732,6 +775,8 @@ void SALOMEDS_StudyBuilder_i::NewCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { @@ -759,6 +804,8 @@ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::Loc //============================================================================ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() { + SALOMEDS::Locker lock; + return _doc->HasOpenCommand(); } @@ -769,6 +816,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::AbortCommand() { + SALOMEDS::Locker lock; + _study->UndoPostponed(0); _doc->AbortCommand(); @@ -781,6 +830,8 @@ void SALOMEDS_StudyBuilder_i::AbortCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { @@ -803,7 +854,9 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti */ //============================================================================ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection) -{ +{ + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { @@ -828,6 +881,8 @@ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtecti //============================================================================ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableUndos() { + SALOMEDS::Locker lock; + return _doc->GetAvailableUndos(); } @@ -838,6 +893,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableUndos() //============================================================================ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos() { + SALOMEDS::Locker lock; + return _doc->GetAvailableRedos(); } @@ -848,6 +905,8 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos() //============================================================================ CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit() { + SALOMEDS::Locker lock; + return _doc->GetUndoLimit(); } @@ -858,6 +917,8 @@ CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit() //============================================================================ void SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n) { + SALOMEDS::Locker lock; + CheckLocked(); _doc->SetUndoLimit (n); } @@ -909,6 +970,8 @@ void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockP void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); CheckLocked(); @@ -930,6 +993,8 @@ void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* t void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); CheckLocked(); @@ -951,6 +1016,8 @@ void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue) throw(SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(SBLockProtection); CheckLocked(); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 588019be2..d0464d63f 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -47,6 +47,7 @@ #include #include +#include "SALOMEDS.hxx" #include "SALOMEDS_StudyManager_i.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -284,6 +285,8 @@ void SALOMEDS_StudyManager_i::register_name(char * theName) { //============================================================================ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* theStudyName) { + SALOMEDS::Locker lock; + Handle(TDocStd_Document) aDocument; _OCAFApp->NewDocument("SALOME_STUDY",aDocument); @@ -331,6 +334,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* theStudyName) SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* theURL) throw(SALOME::SALOME_Exception) { + SALOMEDS::Locker lock; + Unexpect aCatch(SalomeException); MESSAGE("Begin of SALOMEDS_StudyManager_i::Open"); @@ -433,6 +438,8 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* theURL) //============================================================================ void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) { + SALOMEDS::Locker lock; + if(aStudy->_is_nil()) return; aStudy->RemovePostponed(-1); @@ -453,6 +460,8 @@ void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) //============================================================================ void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile) { + SALOMEDS::Locker lock; + CORBA::String_var anURL = theStudy->URL(); if(strcmp(anURL.in(),"") == 0){ MESSAGE( "No path specified to save the study. Nothing done"); @@ -463,6 +472,8 @@ void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr theStudy, CORBA::Boolean void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile) { + SALOMEDS::Locker lock; + CORBA::String_var anURL = theStudy->URL(); if(strcmp(anURL.in(),"") == 0){ MESSAGE( "No path specified to save the study. Nothing done"); @@ -478,12 +489,16 @@ void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr theStudy, CORBA::Boo //============================================================================ void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile) { + SALOMEDS::Locker lock; + _SaveAs(aUrl,theStudy,theMultiFile, false); } void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile) { + SALOMEDS::Locker lock; + _SaveAs(aUrl,theStudy,theMultiFile, true); } @@ -726,7 +741,10 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, if(!aComp->_is_nil()){ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp); if (!CORBA::is_nil(aDriver)) { + // PAL8065: san - _SaveAs() should always be called from some CORBA method protected with a lock + SALOMEDS::unlock(); SB->LoadWith(sco, aDriver); + SALOMEDS::lock(); } } } @@ -1007,23 +1025,27 @@ std::string SALOMEDS_StudyManager_i::_SubstituteSlash(const char *theUrl) */ //============================================================================ CORBA::Boolean SALOMEDS_StudyManager_i::CanCopy(SALOMEDS::SObject_ptr theObject) { - SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + SALOMEDS::Driver_var Engine; + { // Guarded block of code + SALOMEDS::Locker lock; - if(aComponent->_is_nil()) - return false; + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); - if(aComponent == theObject) - return false; + if(aComponent->_is_nil()) + return false; - CORBA::String_var IOREngine; - if(!aComponent->ComponentIOR(IOREngine)) - return false; + if(aComponent == theObject) + return false; - CORBA::Object_var obj = _orb->string_to_object(IOREngine); - SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; - if (CORBA::is_nil(Engine)) - return false; + CORBA::String_var IOREngine; + if(!aComponent->ComponentIOR(IOREngine)) + return false; + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + Engine = SALOMEDS::Driver::_narrow(obj); + if (CORBA::is_nil(Engine)) + return false; + } // End of guarded block of code return Engine->CanCopy(theObject); } @@ -1069,24 +1091,31 @@ void SALOMEDS_StudyManager_i::CopyLabel(SALOMEDS_Study_i* theSourceStudy, continue; } - if (!Handle(SALOMEDS_IORAttribute)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theSource, anEntry); - SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(anEntry.ToCString()); - CORBA::Long anObjID; - SALOMEDS::TMPFile_var aStream = theEngine->CopyFrom(aSO, anObjID); - int aLen = aStream->length(); - TCollection_ExtendedString aResStr(""); - for(a = 0; a < aLen; a++) { - aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a])); - } - TDataStd_Integer::Set(aAuxTargetLabel, anObjID); - TDataStd_Name::Set(aAuxTargetLabel, aResStr); + if (Handle(SALOMEDS_IORAttribute)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine + Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); + aTargetLabel.AddAttribute(aNewAttribute); + anAttr->Paste(aNewAttribute, aRT); continue; } - Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); - aTargetLabel.AddAttribute(aNewAttribute); - anAttr->Paste(aNewAttribute, aRT); + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theSource, anEntry); + SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(anEntry.ToCString()); + CORBA::Long anObjID; + + // PAL8065: san - CopyLabel() should always be called from some CORBA method protected with a lock + SALOMEDS::unlock(); + SALOMEDS::TMPFile_var aStream = theEngine->CopyFrom(aSO, anObjID); + SALOMEDS::lock(); + + int aLen = aStream->length(); + TCollection_ExtendedString aResStr(""); + for(a = 0; a < aLen; a++) { + aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a])); + } + TDataStd_Integer::Set(aAuxTargetLabel, anObjID); + TDataStd_Name::Set(aAuxTargetLabel, aResStr); + // aRT->SetRelocation(anAttr, aNewAttribute); } } @@ -1097,6 +1126,8 @@ void SALOMEDS_StudyManager_i::CopyLabel(SALOMEDS_Study_i* theSourceStudy, */ //============================================================================ CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) { + SALOMEDS::Locker lock; + // adoptation for alliances datamodel copy: without IOR attributes !!! // copy only SObjects and attributes without component help SALOMEDS::GenericAttribute_var anAttribute; @@ -1170,28 +1201,37 @@ CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) { */ //============================================================================ CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject) { - if (_clipboard.IsNull()) return false; + CORBA::String_var aName; + Standard_Integer anID; + SALOMEDS::Driver_var Engine; + { // Guarded block of code + SALOMEDS::Locker lock; - Handle(TDataStd_Comment) aCompName; - if (!_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aCompName)) return false; - Handle(TDataStd_Integer) anObjID; - if (!_clipboard->Main().Father().FindChild(2).FindAttribute(TDataStd_Integer::GetID(), anObjID)) - return false; + if (_clipboard.IsNull()) return false; - SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); - if(aComponent->_is_nil()) - return false; + Handle(TDataStd_Comment) aCompName; + if (!_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aCompName)) return false; + Handle(TDataStd_Integer) anObjID; + if (!_clipboard->Main().Father().FindChild(2).FindAttribute(TDataStd_Integer::GetID(), anObjID)) + return false; + + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + if(aComponent->_is_nil()) + return false; - CORBA::String_var IOREngine; - if(!aComponent->ComponentIOR(IOREngine)) - return false; + CORBA::String_var IOREngine; + if(!aComponent->ComponentIOR(IOREngine)) + return false; - CORBA::Object_var obj = _orb->string_to_object(IOREngine); - SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; - if (CORBA::is_nil(Engine)) - return false; + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + Engine = SALOMEDS::Driver::_narrow(obj) ; + if (CORBA::is_nil(Engine)) + return false; - return Engine->CanPaste(TCollection_AsciiString(aCompName->Get()).ToCString(),anObjID->Get()); + aName = CORBA::string_dup( TCollection_AsciiString(aCompName->Get()).ToCString() ); + anID = anObjID->Get(); + } // End of guarded block of code + return Engine->CanPaste(aName.in(),anID); } //============================================================================ /*! Function : PasteLabel @@ -1241,13 +1281,19 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(SALOMEDS_Study_i* theDestinationSt TDF_Tool::Entry(aTargetLabel, anEntry); SALOMEDS::SObject_var aPastedSO = theDestinationStudy->FindObjectID(anEntry.ToCString()); if(isFirstElement){ + // PAL8065: san - PasteLabel() should always be called from some CORBA method protected with a lock + SALOMEDS::unlock(); SALOMEDS::SObject_var aDestSO = theEngine->PasteInto(aTMPFil.in(), anObjID->Get(), aPastedSO->GetFatherComponent()); + SALOMEDS::lock(); TDF_Tool::Label(theDestinationStart.Data(), aDestSO->GetID(), aTargetLabel); }else + // PAL8065: san - PasteLabel() should always be called from some CORBA method protected with a lock + SALOMEDS::unlock(); theEngine->PasteInto(aTMPFil.in(),anObjID->Get(),aPastedSO); + SALOMEDS::lock(); } } @@ -1299,6 +1345,8 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(SALOMEDS_Study_i* theDestinationSt SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection) { + SALOMEDS::Locker lock; + Unexpect aCatch(LockProtection); PortableServer::ServantBase_var aServant = GetServant(theObject,_poa); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 1f8e0aa75..3b4d5e087 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -40,6 +40,7 @@ #include #include +#include "SALOMEDS.hxx" #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS_StudyManager_i.hxx" @@ -216,6 +217,8 @@ void SALOMEDS_Study_i::OnRemoveSObject(SALOMEDS::SObject_ptr theObject) //============================================================================ void SALOMEDS_Study_i::CheckLocked() { + SALOMEDS::Locker lock; + if(_doc->HasOpenCommand()) return; @@ -247,6 +250,8 @@ CORBA::Object_ptr SALOMEDS_Study_i::ConvertIORToObject(const char* theIOR) //============================================================================ char* SALOMEDS_Study_i::GetPersistentReference() { + SALOMEDS::Locker lock; + return URL(); } //============================================================================ @@ -256,6 +261,8 @@ char* SALOMEDS_Study_i::GetPersistentReference() //============================================================================ char* SALOMEDS_Study_i::GetTransientReference() { + SALOMEDS::Locker lock; + CORBA::String_var IOR; Handle(SALOMEDS_IORAttribute) Att; @@ -277,6 +284,8 @@ char* SALOMEDS_Study_i::GetTransientReference() //============================================================================ CORBA::Boolean SALOMEDS_Study_i::IsEmpty() { + SALOMEDS::Locker lock; + if (_doc.IsNull()) return true; return _doc->IsEmpty(); } @@ -289,6 +298,8 @@ CORBA::Boolean SALOMEDS_Study_i::IsEmpty() SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent(const char* theComponentName) { + SALOMEDS::Locker lock; + bool anIsFound = false; SALOMEDS::SComponent_var aSComponent; SALOMEDS_SComponentIterator_i aComponentIter(this,_doc); @@ -310,6 +321,8 @@ SALOMEDS_Study_i::FindComponent(const char* theComponentName) //============================================================================ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID) { + SALOMEDS::Locker lock; + // Iterate on each components defined in the study // Get the component ID and compare with aComponentID bool _find = false; @@ -341,6 +354,8 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponen //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* theObjectName) { + SALOMEDS::Locker lock; + // Iterate to all components defined in the study // After testing the component name, iterate in all objects defined under // components (function _FindObject) @@ -371,6 +386,8 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* theObjectName) //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) { + SALOMEDS::Locker lock; + // Convert aSO->GetID in TDF_Label. TDF_Label Lab; TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab); @@ -389,6 +406,8 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID) { + SALOMEDS::Locker lock; + // Convert aSO->GetID in TDF_Label. TDF_Label Lab; TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True); @@ -409,6 +428,8 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName(const char* theObjectName, const char* theComponentName) { + SALOMEDS::Locker lock; + SALOMEDS::Study::ListOfSObject_var aListOfSObj = new SALOMEDS::Study::ListOfSObject ; aListOfSObj->length(0); @@ -454,6 +475,8 @@ SALOMEDS_Study_i::FindObjectByName(const char* theObjectName, //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* theObjectIOR) { + SALOMEDS::Locker lock; + // firstly searching in the datamap for optimization char* anIOR = const_cast(theObjectIOR); if(myIORLabels.IsBound(anIOR)){ @@ -503,6 +526,8 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* theObjectIOR) //============================================================================ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath) { + SALOMEDS::Locker lock; + TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aToken; SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_nil(); int i = 1, aLength = aPath.Length(); @@ -563,6 +588,8 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath) //============================================================================ char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject) { + SALOMEDS::Locker lock; + TCollection_AsciiString aPath(""); if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString()); @@ -607,6 +634,8 @@ char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject) //============================================================================ void SALOMEDS_Study_i::SetContext(const char* thePath) { + SALOMEDS::Locker lock; + if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory(); TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""); bool isInvalid = false; @@ -644,6 +673,8 @@ void SALOMEDS_Study_i::SetContext(const char* thePath) //============================================================================ char* SALOMEDS_Study_i::GetContext() { + SALOMEDS::Locker lock; + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); @@ -657,6 +688,8 @@ char* SALOMEDS_Study_i::GetContext() */ //============================================================================ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext) { + SALOMEDS::Locker lock; + TColStd_SequenceOfExtendedString aResultSeq; SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; TDF_Label aLabel; @@ -694,6 +727,8 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext */ //============================================================================ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext) { + SALOMEDS::Locker lock; + TColStd_SequenceOfExtendedString aResultSeq; SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; TDF_Label aLabel; @@ -734,6 +769,8 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theCont */ //============================================================================ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) { + SALOMEDS::Locker lock; + TColStd_SequenceOfExtendedString aResultSeq; SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; TDF_Label aLabel; @@ -777,6 +814,8 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) */ //============================================================================ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext) { + SALOMEDS::Locker lock; + TColStd_SequenceOfExtendedString aResultSeq; SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; TDF_ChildIterator anIter(_doc->Main(), Standard_False); // iterate all subchildren at first level @@ -802,6 +841,8 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theCont SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSObject) { + SALOMEDS::Locker lock; + SALOMEDS_ChildIterator_i* aServant = new SALOMEDS_ChildIterator_i(GetChildIterator(theSObject)); @@ -824,6 +865,8 @@ SALOMEDS_Study_i::GetChildIterator(SALOMEDS::SObject_ptr theSObject) SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() { + SALOMEDS::Locker lock; + SALOMEDS_SComponentIterator_i* aServant = new SALOMEDS_SComponentIterator_i(GetComponentIterator()); @@ -843,6 +886,8 @@ SALOMEDS_Study_i::GetComponentIterator() //============================================================================ SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() { + SALOMEDS::Locker lock; + return _UseCaseBuilder->_this(); } @@ -858,6 +903,8 @@ SALOMEDS_StudyBuilder_i* SALOMEDS_Study_i::GetBuilder() SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() { + SALOMEDS::Locker lock; + return GetBuilder()->_this(); } @@ -868,6 +915,8 @@ SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() //============================================================================ char* SALOMEDS_Study_i::Name() { + SALOMEDS::Locker lock; + return CORBA::string_dup(_name); } @@ -878,6 +927,8 @@ char* SALOMEDS_Study_i::Name() //============================================================================ void SALOMEDS_Study_i::Name(const char* name) { + SALOMEDS::Locker lock; + _name = new char[strlen(name) +1]; strcpy(_name,name); } @@ -889,6 +940,8 @@ void SALOMEDS_Study_i::Name(const char* name) //============================================================================ CORBA::Boolean SALOMEDS_Study_i::IsSaved() { + SALOMEDS::Locker lock; + return _isSaved; } @@ -899,6 +952,8 @@ CORBA::Boolean SALOMEDS_Study_i::IsSaved() //============================================================================ void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save) { + SALOMEDS::Locker lock; + _isSaved = save; } @@ -909,6 +964,8 @@ void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save) //============================================================================ CORBA::Boolean SALOMEDS_Study_i::IsModified() { + SALOMEDS::Locker lock; + // True if is modified and not saved if (_doc->IsModified()) if (!_isSaved) return true; @@ -923,6 +980,8 @@ CORBA::Boolean SALOMEDS_Study_i::IsModified() //============================================================================ char* SALOMEDS_Study_i::URL() { + SALOMEDS::Locker lock; + if(!_URL) { _URL = new char[1]; _URL[0] = (char)0; @@ -937,6 +996,8 @@ char* SALOMEDS_Study_i::URL() //============================================================================ void SALOMEDS_Study_i::URL(const char* url) { + SALOMEDS::Locker lock; + if (_URL) delete [] _URL; _URL = new char[strlen(url) +1]; strcpy(_URL,url); @@ -1013,15 +1074,21 @@ SALOMEDS_Study_i::_FindObjectIOR(TDF_Label theLabel, CORBA::Short SALOMEDS_Study_i::StudyId() { + SALOMEDS::Locker lock; + return _StudyId; } void SALOMEDS_Study_i::StudyId(CORBA::Short id) { + SALOMEDS::Locker lock; + _StudyId = id; } void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) { + SALOMEDS::Locker lock; + TDF_Label aLabel; CORBA::String_var anEn = CORBA::string_dup(anEntry); CORBA::String_var IOR = CORBA::string_dup(anIOR); @@ -1038,6 +1105,8 @@ void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribu } SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) { + SALOMEDS::Locker lock; + SALOMEDS::GenericAttribute_ptr aTarget; if (anObject->FindAttribute(aTarget,"AttributeTarget")) { return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get(); @@ -1049,6 +1118,8 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObj SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(){ + SALOMEDS::Locker lock; + SALOMEDS::SObject_var aSObject = FindObjectID("0:1"); SALOMEDS::GenericAttribute_var anAttr = @@ -1058,6 +1129,8 @@ SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(){ } char* SALOMEDS_Study_i::GetLastModificationDate() { + SALOMEDS::Locker lock; + SALOMEDS::AttributeStudyProperties_var aProp = GetProperties(); SALOMEDS::StringSeq_var aNames; SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; @@ -1071,6 +1144,8 @@ char* SALOMEDS_Study_i::GetLastModificationDate() { } SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() { + SALOMEDS::Locker lock; + SALOMEDS::AttributeStudyProperties_var aProp = GetProperties(); SALOMEDS::StringSeq_var aNames; SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; @@ -1098,6 +1173,8 @@ SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() { //============================================================================ void SALOMEDS_Study_i::Close() { + SALOMEDS::Locker lock; + SALOMEDS_SComponentIterator_i itcomponent(this,_doc); const CORBA::ORB_var& anORB = GetORB(); @@ -1114,8 +1191,11 @@ void SALOMEDS_Study_i::Close() if (!CORBA::is_nil(obj)) { SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; - if (!anEngine->_is_nil()) + if (!anEngine->_is_nil()){ + SALOMEDS::unlock(); anEngine->Close(sco); + SALOMEDS::lock(); + } } } } @@ -1136,6 +1216,8 @@ void SALOMEDS_Study_i::Close() */ //============================================================================ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { + SALOMEDS::Locker lock; + if (!GetBuilder()->HasOpenCommand()) return; try { CORBA::Object_var obj = GetORB()->string_to_object(theIOR); @@ -1152,6 +1234,8 @@ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { } void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { + SALOMEDS::Locker lock; + if (!GetBuilder()->HasOpenCommand()) return; try { CORBA::Object_var obj = GetORB()->string_to_object(theIOR); @@ -1173,6 +1257,8 @@ void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { */ //============================================================================ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { + SALOMEDS::Locker lock; + int anIndex; int anOld; @@ -1236,6 +1322,8 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) { */ //============================================================================ void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) { + SALOMEDS::Locker lock; + myNbUndos += theWay; // remove current postponed if (myNbPostponed.Last() > 0) diff --git a/src/SALOMEGUI/QAD_Application.cxx b/src/SALOMEGUI/QAD_Application.cxx index c58e5f57f..ef2a9c39d 100644 --- a/src/SALOMEGUI/QAD_Application.cxx +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -1279,7 +1279,9 @@ void QAD_Application::onStudyClosed(QAD_Study* study) void QAD_Application::onActiveStudyChanged( QAD_Study* oldActiveStudy, QAD_Study* newActiveStudy ) { - getDesktop()->onActiveStudyChanged(); + // san -- Check added: see comment by P.Rascle to PAL8065 about poor performance + if ( oldActiveStudy != newActiveStudy ) + getDesktop()->onActiveStudyChanged(); if ( oldActiveStudy ) QAD_ASSERT( disconnect( oldActiveStudy, SIGNAL(docOperationTerminated( bool )), diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in index f7f5d5a65..c862428f3 100644 --- a/src/Utils/Makefile.in +++ b/src/Utils/Makefile.in @@ -46,7 +46,8 @@ EXPORT_HEADERS= \ Utils_SINGLETON.hxx \ Utils_DESTRUCTEUR_GENERIQUE.hxx \ Utils_ExceptHandlers.hxx \ - Utils_SignalsHandler.h + Utils_SignalsHandler.h \ + Utils_Mutex.hxx EXPORT_PYSCRIPTS = Utils_Identity.py SALOME_utilities.py # Libraries targets @@ -58,7 +59,8 @@ LIB_SRC = OpUtil.cxx Utils_Timer.cxx duplicate.cxx \ Utils_Identity.cxx Utils_ORB_INIT.cxx \ Utils_DESTRUCTEUR_GENERIQUE.cxx \ Utils_ExceptHandlers.cxx \ - Utils_SignalsHandler.cxx + Utils_SignalsHandler.cxx \ + Utils_Mutex.cxx LIB_SERVER_IDL = SALOME_Exception.idl diff --git a/src/Utils/Utils_Mutex.cxx b/src/Utils/Utils_Mutex.cxx new file mode 100644 index 000000000..0aa3e4514 --- /dev/null +++ b/src/Utils/Utils_Mutex.cxx @@ -0,0 +1,85 @@ +// SALOME Utils : general SALOME's definitions and tools +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: Utils_Mutex.cxx +// Author: Sergey ANIKIN +// Module : SALOME +// $Header$ + + +#include + +Utils_Mutex::Utils_Mutex() +: myCount( 0 ) +{ + pthread_mutex_init( &myMutex, 0 ); + pthread_mutex_init( &myHelperMutex, 0 ); +} + +Utils_Mutex::~Utils_Mutex() +{ + pthread_mutex_destroy( &myHelperMutex ); + pthread_mutex_destroy( &myMutex ); +} + +void Utils_Mutex::lock() +{ + pthread_mutex_lock( &myHelperMutex ); + + if ( myCount > 0 && myThread == pthread_self() ) { + myCount++; + } + else { + pthread_mutex_unlock( &myHelperMutex ); + pthread_mutex_lock( &myMutex ); + pthread_mutex_lock( &myHelperMutex ); + myCount = 1; + myThread = pthread_self(); + } + + pthread_mutex_unlock( &myHelperMutex ); +} + +void Utils_Mutex::unlock() +{ + pthread_mutex_lock( &myHelperMutex ); + + if ( myThread == pthread_self() ) { + if ( myCount && (--myCount) < 1 ) { + myCount = 0; + pthread_mutex_unlock( &myMutex ); + } + } + + pthread_mutex_unlock( &myHelperMutex ); +} + +Utils_Locker::Utils_Locker( Utils_Mutex* mutex ) +: myMutex( mutex ) +{ + if ( myMutex ) myMutex->lock(); +} + +Utils_Locker::~Utils_Locker() +{ + if ( myMutex ) myMutex->unlock(); +} diff --git a/src/Utils/Utils_Mutex.hxx b/src/Utils/Utils_Mutex.hxx new file mode 100644 index 000000000..d33df2211 --- /dev/null +++ b/src/Utils/Utils_Mutex.hxx @@ -0,0 +1,59 @@ +// SALOME Utils : general SALOME's definitions and tools +// +// Copyright (C) 2003 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// File: Utils_Mutex.hxx +// Author: Sergey ANIKIN +// Module : SALOME +// $Header$ + + +#ifndef Utils_Mutex_HeaderFile +#define Utils_Mutex_HeaderFile + +#include + +class Utils_Mutex +{ +public: + Utils_Mutex(); + ~Utils_Mutex(); + + void lock(); + void unlock(); + +private: + pthread_mutex_t myMutex; + pthread_mutex_t myHelperMutex; + pthread_t myThread; + int myCount; +}; + +class Utils_Locker +{ +public: + Utils_Locker( Utils_Mutex* ); + virtual ~Utils_Locker(); + +private: + Utils_Mutex* myMutex; +}; + +#endif