From ec64825655b99b08182ef682868ccb732edb3c2a Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 2 Feb 2006 10:33:36 +0000 Subject: [PATCH] PR: mergefrom branch BR_V3_1_0_PR tag mergeto_trunk_02feb06 --- bin/createAppli.sh | 14 +- bin/runSalome.py | 14 +- idl/SALOMEDS.idl | 8 +- salome_adm/unix/config_files/check_boost.m4 | 36 ++- salome_adm/unix/config_files/check_lam.m4 | 17 ++ .../unix/config_files/check_pthreads.m4 | 2 + salome_adm/unix/make_commence.in | 1 + src/Communication/ReceiverFactory.cxx | 4 +- src/Communication/Receivers.cxx | 18 +- src/Communication/Receivers.hxx | 14 +- src/Communication/SALOME_Comm_i.cxx | 2 +- src/SALOMEDS/SALOMEDS_AttributeComment.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeDrawable.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx | 7 +- src/SALOMEDS/SALOMEDS_AttributeExpandable.cxx | 18 +- .../SALOMEDS_AttributeExpandable_i.cxx | 7 +- .../SALOMEDS_AttributeExternalFileDef.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeFileType.cxx | 17 +- src/SALOMEDS/SALOMEDS_AttributeFlags.cxx | 20 +- src/SALOMEDS/SALOMEDS_AttributeGraphic.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeIOR.cxx | 17 +- src/SALOMEDS/SALOMEDS_AttributeInteger.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeName.cxx | 17 +- src/SALOMEDS/SALOMEDS_AttributeOpened.cxx | 13 +- .../SALOMEDS_AttributePersistentRef.cxx | 17 +- src/SALOMEDS/SALOMEDS_AttributePixMap.cxx | 22 +- src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx | 14 +- .../SALOMEDS_AttributePythonObject.cxx | 23 +- src/SALOMEDS/SALOMEDS_AttributeReal.cxx | 15 +- src/SALOMEDS/SALOMEDS_AttributeSelectable.cxx | 13 +- .../SALOMEDS_AttributeSequenceOfInteger.cxx | 62 ++-- .../SALOMEDS_AttributeSequenceOfReal.cxx | 59 ++-- .../SALOMEDS_AttributeStudyProperties.cxx | 33 ++- .../SALOMEDS_AttributeTableOfInteger.cxx | 176 +++++++---- .../SALOMEDS_AttributeTableOfReal.cxx | 175 ++++++----- .../SALOMEDS_AttributeTableOfString.cxx | 196 +++++++----- src/SALOMEDS/SALOMEDS_AttributeTarget.cxx | 22 +- src/SALOMEDS/SALOMEDS_AttributeTextColor.cxx | 17 +- .../SALOMEDS_AttributeTextHighlightColor.cxx | 19 +- src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx | 133 ++++++--- src/SALOMEDS/SALOMEDS_AttributeUserID.cxx | 14 +- src/SALOMEDS/SALOMEDS_ChildIterator.cxx | 28 +- src/SALOMEDS/SALOMEDS_Driver_i.cxx | 68 +++-- src/SALOMEDS/SALOMEDS_GenericAttribute.cxx | 23 +- src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx | 20 +- src/SALOMEDS/SALOMEDS_SComponent.cxx | 18 +- src/SALOMEDS/SALOMEDS_SComponentIterator.cxx | 28 +- src/SALOMEDS/SALOMEDS_SObject.cxx | 88 ++++-- src/SALOMEDS/SALOMEDS_Study.cxx | 280 ++++++++++++------ src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 249 ++++++++++------ src/SALOMEDS/SALOMEDS_StudyManager.cxx | 79 +++-- src/SALOMEDS/SALOMEDS_StudyManager.hxx | 8 +- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 24 +- src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 8 +- src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx | 72 ++++- src/SALOMEDS/SALOMEDS_UseCaseIterator.cxx | 22 +- .../SALOMEDSClient_StudyManager.hxx | 8 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 21 +- .../SALOMEDSImpl_StudyBuilder.cxx | 46 ++- 60 files changed, 1644 insertions(+), 792 deletions(-) diff --git a/bin/createAppli.sh b/bin/createAppli.sh index c6c4de072..1ff6ed6de 100755 --- a/bin/createAppli.sh +++ b/bin/createAppli.sh @@ -3,5 +3,15 @@ comName=`which $0` rep=`dirname $comName` -cp -r $rep/appliskel $1 -chmod +x $1/*.sh $1/run* $1/envd +if [ $# -ne 1 ] + echo "--- usage:" + echo $0 AppliName + echo "--- In which AppliName is a directory to create with SALOME application scripts" +elif [ -d $1] + echo $1 "directory already exists, nothing done" +else + mkdir -p $1 + cp -r $rep/appliskel/* $1 + cp $rep/appliskel/.bashrc $1 + chmod +x $1/*.sh $1/run* $1/envd +fi \ No newline at end of file diff --git a/bin/runSalome.py b/bin/runSalome.py index 9d0a66971..98ff0a19f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -65,7 +65,7 @@ def get_config(): to_remove_list=[] for module in modules_list : - module_variable=module.upper()+"_ROOT_DIR" + module_variable=module+"_ROOT_DIR" if not os.environ.has_key(module_variable): print "*******************************************************" print "*" @@ -155,10 +155,18 @@ def set_env(args, modules_list, modules_root_dir): pass if args.has_key("SMESH_plugins"): for plugin in args["SMESH_plugins"]: - if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + plugin_root = "" + if os.environ.has_key(plugin+"_ROOT_DIR"): + plugin_root = os.environ[plugin+"_ROOT_DIR"] + else: + # workaround to avoid modifications of existing environment + if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] + pass + pass + if plugin_root != "": os.environ["SMESH_MeshersList"] \ = os.environ["SMESH_MeshersList"]+":"+plugin - plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] if not os.environ.has_key("SALOME_"+plugin+"Resources"): os.environ["SALOME_"+plugin+"Resources"] \ = plugin_root+"/share/"+args["appname"]+"/resources" diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 7c0844a31..de883d82e 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -695,13 +695,13 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
See also an example of this method usage in batchmode of %SALOME application. */ - void Save(in Study aStudy, in boolean theMultiFile); + boolean Save(in Study aStudy, in boolean theMultiFile); /*! \brief Saving a study in a ASCII file (or files). Saves a study in an ASCII format file (or files). \param theMultiFile If this parameter is True the study will be saved in several files. */ - void SaveASCII(in Study aStudy, in boolean theMultiFile); + boolean SaveASCII(in Study aStudy, in boolean theMultiFile); /*! \brief Saving the study in a specified HDF file (or files). Saves the study in a specified file (or files). @@ -711,7 +711,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
See also an example of this method usage in batchmode of %SALOME application. */ - void SaveAs(in URL aUrl, // if the file already exists + boolean SaveAs(in URL aUrl, // if the file already exists in Study aStudy, in boolean theMultiFile); // overwrite (as option) /*! \brief Saving the study in a specified ASCII file (or files). @@ -722,7 +722,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin \param aStudy The study which will be saved \param theMultiFile If this parameter is True the study will be saved in several files. */ - void SaveAsASCII(in URL aUrl, // if the file already exists + boolean SaveAsASCII(in URL aUrl, // if the file already exists in Study aStudy, in boolean theMultiFile); // overwrite (as option) diff --git a/salome_adm/unix/config_files/check_boost.m4 b/salome_adm/unix/config_files/check_boost.m4 index 215ce8cf5..b5e475ffa 100644 --- a/salome_adm/unix/config_files/check_boost.m4 +++ b/salome_adm/unix/config_files/check_boost.m4 @@ -28,6 +28,13 @@ AC_LANG_CPLUSPLUS AC_SUBST(BOOST_CPPFLAGS) BOOST_CPPFLAGS="" + +AC_SUBST(BOOST_LIBS) +BOOST_LIBS="" + +AC_SUBST(BOOST_LIBTHREAD) +BOOST_LIBTHREAD="" + boost_ok=no if test -z ${BOOSTDIR}; then @@ -37,17 +44,42 @@ if test -z ${BOOSTDIR}; then fi else AC_MSG_RESULT(\$BOOSTDIR = ${BOOSTDIR}) - AC_CHECKING(for boost/shared_ptr.hpp header file) + dnl BOOST headers + AC_CHECKING(for boost/shared_ptr.hpp header file) CPPFLAGS_old="${CPPFLAGS}" - BOOST_CPPFLAGS="-I${BOOSTDIR}" + BOOST_CPPFLAGS="-I${BOOSTDIR}/include" CPPFLAGS="${CPPFLAGS} ${BOOST_CPPFLAGS}" AC_CHECK_HEADER(boost/shared_ptr.hpp,boost_ok=yes,boost_ok=no) CPPFLAGS="${CPPFLAGS_old}" + + if test "x${boost_ok}" = "xyes" ; then + AC_MSG_RESULT(\$BOOST_CPPFLAGS = ${BOOST_CPPFLAGS}) + dnl BOOST libs + AC_CHECKING(for libboost_thread-mt.so library file) + AC_CHECK_FILE(${BOOSTDIR}/lib/libboost_thread-mt.so,boost_ok=yes,boost_ok=no) + if test "x${boost_ok}" = "xyes" ; then + BOOST_LIBS="-L${BOOSTDIR}/lib" + AC_MSG_RESULT(\$BOOST_LIBS = ${BOOST_LIBS}) + BOOST_LIBTHREAD="libboost_thread-mt.so" + AC_MSG_RESULT(\$BOOST_LIBTHREAD = ${BOOST_LIBTHREAD}) + else + AC_CHECKING(for libboost_thread.so library file) + AC_CHECK_FILE(${BOOSTDIR}/lib/libboost_thread.so,boost_ok=yes,boost_ok=no) + if test "x${boost_ok}" = "xyes" ; then + BOOST_LIBS="-L${BOOSTDIR}/lib" + AC_MSG_RESULT(\$BOOST_LIBS = ${BOOST_LIBS}) + BOOST_LIBTHREAD="libboost_thread.so" + AC_MSG_RESULT(\$BOOST_LIBTHREAD = ${BOOST_LIBTHREAD}) + fi + fi + fi fi +AC_MSG_RESULT(for boost: $boost_ok) + AC_LANG_RESTORE ])dnl diff --git a/salome_adm/unix/config_files/check_lam.m4 b/salome_adm/unix/config_files/check_lam.m4 index d15fdde31..4a9941e2c 100644 --- a/salome_adm/unix/config_files/check_lam.m4 +++ b/salome_adm/unix/config_files/check_lam.m4 @@ -88,8 +88,25 @@ if test "$WITHLAM" = yes; then AC_CHECK_LIB(mpi,MPI_Init,WITHLAM="yes",WITHLAM="no") if test "$WITHLAM" = "yes";then MPI_LIBS="-lmpi $MPI_LIBS" + LIBS="-lmpi $LIBS" fi + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + LIBS="-llammpi++ $LIBS" + AC_MSG_CHECKING(for MPI_Init in -llammpi++) + AC_TRY_LINK([ + #include + ], [MPI::Init();], + WITHLAM="yes",WITHLAM="no") + if test "$WITHLAM" = "yes";then + AC_MSG_RESULT(yes) + MPI_LIBS="-llammpi++ $MPI_LIBS" + else + AC_MSG_RESULT(no) + fi + AC_LANG_RESTORE + AC_CHECK_LIB(mpi,MPI_Publish_name,WITHMPI2="yes",WITHMPI2="no") fi diff --git a/salome_adm/unix/config_files/check_pthreads.m4 b/salome_adm/unix/config_files/check_pthreads.m4 index 80aef2aad..d5033889e 100644 --- a/salome_adm/unix/config_files/check_pthreads.m4 +++ b/salome_adm/unix/config_files/check_pthreads.m4 @@ -38,6 +38,8 @@ if test $flag = no; then AC_CHECK_LIB(posix4,nanosleep, LIBS_PTHREADS="-lposix4",LIBS_PTHREADS="") AC_CHECK_LIB(pthread,pthread_mutex_lock, LIBS_PTHREADS="-lpthread $LIBS_PTHREADS",LIBS_PTHREADS="") +else + LDFLAGS="-pthread $LDFLAGS" fi if test $flag = no && x$LIBS_PTHREADS = x; then diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index acd9fc70a..31535c4a6 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -42,6 +42,7 @@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ # BOOST Library BOOST_CPPFLAGS = @BOOST_CPPFLAGS@ +BOOST_LIBS = @BOOST_LIBS@ # OpenPBS diff --git a/src/Communication/ReceiverFactory.cxx b/src/Communication/ReceiverFactory.cxx index f404a7ec3..94743bfae 100644 --- a/src/Communication/ReceiverFactory.cxx +++ b/src/Communication/ReceiverFactory.cxx @@ -115,7 +115,7 @@ double *ReceiverFactory::getValueOneShot(SALOME::SenderDouble_ptr sender,long &s else if(!CORBA::is_nil(mpi_ptr)) { CORBA::release(sender); - MPIReceiver rec(mpi_ptr); + MPIReceiver rec(mpi_ptr); return rec.getValue(size); } #endif @@ -165,7 +165,7 @@ int *ReceiverFactory::getValueOneShot(SALOME::SenderInt_ptr sender,long &size)th else if(!CORBA::is_nil(mpi_ptr)) { CORBA::release(sender); - MPIReceiver rec(mpi_ptr); + MPIReceiver rec(mpi_ptr); return rec.getValue(size); } #endif diff --git a/src/Communication/Receivers.cxx b/src/Communication/Receivers.cxx index f97b4a1a4..f2ce1fa89 100644 --- a/src/Communication/Receivers.cxx +++ b/src/Communication/Receivers.cxx @@ -154,17 +154,17 @@ T *CorbaWCWithCopyReceiver::get #ifdef HAVE_MPI2 -template -MPIReceiver::MPIReceiver(CorbaSender mySender):_mySender(mySender){ +template +MPIReceiver::MPIReceiver(CorbaSender mySender):_mySender(mySender){ } -template -MPIReceiver::~MPIReceiver(){ +template +MPIReceiver::~MPIReceiver(){ _mySender->release(); } -template -T *MPIReceiver::getDistValue(long &size){ +template +T *MPIReceiver::getDistValue(long &size){ int i=0; int myproc; int sproc; @@ -211,15 +211,15 @@ T *MPIReceiver::getDistValue(long &size){ } MPI_Recv( &_n, 1, MPI_LONG, sproc,p->tag1,com,&status); _v = new T[_n]; - MPI_Recv( _v, _n, T2, sproc,p->tag2,com,&status); + MPI_Recv( _v, _n, MPITRAITS::MpiType, sproc,p->tag2,com,&status); _mySender->close(p); MPI_Comm_disconnect( &com ); size=_n; return _v; } -template -T *MPIReceiver::getValue(long &size) +template +T *MPIReceiver::getValue(long &size) { return Receiver::getValue(size,_mySender); } diff --git a/src/Communication/Receivers.hxx b/src/Communication/Receivers.hxx index 203bf64dc..2dd44a854 100644 --- a/src/Communication/Receivers.hxx +++ b/src/Communication/Receivers.hxx @@ -94,7 +94,19 @@ private: /*! Receiver for MPI transfert. */ -template +template +struct MPITRAITS +{ + static MPI_Datatype MpiType; +}; + +template<> +MPI_Datatype MPITRAITS::MpiType=MPI_DOUBLE; + +template<> +MPI_Datatype MPITRAITS::MpiType=MPI_INT; + +template class MPIReceiver : public Receiver { private: diff --git a/src/Communication/SALOME_Comm_i.cxx b/src/Communication/SALOME_Comm_i.cxx index f886b5387..632ce7a73 100644 --- a/src/Communication/SALOME_Comm_i.cxx +++ b/src/Communication/SALOME_Comm_i.cxx @@ -272,7 +272,7 @@ SALOME::MPISender::param* SALOME_MPISender_i::getParam() void SALOME_MPISender_i::send() { _type=getTypeOfDataTransmitted(); - _argsForThr=new (void *)[8]; + _argsForThr=new void *[8]; _argsForThr[0]=_portName; _argsForThr[1]=&_lgrTabToSend; _argsForThr[2]=(void *)_tabToSend; diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment.cxx b/src/SALOMEDS/SALOMEDS_AttributeComment.cxx index 0d936c740..3a54f00bb 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeComment.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeComment.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeComment.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributeComment::~SALOMEDS_AttributeComment() std::string SALOMEDS_AttributeComment::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeComment)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeComment):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributeComment::_narrow(_corba_impl)->Value(); return aValue; } void SALOMEDS_AttributeComment::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeComment)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeComment)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributeComment::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable.cxx index ac1abc62b..10d9c4df8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeDrawable.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,14 +41,20 @@ SALOMEDS_AttributeDrawable::~SALOMEDS_AttributeDrawable() bool SALOMEDS_AttributeDrawable::IsDrawable() { bool aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->IsDrawable(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->IsDrawable(); + } else aValue = SALOMEDS::AttributeDrawable::_narrow(_corba_impl)->IsDrawable(); return aValue; } - + void SALOMEDS_AttributeDrawable::SetDrawable(bool value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->SetDrawable((int)value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_local_impl)->SetDrawable((int)value); + } else SALOMEDS::AttributeDrawable::_narrow(_corba_impl)->SetDrawable(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx index 828b8add8..e74b2221f 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -28,16 +28,15 @@ using namespace std; -CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() +CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() { SALOMEDS::Locker lock; return (Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_impl)->IsDrawable() == 1); } - -void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) + +void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { SALOMEDS::Locker lock; CheckLocked(); Handle(SALOMEDSImpl_AttributeDrawable)::DownCast(_impl)->SetDrawable(value); } - diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable.cxx index 4dce54303..4f14f10b4 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable.cxx @@ -22,11 +22,13 @@ // Module : SALOME #include "SALOMEDS_AttributeExpandable.hxx" +#include "SALOMEDS.hxx" #include #include -SALOMEDS_AttributeExpandable::SALOMEDS_AttributeExpandable(const Handle(SALOMEDSImpl_AttributeExpandable)& theAttr) +SALOMEDS_AttributeExpandable::SALOMEDS_AttributeExpandable + (const Handle(SALOMEDSImpl_AttributeExpandable)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -40,14 +42,20 @@ SALOMEDS_AttributeExpandable::~SALOMEDS_AttributeExpandable() bool SALOMEDS_AttributeExpandable::IsExpandable() { bool aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->IsExpandable(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->IsExpandable(); + } else aValue = SALOMEDS::AttributeExpandable::_narrow(_corba_impl)->IsExpandable(); return aValue; } - + void SALOMEDS_AttributeExpandable::SetExpandable(bool value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->SetExpandable((int)value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_local_impl)->SetExpandable((int)value); + } else SALOMEDS::AttributeExpandable::_narrow(_corba_impl)->SetExpandable(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx index 257ab67a7..e62b60c8c 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -27,16 +27,15 @@ using namespace std; -CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() +CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() { SALOMEDS::Locker lock; return (Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_impl)->IsExpandable() == 1); } - -void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) + +void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) { SALOMEDS::Locker lock; CheckLocked(); Handle(SALOMEDSImpl_AttributeExpandable)::DownCast(_impl)->SetExpandable(value); } - diff --git a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef.cxx b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef.cxx index 2dc8a3c9c..9ea935ffe 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeExternalFileDef.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeExternalFileDef.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributeExternalFileDef::~SALOMEDS_AttributeExternalFileDef() std::string SALOMEDS_AttributeExternalFileDef::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeExternalFileDef):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributeExternalFileDef::_narrow(_corba_impl)->Value(); return aValue; } void SALOMEDS_AttributeExternalFileDef::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeExternalFileDef)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributeExternalFileDef::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeFileType.cxx b/src/SALOMEDS/SALOMEDS_AttributeFileType.cxx index ed535426a..797941a08 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeFileType.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeFileType.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeFileType.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributeFileType::~SALOMEDS_AttributeFileType() std::string SALOMEDS_AttributeFileType::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeFileType):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributeFileType::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeFileType::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeFileType)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributeFileType::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeFlags.cxx b/src/SALOMEDS/SALOMEDS_AttributeFlags.cxx index 5168f238b..935a7edee 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeFlags.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeFlags.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeFlags.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,14 +41,20 @@ SALOMEDS_AttributeFlags::~SALOMEDS_AttributeFlags() int SALOMEDS_AttributeFlags::GetFlags() { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Get(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Get(); + } else aValue = SALOMEDS::AttributeFlags::_narrow(_corba_impl)->GetFlags(); return aValue; } void SALOMEDS_AttributeFlags::SetFlags(int theFlags) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Set(theFlags); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl)->Set(theFlags); + } else SALOMEDS::AttributeFlags::_narrow(_corba_impl)->SetFlags(theFlags); } @@ -58,12 +65,13 @@ bool SALOMEDS_AttributeFlags::Get(int theFlag) void SALOMEDS_AttributeFlags::Set(int theFlag, bool theValue) { - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeFlags) anAttr = Handle(SALOMEDSImpl_AttributeFlags)::DownCast(_local_impl); - if ( theValue ) - anAttr->Set( anAttr->Get() | theFlag ); + if (theValue) + anAttr->Set(anAttr->Get() | theFlag); else - anAttr->Set( anAttr->Get() & ~theFlag ); + anAttr->Set(anAttr->Get() & ~theFlag); } else SALOMEDS::AttributeFlags::_narrow(_corba_impl)->Set(theFlag, theValue); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeGraphic.cxx b/src/SALOMEDS/SALOMEDS_AttributeGraphic.cxx index e0dc038d9..38b754279 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeGraphic.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeGraphic.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeGraphic.hxx" +#include "SALOMEDS.hxx" #include #include @@ -38,16 +39,22 @@ SALOMEDS_AttributeGraphic::~SALOMEDS_AttributeGraphic() {} -bool SALOMEDS_AttributeGraphic:: GetVisibility(int theViewId) +bool SALOMEDS_AttributeGraphic::GetVisibility(int theViewId) { bool aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->GetVisibility(theViewId); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->GetVisibility(theViewId); + } else aValue = SALOMEDS::AttributeGraphic::_narrow(_corba_impl)->GetVisibility(theViewId); return aValue; } - + void SALOMEDS_AttributeGraphic::SetVisibility(int theViewId, bool theValue) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->SetVisibility(theViewId, theValue); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeGraphic)::DownCast(_local_impl)->SetVisibility(theViewId, theValue); + } else SALOMEDS::AttributeGraphic::_narrow(_corba_impl)->SetVisibility(theViewId, theValue); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR.cxx index de6ca253f..04b37485a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeIOR.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeIOR.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributeIOR::~SALOMEDS_AttributeIOR() std::string SALOMEDS_AttributeIOR::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeIOR):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributeIOR::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeIOR::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeIOR)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributeIOR::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger.cxx b/src/SALOMEDS/SALOMEDS_AttributeInteger.cxx index b32650bcd..f7d4addfb 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeInteger.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeInteger.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,14 +41,20 @@ SALOMEDS_AttributeInteger::~SALOMEDS_AttributeInteger() int SALOMEDS_AttributeInteger::Value() { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->Value(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->Value(); + } else aValue = SALOMEDS::AttributeInteger::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeInteger::SetValue(int value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->SetValue(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeInteger)::DownCast(_local_impl)->SetValue(value); + } else SALOMEDS::AttributeInteger::_narrow(_corba_impl)->SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx index c9d778adb..379fc58b6 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeLocalID.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,14 +41,20 @@ SALOMEDS_AttributeLocalID::~SALOMEDS_AttributeLocalID() int SALOMEDS_AttributeLocalID::Value() { int aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->Value(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->Value(); + } else aValue = SALOMEDS::AttributeLocalID::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeLocalID::SetValue(int value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->SetValue(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeLocalID)::DownCast(_local_impl)->SetValue(value); + } else SALOMEDS::AttributeLocalID::_narrow(_corba_impl)->SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeName.cxx b/src/SALOMEDS/SALOMEDS_AttributeName.cxx index b4b8d7b18..1fc1a1a8a 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeName.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeName.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeName.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributeName::~SALOMEDS_AttributeName() std::string SALOMEDS_AttributeName::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeName)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeName):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributeName::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeName::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeName)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeName)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributeName::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened.cxx index 7424a7498..a2c82dd81 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeOpened.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeOpened.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,13 +41,19 @@ SALOMEDS_AttributeOpened::~SALOMEDS_AttributeOpened() bool SALOMEDS_AttributeOpened::IsOpened() { bool aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->IsOpened(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->IsOpened(); + } else aValue = SALOMEDS::AttributeOpened::_narrow(_corba_impl)->IsOpened(); return aValue; } - + void SALOMEDS_AttributeOpened::SetOpened(bool value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->SetOpened((int)value); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeOpened)::DownCast(_local_impl)->SetOpened((int)value); + } else SALOMEDS::AttributeOpened::_narrow(_corba_impl)->SetOpened(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef.cxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef.cxx index 1ca0bf276..276cafe29 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePersistentRef.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributePersistentRef.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,15 +42,21 @@ SALOMEDS_AttributePersistentRef::~SALOMEDS_AttributePersistentRef() std::string SALOMEDS_AttributePersistentRef::Value() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_local_impl)->Value()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePersistentRef):: + DownCast(_local_impl)->Value()).ToCString(); + } else aValue = SALOMEDS::AttributePersistentRef::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributePersistentRef::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast(_local_impl)->SetValue((char*)value.c_str()); + } else SALOMEDS::AttributePersistentRef::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap.cxx index 21bf8a489..d82db803f 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributePixMap.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,7 +42,10 @@ SALOMEDS_AttributePixMap::~SALOMEDS_AttributePixMap() bool SALOMEDS_AttributePixMap::HasPixMap() { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->HasPixMap(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->HasPixMap(); + } else ret = SALOMEDS::AttributePixMap::_narrow(_corba_impl)->HasPixMap(); return ret; } @@ -49,15 +53,21 @@ bool SALOMEDS_AttributePixMap::HasPixMap() std::string SALOMEDS_AttributePixMap::GetPixMap() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->GetPixMap()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap):: + DownCast(_local_impl)->GetPixMap()).ToCString(); + } else aValue = SALOMEDS::AttributePixMap::_narrow(_corba_impl)->GetPixMap(); return aValue; } - + void SALOMEDS_AttributePixMap::SetPixMap(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->SetPixMap((char*)value.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_local_impl)->SetPixMap((char*)value.c_str()); + } else SALOMEDS::AttributePixMap::_narrow(_corba_impl)->SetPixMap(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx index 0c01c6e50..8ba8c973b 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx @@ -24,28 +24,30 @@ #include "SALOMEDS_AttributePixMap_i.hxx" #include "SALOMEDS.hxx" + #include using namespace std; -CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() +CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() { + SALOMEDS::Locker lock; return Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->HasPixMap(); } -char* SALOMEDS_AttributePixMap_i::GetPixMap() +char* SALOMEDS_AttributePixMap_i::GetPixMap() { SALOMEDS::Locker lock; - CORBA::String_var S = - CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->GetPixMap()).ToCString()); + CORBA::String_var S = + CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePixMap):: + DownCast(_impl)->GetPixMap()).ToCString()); return S._retn(); } -void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) +void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) { SALOMEDS::Locker lock; CheckLocked(); CORBA::String_var Str = CORBA::string_dup(value); Handle(SALOMEDSImpl_AttributePixMap)::DownCast(_impl)->SetPixMap(TCollection_ExtendedString(Str)); } - diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject.cxx index 71990e4db..789dd3618 100644 --- a/src/SALOMEDS/SALOMEDS_AttributePythonObject.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributePythonObject.hxx" +#include "SALOMEDS.hxx" #include #include @@ -41,7 +42,10 @@ SALOMEDS_AttributePythonObject::~SALOMEDS_AttributePythonObject() bool SALOMEDS_AttributePythonObject::IsScript() { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->IsScript(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->IsScript(); + } else ret = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->IsScript(); return ret; } @@ -49,15 +53,22 @@ bool SALOMEDS_AttributePythonObject::IsScript() std::string SALOMEDS_AttributePythonObject::GetObject() { std::string aValue; - if(_isLocal) - aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->GetObject()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributePythonObject):: + DownCast(_local_impl)->GetObject()).ToCString(); + } else aValue = SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->GetObject(); return aValue; } - + void SALOMEDS_AttributePythonObject::SetObject(const std::string& theSequence, bool IsScript) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributePythonObject)::DownCast(_local_impl)->SetObject((char*)theSequence.c_str(), IsScript); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributePythonObject):: + DownCast(_local_impl)->SetObject((char*)theSequence.c_str(), IsScript); + } else SALOMEDS::AttributePythonObject::_narrow(_corba_impl)->SetObject(theSequence.c_str(), IsScript); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal.cxx index 8d98f6cf1..e96837534 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeReal.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeReal.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,14 +41,20 @@ SALOMEDS_AttributeReal::~SALOMEDS_AttributeReal() double SALOMEDS_AttributeReal::Value() { double aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->Value(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->Value(); + } else aValue = SALOMEDS::AttributeReal::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeReal::SetValue(double value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->SetValue(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeReal)::DownCast(_local_impl)->SetValue(value); + } else SALOMEDS::AttributeReal::_narrow(_corba_impl)->SetValue(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable.cxx index 6ffb270f7..fb16c9907 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSelectable.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeSelectable.hxx" +#include "SALOMEDS.hxx" #include #include @@ -40,13 +41,19 @@ SALOMEDS_AttributeSelectable::~SALOMEDS_AttributeSelectable() bool SALOMEDS_AttributeSelectable::IsSelectable() { bool aValue; - if(_isLocal) aValue = (bool)Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->IsSelectable(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = (bool)Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->IsSelectable(); + } else aValue = SALOMEDS::AttributeSelectable::_narrow(_corba_impl)->IsSelectable(); return aValue; } - + void SALOMEDS_AttributeSelectable::SetSelectable(bool value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->SetSelectable((int)value); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSelectable)::DownCast(_local_impl)->SetSelectable((int)value); + } else SALOMEDS::AttributeSelectable::_narrow(_corba_impl)->SetSelectable(value); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger.cxx index fac549e3b..a2d861312 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger.cxx @@ -22,17 +22,19 @@ // Module : SALOME #include "SALOMEDS_AttributeSequenceOfInteger.hxx" +#include "SALOMEDS.hxx" #include #include #include -SALOMEDS_AttributeSequenceOfInteger -::SALOMEDS_AttributeSequenceOfInteger(const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr) +SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger + (const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger(SALOMEDS::AttributeSequenceOfInteger_ptr theAttr) +SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger + (SALOMEDS::AttributeSequenceOfInteger_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -42,15 +44,17 @@ SALOMEDS_AttributeSequenceOfInteger::~SALOMEDS_AttributeSequenceOfInteger() void SALOMEDS_AttributeSequenceOfInteger::Assign(const std::vector& other) { int i, aLength = other.size(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; - for(i = 0; i < aLength; i++) aSeq->Append(other[i]); + for (i = 0; i < aLength; i++) aSeq->Append(other[i]); Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Assign(aSeq); } else { SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = other[i]; + for (i = 0; i < aLength; i++) aSeq[i] = other[i]; SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Assign(aSeq); } } @@ -59,50 +63,70 @@ std::vector SALOMEDS_AttributeSequenceOfInteger::CorbaSequence() { std::vector aVector; int i, aLength; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeSequenceOfInteger) aSeqAttr; aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } else { - SALOMEDS::AttributeSequenceOfInteger_var aSeqAttr = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl); + SALOMEDS::AttributeSequenceOfInteger_var aSeqAttr = + SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } return aVector; } - + void SALOMEDS_AttributeSequenceOfInteger::Add(int value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Add(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Add(value); + } else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Add(value); } void SALOMEDS_AttributeSequenceOfInteger::Remove(int index) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Remove(index); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Remove(index); + } else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Remove(index); } - + void SALOMEDS_AttributeSequenceOfInteger::ChangeValue(int index, int value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->ChangeValue(index, value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->ChangeValue(index, value); + } else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->ChangeValue(index, value); } - + int SALOMEDS_AttributeSequenceOfInteger::Value(int index) { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Value(index); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Value(index); + } else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Value(index); return aValue; } - + int SALOMEDS_AttributeSequenceOfInteger::Length() { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)-> Length(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)-> Length(); + } else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)-> Length(); return aValue; } diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx index faffcaa29..9697594f8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal.cxx @@ -22,17 +22,19 @@ // Module : SALOME #include "SALOMEDS_AttributeSequenceOfReal.hxx" +#include "SALOMEDS.hxx" #include #include #include -SALOMEDS_AttributeSequenceOfReal -::SALOMEDS_AttributeSequenceOfReal(const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr) +SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal + (const Handle(SALOMEDSImpl_AttributeSequenceOfReal)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal(SALOMEDS::AttributeSequenceOfReal_ptr theAttr) +SALOMEDS_AttributeSequenceOfReal::SALOMEDS_AttributeSequenceOfReal + (SALOMEDS::AttributeSequenceOfReal_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -42,15 +44,17 @@ SALOMEDS_AttributeSequenceOfReal::~SALOMEDS_AttributeSequenceOfReal() void SALOMEDS_AttributeSequenceOfReal::Assign(const std::vector& other) { int i, aLength = other.size(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; - for(i = 0; i < aLength; i++) aSeq->Append(other[i]); + for (i = 0; i < aLength; i++) aSeq->Append(other[i]); Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Assign(aSeq); } else { SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = other[i]; + for (i = 0; i < aLength; i++) aSeq[i] = other[i]; SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Assign(aSeq); } } @@ -59,50 +63,69 @@ std::vector SALOMEDS_AttributeSequenceOfReal::CorbaSequence() { std::vector aVector; int i, aLength; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeSequenceOfReal) aSeqAttr; aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } else { SALOMEDS::AttributeSequenceOfReal_var aSeqAttr = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl); aLength = aSeqAttr->Length(); - for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); + for (i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i)); } return aVector; } - + void SALOMEDS_AttributeSequenceOfReal::Add(double value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Add(value); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Add(value); } void SALOMEDS_AttributeSequenceOfReal::Remove(int index) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Remove(index); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Remove(index); } - + void SALOMEDS_AttributeSequenceOfReal::ChangeValue(int index, double value) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->ChangeValue(index, value); + } else SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->ChangeValue(index, value); } - + double SALOMEDS_AttributeSequenceOfReal::Value(int index) { double aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)->Value(index); + } else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)->Value(index); return aValue; } - + int SALOMEDS_AttributeSequenceOfReal::Length() { int aValue; - if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = Handle(SALOMEDSImpl_AttributeSequenceOfReal)::DownCast(_local_impl)-> Length(); + } else aValue = SALOMEDS::AttributeSequenceOfReal::_narrow(_corba_impl)-> Length(); return aValue; } diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx index 8447a28dd..b56a728b1 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeStudyProperties.hxx" +#include "SALOMEDS.hxx" #include #include @@ -46,6 +47,8 @@ SALOMEDS_AttributeStudyProperties::~SALOMEDS_AttributeStudyProperties() void SALOMEDS_AttributeStudyProperties::SetUserName(const std::string& theName) { if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); anImpl->ChangeCreatorName((char*)theName.c_str()); @@ -57,6 +60,7 @@ std::string SALOMEDS_AttributeStudyProperties::GetUserName() { std::string aName; if (_isLocal) { + SALOMEDS::Locker lock; TCollection_ExtendedString S = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreatorName(); aName = TCollection_AsciiString(S).ToCString(); @@ -73,6 +77,8 @@ void SALOMEDS_AttributeStudyProperties::SetCreationDate (int theMinute, int theHour, int theDay, int theMonth, int theYear) { if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); int aTmp; @@ -96,6 +102,7 @@ bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute, { bool ret; if (_isLocal) { + SALOMEDS::Locker lock; ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast (_local_impl)->GetCreationDate(theMinute, theHour, theDay, theMonth, theYear); } else { @@ -117,6 +124,8 @@ bool SALOMEDS_AttributeStudyProperties::GetCreationDate(int& theMinute, void SALOMEDS_AttributeStudyProperties::SetCreationMode(const std::string& theMode) { if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; if (theMode == "from scratch") Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetCreationMode(1); else if (theMode == "copy from") @@ -131,6 +140,7 @@ std::string SALOMEDS_AttributeStudyProperties::GetCreationMode() { std::string aMode; if (_isLocal) { + SALOMEDS::Locker lock; int mode = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetCreationMode(); if (mode == 1) aMode = "from scratch"; if (mode == 2) aMode = "copy from"; @@ -142,8 +152,10 @@ std::string SALOMEDS_AttributeStudyProperties::GetCreationMode() void SALOMEDS_AttributeStudyProperties::SetModified(int theModified) { - if (_isLocal) + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetModified(theModified); + } else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetModified(theModified); } @@ -151,8 +163,10 @@ void SALOMEDS_AttributeStudyProperties::SetModified(int theModified) bool SALOMEDS_AttributeStudyProperties::IsModified() { bool ret; - if (_isLocal) + if (_isLocal) { + SALOMEDS::Locker lock; ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsModified(); + } else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsModified(); return ret; @@ -161,8 +175,10 @@ bool SALOMEDS_AttributeStudyProperties::IsModified() int SALOMEDS_AttributeStudyProperties::GetModified() { int isModified; - if (_isLocal) + if (_isLocal) { + SALOMEDS::Locker lock; isModified = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->GetModified(); + } else isModified = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetModified(); return isModified; @@ -170,8 +186,10 @@ int SALOMEDS_AttributeStudyProperties::GetModified() void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked) { - if (_isLocal) + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->SetLocked(theLocked); + } else SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->SetLocked(theLocked); } @@ -179,8 +197,10 @@ void SALOMEDS_AttributeStudyProperties::SetLocked(bool theLocked) bool SALOMEDS_AttributeStudyProperties::IsLocked() { bool ret; - if (_isLocal) + if (_isLocal) { + SALOMEDS::Locker lock; ret = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl)->IsLocked(); + } else ret = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->IsLocked(); return ret; @@ -194,6 +214,8 @@ void SALOMEDS_AttributeStudyProperties::SetModification(const std::string& theNa int theYear) { if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeStudyProperties) anImpl = Handle(SALOMEDSImpl_AttributeStudyProperties)::DownCast(_local_impl); anImpl->SetModification((char*)theName.c_str(), theMinute, theHour, theDay, theMonth, theYear); @@ -217,6 +239,7 @@ void SALOMEDS_AttributeStudyProperties::GetModificationsList(std::vector #include @@ -29,12 +30,13 @@ #include -SALOMEDS_AttributeTableOfInteger -::SALOMEDS_AttributeTableOfInteger(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr) +SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger + (const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger(SALOMEDS::AttributeTableOfInteger_ptr theAttr) +SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger + (SALOMEDS::AttributeTableOfInteger_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -44,35 +46,45 @@ SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger() void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str()); } std::string SALOMEDS_AttributeTableOfInteger::GetTitle() { std::string aStr; - if(_isLocal) - aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetTitle()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->GetTitle()).ToCString(); + } else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle(); return aStr; } void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->SetRowTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str()); } void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector& theTitles) { - CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitles(aSeq); } else { @@ -88,7 +100,8 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRowTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowTitles(); aLength = aSeq->Length(); @@ -104,26 +117,29 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRowTitles() void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle) { - CheckLocked(); - if(_isLocal) - Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->SetColumnTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str()); } void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector& theTitles) { - CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitles(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str(); SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq); } } @@ -132,41 +148,46 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetColumnTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnTitles(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles(); aLength = aSeq->length(); - for(i = 0; iSetRowUnit(theIndex, - (char*)theUnit.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->SetRowUnit(theIndex, (char*)theUnit.c_str()); + } else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str()); } void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector& theUnits) { - CheckLocked(); int aLength = theUnits.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnits(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq); } } @@ -175,16 +196,17 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRowUnits() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowUnits(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits(); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_AttributeTableOfInteger::GetRowUnits() int SALOMEDS_AttributeTableOfInteger::GetNbRows() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows(); + } else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows(); return aNb; } @@ -200,7 +225,10 @@ int SALOMEDS_AttributeTableOfInteger::GetNbRows() int SALOMEDS_AttributeTableOfInteger::GetNbColumns() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns(); + } else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns(); return aNb; @@ -208,9 +236,10 @@ int SALOMEDS_AttributeTableOfInteger::GetNbColumns() void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl); Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger; @@ -232,9 +261,10 @@ void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector& theData) void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl); Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger; @@ -249,7 +279,7 @@ void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector else { SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = theData[i]; + for (i = 0; i < aLength; i++) aSeq[i] = theData[i]; SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq); } } @@ -258,15 +288,16 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRow(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aRow; aRow = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowData(theRow); aLength = aRow->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aRow->Value(i)); } else { SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow); - for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]); + for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]); } return aVector; @@ -274,9 +305,10 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRow(int theRow) void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl); Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger; @@ -298,9 +330,10 @@ void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector& theData void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl); Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger; @@ -315,7 +348,7 @@ void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vecto else { SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq(); aColumn->length(aLength); - for(i = 0; i < aLength; i++) aColumn[i] = theData[i]; + for (i = 0; i < aLength; i++) aColumn[i] = theData[i]; SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theColumn, aColumn); } } @@ -324,26 +357,29 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aColumn; aColumn = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnData(theColumn); aLength = aColumn->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aColumn->Value(i)); } else { SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn); - for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]); + for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]); } return aVector; } void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn) { - CheckLocked(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; try { - Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn); - } + Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->PutValue(theValue, theRow, theColumn); + } catch(...) { throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); } @@ -356,7 +392,10 @@ void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int th bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn) { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn); + } else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn); return ret; } @@ -364,9 +403,11 @@ bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn) int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn) { int aValue; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { - aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetValue(theRow, theColumn); + aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger):: + DownCast(_local_impl)->GetValue(theRow, theColumn); } catch(...) { throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); @@ -382,21 +423,26 @@ std::vector SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aSet; aSet = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetSetRowIndices(theRow); aLength = aSet->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aSet->Value(i)); } else { - SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow); - for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } return aVector; } void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + } else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx index 68ccc2d42..bb7cf1f26 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeTableOfReal.hxx" +#include "SALOMEDS.hxx" #include #include @@ -30,8 +31,8 @@ #include -SALOMEDS_AttributeTableOfReal -::SALOMEDS_AttributeTableOfReal(const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr) +SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal + (const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -45,25 +46,34 @@ SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal() void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str()); } std::string SALOMEDS_AttributeTableOfReal::GetTitle() { std::string aStr; - if(_isLocal) - aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetTitle()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfReal):: + DownCast(_local_impl)->GetTitle()).ToCString(); + } else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle(); return aStr; } void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfReal):: + DownCast(_local_impl)->SetRowTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str()); } @@ -71,59 +81,65 @@ void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector& { CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitles(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq); } - } std::vector SALOMEDS_AttributeTableOfReal::GetRowTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowTitles(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles(); aLength = aSeq->length(); - for(i = 0; iSetColumnTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfReal):: + DownCast(_local_impl)->SetColumnTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str()); } void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector& theTitles) { - CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitles(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq); } } @@ -132,41 +148,46 @@ std::vector SALOMEDS_AttributeTableOfReal::GetColumnTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnTitles(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles(); aLength = aSeq->length(); - for(i = 0; iSetRowUnit(theIndex, - (char*)theUnit.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfReal):: + DownCast(_local_impl)->SetRowUnit(theIndex, (char*)theUnit.c_str()); + } else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str()); } void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector& theUnits) { - CheckLocked(); int aLength = theUnits.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnits(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq); } } @@ -175,16 +196,17 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRowUnits() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowUnits(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits(); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_AttributeTableOfReal::GetRowUnits() int SALOMEDS_AttributeTableOfReal::GetNbRows() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbRows(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbRows(); + } else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows(); return aNb; } @@ -200,17 +225,20 @@ int SALOMEDS_AttributeTableOfReal::GetNbRows() int SALOMEDS_AttributeTableOfReal::GetNbColumns() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbColumns(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbColumns(); + } else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns(); return aNb; - } void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfReal) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl); Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; @@ -225,16 +253,17 @@ void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector& theData) else { SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = theData[i]; + for (i = 0; i < aLength; i++) aSeq[i] = theData[i]; SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq); } } void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfReal) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl); Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; @@ -249,7 +278,7 @@ void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector else { SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = theData[i]; + for (i = 0; i < aLength; i++) aSeq[i] = theData[i]; SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq); } } @@ -258,15 +287,16 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRow(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfReal) aRow; aRow = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowData(theRow); aLength = aRow->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aRow->Value(i)); } else { SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow); - for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]); + for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]); } return aVector; @@ -274,9 +304,10 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRow(int theRow) void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfReal) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl); Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; @@ -291,16 +322,17 @@ void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector& theData else { SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq(); aColumn->length(aLength); - for(i = 0; i < aLength; i++) aColumn[i] = theData[i]; + for (i = 0; i < aLength; i++) aColumn[i] = theData[i]; SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn); } } void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfReal) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl); Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; @@ -315,7 +347,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vectorlength(aLength); - for(i = 0; i < aLength; i++) aColumn[i] = theData[i]; + for (i = 0; i < aLength; i++) aColumn[i] = theData[i]; SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theColumn, aColumn); } } @@ -324,25 +356,28 @@ std::vector SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfReal) aColumn; aColumn = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnData(theColumn); aLength = aColumn->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aColumn->Value(i)); } else { SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn); - for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]); + for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]); } return aVector; } void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn) { - CheckLocked(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; try { - Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn); + Handle(SALOMEDSImpl_AttributeTableOfReal):: + DownCast(_local_impl)->PutValue(theValue, theRow, theColumn); } catch(...) { throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); @@ -356,7 +391,10 @@ void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int th bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn) { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->HasValue(theRow, theColumn); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->HasValue(theRow, theColumn); + } else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn); return ret; } @@ -364,7 +402,8 @@ bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn) double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn) { double aValue; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { aValue = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetValue(theRow, theColumn); } @@ -382,21 +421,25 @@ std::vector SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aSet; aSet = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetSetRowIndices(theRow); aLength = aSet->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aSet->Value(i)); } else { SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow); - for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } return aVector; } void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + } else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx index 0978252c7..a999892a4 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeTableOfString.hxx" +#include "SALOMEDS.hxx" #include #include @@ -30,12 +31,13 @@ #include #include -SALOMEDS_AttributeTableOfString -::SALOMEDS_AttributeTableOfString(const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr) +SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString + (const Handle(SALOMEDSImpl_AttributeTableOfString)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString(SALOMEDS::AttributeTableOfString_ptr theAttr) +SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString + (SALOMEDS::AttributeTableOfString_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -45,85 +47,99 @@ SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString() void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str()); } std::string SALOMEDS_AttributeTableOfString::GetTitle() { std::string aStr; - if(_isLocal) - aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetTitle()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->GetTitle()).ToCString(); + } else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle(); return aStr; } void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->SetRowTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str()); } void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector& theTitles) { - CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowTitles(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq); } - } std::vector SALOMEDS_AttributeTableOfString::GetRowTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowTitles(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitles(); aLength = aSeq->length(); - for(i = 0; iSetColumnTitle(theIndex, - (char*)theTitle.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->SetColumnTitle(theIndex, (char*)theTitle.c_str()); + } else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str()); } void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector& theTitles) { - CheckLocked(); int aLength = theTitles.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetColumnTitles(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq); } } @@ -132,41 +148,46 @@ std::vector SALOMEDS_AttributeTableOfString::GetColumnTitles() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnTitles(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitles(); aLength = aSeq->length(); - for(i = 0; iSetRowUnit(theIndex, - (char*)theUnit.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->SetRowUnit(theIndex, (char*)theUnit.c_str()); + } else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str()); } void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector& theUnits) { - CheckLocked(); int aLength = theUnits.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; - for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); + for (i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str()); Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetRowUnits(aSeq); } else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq); } } @@ -175,16 +196,17 @@ std::vector SALOMEDS_AttributeTableOfString::GetRowUnits() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowUnits(); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits(); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_AttributeTableOfString::GetRowUnits() int SALOMEDS_AttributeTableOfString::GetNbRows() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbRows(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbRows(); + } else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows(); return aNb; } @@ -200,17 +225,20 @@ int SALOMEDS_AttributeTableOfString::GetNbRows() int SALOMEDS_AttributeTableOfString::GetNbColumns() { int aNb; - if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbColumns(); + if (_isLocal) { + SALOMEDS::Locker lock; + aNb = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetNbColumns(); + } else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns(); return aNb; - } void SALOMEDS_AttributeTableOfString::AddRow(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfString) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl); Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString; @@ -225,16 +253,17 @@ void SALOMEDS_AttributeTableOfString::AddRow(const std::vector& the else { SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq(); aSeq->length(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq); } } void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfString) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl); Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString; @@ -249,7 +278,7 @@ void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vectorlength(aLength); - for(i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str(); + for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq); } } @@ -258,15 +287,16 @@ std::vector SALOMEDS_AttributeTableOfString::GetRow(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aRow; aRow = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetRowData(theRow); aLength = aRow->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aRow->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aRow->Value(i)).ToCString()); } else { SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow); - for(i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in()); + for (i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in()); } return aVector; @@ -274,9 +304,10 @@ std::vector SALOMEDS_AttributeTableOfString::GetRow(int theRow) void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfString) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl); Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString; @@ -291,16 +322,17 @@ void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector& else { SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq(); aColumn->length(aLength); - for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str(); + for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn); } } void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector& theData) { - CheckLocked(); int aLength = theData.size(), i; - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTableOfString) aTable; aTable = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl); Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString; @@ -315,7 +347,7 @@ void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector else { SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq(); aColumn->length(aLength); - for(i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str(); + for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str(); SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theColumn, aColumn); } } @@ -324,27 +356,31 @@ std::vector SALOMEDS_AttributeTableOfString::GetColumn(int theColum { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfExtendedString) aColumn; - aColumn = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetColumnData(theColumn); + aColumn = Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->GetColumnData(theColumn); aLength = aColumn->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aColumn->Value(i)).ToCString()); + for (i = 1; i <= aLength; i++) + aVector.push_back(TCollection_AsciiString(aColumn->Value(i)).ToCString()); } else { - SALOMEDS::StringSeq_var aColumn = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn); - for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in()); + SALOMEDS::StringSeq_var aColumn = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn); + for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in()); } return aVector; } void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn) { - CheckLocked(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; try { - Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->PutValue((char*)theValue.c_str(), - theRow, - theColumn); + Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->PutValue((char*)theValue.c_str(), theRow, theColumn); } catch(...) { throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -358,7 +394,10 @@ void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn) { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->HasValue(theRow, theColumn); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->HasValue(theRow, theColumn); + } else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn); return ret; } @@ -366,11 +405,11 @@ bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn) std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn) { std::string aValue; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { - aValue = - TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetValue(theRow, - theColumn)).ToCString(); + aValue = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfString):: + DownCast(_local_impl)->GetValue(theRow, theColumn)).ToCString(); } catch(...) { throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); @@ -386,21 +425,26 @@ std::vector SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow) { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfInteger) aSet; aSet = Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->GetSetRowIndices(theRow); aLength = aSet->Length(); - for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i)); + for (i = 1; i <= aLength; i++) aVector.push_back(aSet->Value(i)); } else { - SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow); - for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]); + SALOMEDS::LongSeq_var aSet = + SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow); + for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]); } return aVector; } void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns) { - if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTableOfString)::DownCast(_local_impl)->SetNbColumns(theNbColumns); + } else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx index 62c6ce021..8511dac23 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeTarget.hxx" +#include "SALOMEDS.hxx" #include @@ -44,7 +45,10 @@ void SALOMEDS_AttributeTarget::Add(const _PTR(SObject)& theObject) { SALOMEDS_SObject* aSO = dynamic_cast(theObject.get()); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Add(aSO->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Add(aSO->GetLocalImpl()); + } else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Add(aSO->GetCORBAImpl()); } @@ -54,10 +58,12 @@ std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get() int aLength, i; SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { - Handle(TColStd_HSequenceOfTransient) aSeq = Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Get(); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfTransient) aSeq = + Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Get(); aLength = aSeq->Length(); - for(i=1; i<=aLength; i++) { + for (i = 1; i <= aLength; i++) { aSO = new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i))); aVector.push_back(_PTR(SObject)(aSO)); } @@ -66,7 +72,7 @@ std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get() SALOMEDS::Study::ListOfSObject_var aSeq = SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Get(); aLength = aSeq->length(); aSO = new SALOMEDS_SObject(aSeq[i].in()); - for(i = 0; i(theObject.get()); - if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Remove(aSO->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Remove(aSO->GetLocalImpl()); + } else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Remove(aSO->GetCORBAImpl()); } - diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor.cxx index c2da3fd0e..6c23440b7 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextColor.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor.cxx @@ -22,10 +22,12 @@ // Module : SALOME #include "SALOMEDS_AttributeTextColor.hxx" +#include "SALOMEDS.hxx" #include -SALOMEDS_AttributeTextColor::SALOMEDS_AttributeTextColor(const Handle(SALOMEDSImpl_AttributeTextColor)& theAttr) +SALOMEDS_AttributeTextColor::SALOMEDS_AttributeTextColor + (const Handle(SALOMEDSImpl_AttributeTextColor)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -40,8 +42,10 @@ SALOMEDS_AttributeTextColor::~SALOMEDS_AttributeTextColor() STextColor SALOMEDS_AttributeTextColor::TextColor() { STextColor aColor; - if(_isLocal) { - Handle(TColStd_HArray1OfReal) aSeq = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_local_impl)->TextColor(); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HArray1OfReal) aSeq = + Handle(SALOMEDSImpl_AttributeTextColor)::DownCast(_local_impl)->TextColor(); aColor.R = aSeq->Value(1); aColor.G = aSeq->Value(2); aColor.B = aSeq->Value(3); @@ -54,11 +58,12 @@ STextColor SALOMEDS_AttributeTextColor::TextColor() } return aColor; } - + void SALOMEDS_AttributeTextColor::SetTextColor(STextColor value) { - CheckLocked(); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HArray1OfReal) aSeq = new TColStd_HArray1OfReal(1, 3); aSeq->SetValue(1, value.R); aSeq->SetValue(2, value.G); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor.cxx index 7d2ea2352..d6d1a4286 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor.cxx @@ -22,14 +22,17 @@ // Module : SALOME #include "SALOMEDS_AttributeTextHighlightColor.hxx" +#include "SALOMEDS.hxx" #include -SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor(const Handle(SALOMEDSImpl_AttributeTextHighlightColor)& theAttr) +SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor + (const Handle(SALOMEDSImpl_AttributeTextHighlightColor)& theAttr) :SALOMEDS_GenericAttribute(theAttr) {} -SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor(SALOMEDS::AttributeTextHighlightColor_ptr theAttr) +SALOMEDS_AttributeTextHighlightColor::SALOMEDS_AttributeTextHighlightColor + (SALOMEDS::AttributeTextHighlightColor_ptr theAttr) :SALOMEDS_GenericAttribute(theAttr) {} @@ -40,7 +43,8 @@ SALOMEDS_AttributeTextHighlightColor::~SALOMEDS_AttributeTextHighlightColor() STextColor SALOMEDS_AttributeTextHighlightColor::TextHighlightColor() { STextColor aColor; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HArray1OfReal) aSeq; aSeq = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast(_local_impl)->TextHighlightColor(); aColor.R = aSeq->Value(1); @@ -48,17 +52,20 @@ STextColor SALOMEDS_AttributeTextHighlightColor::TextHighlightColor() aColor.B = aSeq->Value(3); } else { - SALOMEDS::Color anImplColor = SALOMEDS::AttributeTextHighlightColor::_narrow(_corba_impl)->TextHighlightColor(); + SALOMEDS::Color anImplColor = + SALOMEDS::AttributeTextHighlightColor::_narrow(_corba_impl)->TextHighlightColor(); aColor.R = anImplColor.R; aColor.G = anImplColor.G; aColor.B = anImplColor.B; } return aColor; } - + void SALOMEDS_AttributeTextHighlightColor::SetTextHighlightColor(STextColor value) { - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(TColStd_HArray1OfReal) aSeq = new TColStd_HArray1OfReal(1, 3); aSeq->SetValue(1, value.R); aSeq->SetValue(2, value.G); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx index e23f62e09..2d2df7164 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode.cxx @@ -22,8 +22,10 @@ // Module : SALOME #include "SALOMEDS_AttributeTreeNode.hxx" +#include "SALOMEDS.hxx" #include + #include #include #include @@ -47,7 +49,9 @@ SALOMEDS_AttributeTreeNode::~SALOMEDS_AttributeTreeNode() void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFather; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aFather = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -63,8 +67,10 @@ void SALOMEDS_AttributeTreeNode::SetFather(const _PTR(AttributeTreeNode)& value) bool SALOMEDS_AttributeTreeNode::HasFather() { bool ret; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); ret = aNode->HasFather(); } else { @@ -77,8 +83,10 @@ bool SALOMEDS_AttributeTreeNode::HasFather() _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather() { SALOMEDSClient_AttributeTreeNode* aTN = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFather()); } else { @@ -91,7 +99,9 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFather() void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aPrev; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aPrev = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -107,8 +117,10 @@ void SALOMEDS_AttributeTreeNode::SetPrevious(const _PTR(AttributeTreeNode)& valu bool SALOMEDS_AttributeTreeNode::HasPrevious() { bool ret; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); ret = aNode->HasPrevious(); } else { @@ -121,8 +133,10 @@ bool SALOMEDS_AttributeTreeNode::HasPrevious() _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious() { SALOMEDSClient_AttributeTreeNode* aTN = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aTN = new SALOMEDS_AttributeTreeNode(aNode->GetPrevious()); } else { @@ -135,7 +149,9 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetPrevious() void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aNext; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aNext = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -151,8 +167,10 @@ void SALOMEDS_AttributeTreeNode::SetNext(const _PTR(AttributeTreeNode)& value) bool SALOMEDS_AttributeTreeNode::HasNext() { bool ret; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); ret = aNode->HasNext(); } else { @@ -165,8 +183,10 @@ bool SALOMEDS_AttributeTreeNode::HasNext() _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext() { SALOMEDSClient_AttributeTreeNode* aTN = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aTN = new SALOMEDS_AttributeTreeNode(aNode->GetNext()); } else { @@ -179,7 +199,9 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetNext() void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, aFirst; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aFirst = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -195,8 +217,10 @@ void SALOMEDS_AttributeTreeNode::SetFirst(const _PTR(AttributeTreeNode)& value) bool SALOMEDS_AttributeTreeNode::HasFirst() { bool ret; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); ret = aNode->HasFirst(); } else { @@ -209,8 +233,10 @@ bool SALOMEDS_AttributeTreeNode::HasFirst() _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst() { SALOMEDSClient_AttributeTreeNode* aTN = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aTN = new SALOMEDS_AttributeTreeNode(aNode->GetFirst()); } else { @@ -222,8 +248,11 @@ _PTR(AttributeTreeNode) SALOMEDS_AttributeTreeNode::GetFirst() void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value) { - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); aNode->SetTreeID(Standard_GUID((char*)value.c_str())); } else { @@ -235,8 +264,10 @@ void SALOMEDS_AttributeTreeNode::SetTreeID(const std::string& value) std::string SALOMEDS_AttributeTreeNode::GetTreeID() { TCollection_AsciiString aGUID; - if(_isLocal) { - Handle(SALOMEDSImpl_AttributeTreeNode) aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode) aNode = + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); char guid[40]; aNode->GetTreeID().ToCString(guid); aGUID = TCollection_AsciiString(guid); @@ -252,7 +283,9 @@ std::string SALOMEDS_AttributeTreeNode::GetTreeID() void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -268,7 +301,9 @@ void SALOMEDS_AttributeTreeNode::Append(const _PTR(AttributeTreeNode)& value) void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -284,7 +319,9 @@ void SALOMEDS_AttributeTreeNode::Prepend(const _PTR(AttributeTreeNode)& value) void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -300,7 +337,9 @@ void SALOMEDS_AttributeTreeNode::InsertBefore(const _PTR(AttributeTreeNode)& val void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& value) { SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -315,14 +354,21 @@ void SALOMEDS_AttributeTreeNode::InsertAfter(const _PTR(AttributeTreeNode)& valu void SALOMEDS_AttributeTreeNode::Remove() { - if(_isLocal) Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove(); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Remove(); + } else SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Remove(); } int SALOMEDS_AttributeTreeNode::Depth() { int aDepth; - if(_isLocal) aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth(); + if (_isLocal) { + SALOMEDS::Locker lock; + aDepth = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->Depth(); + } else aDepth = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Depth(); return aDepth; } @@ -330,7 +376,10 @@ int SALOMEDS_AttributeTreeNode::Depth() bool SALOMEDS_AttributeTreeNode::IsRoot() { bool ret; - if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl)->IsRoot(); + } else ret = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->IsRoot(); return ret; } @@ -339,7 +388,8 @@ bool SALOMEDS_AttributeTreeNode::IsDescendant(const _PTR(AttributeTreeNode)& val { bool ret; SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -357,7 +407,8 @@ bool SALOMEDS_AttributeTreeNode::IsFather(const _PTR(AttributeTreeNode)& value) { bool ret; SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -375,7 +426,8 @@ bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value) { bool ret; SALOMEDS_AttributeTreeNode* aTN = dynamic_cast(value.get()); - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_AttributeTreeNode) aNode, anOther; aNode = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(_local_impl); anOther = Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(aTN->_local_impl); @@ -391,10 +443,13 @@ bool SALOMEDS_AttributeTreeNode::IsChild(const _PTR(AttributeTreeNode)& value) std::string SALOMEDS_AttributeTreeNode::Label() { - TCollection_AsciiString aLabel; - if(_isLocal) TDF_Tool::Entry(_local_impl->Label(), aLabel); + string aLabel; + if (_isLocal) { + SALOMEDS::Locker lock; + TCollection_AsciiString anAsciiLabel; + TDF_Tool::Entry(_local_impl->Label(), anAsciiLabel); + aLabel = std::string(anAsciiLabel.ToCString()); + } else aLabel = SALOMEDS::AttributeTreeNode::_narrow(_corba_impl)->Label(); - return std::string(aLabel.ToCString()); + return aLabel; } - - diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx index fe277cc19..4d04a19bc 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx @@ -22,6 +22,7 @@ // Module : SALOME #include "SALOMEDS_AttributeUserID.hxx" +#include "SALOMEDS.hxx" #include #include @@ -42,7 +43,8 @@ SALOMEDS_AttributeUserID::~SALOMEDS_AttributeUserID() std::string SALOMEDS_AttributeUserID::Value() { std::string aValue; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; char guid[40]; Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_local_impl)->Value().ToCString(guid); aValue = std::string(guid); @@ -50,10 +52,14 @@ std::string SALOMEDS_AttributeUserID::Value() else aValue = SALOMEDS::AttributeUserID::_narrow(_corba_impl)->Value(); return aValue; } - + void SALOMEDS_AttributeUserID::SetValue(const std::string& value) { - CheckLocked(); - if(_isLocal) Handle(SALOMEDSImpl_AttributeUserID)::DownCast(_local_impl)->SetValue(Standard_GUID((char*)value.c_str())); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_AttributeUserID):: + DownCast(_local_impl)->SetValue(Standard_GUID((char*)value.c_str())); + } else SALOMEDS::AttributeUserID::_narrow(_corba_impl)->SetValue(value.c_str()); } diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator.cxx index 1814b6526..a31bbbf18 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator.cxx @@ -25,11 +25,14 @@ #include "SALOMEDS_ChildIterator.hxx" #include "SALOMEDS_SObject.hxx" +#include "SALOMEDS.hxx" using namespace std; SALOMEDS_ChildIterator::SALOMEDS_ChildIterator(const Handle(SALOMEDSImpl_ChildIterator)& theIterator) { + SALOMEDS::Locker lock; + _isLocal = true; _local_impl = theIterator; _corba_impl = SALOMEDS::ChildIterator::_nil(); @@ -49,34 +52,49 @@ SALOMEDS_ChildIterator::~SALOMEDS_ChildIterator() void SALOMEDS_ChildIterator::Init() { - if(_isLocal) _local_impl->Init(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Init(); + } else _corba_impl->Init(); } void SALOMEDS_ChildIterator::InitEx(bool theAllLevels) { - if(_isLocal) _local_impl->InitEx(theAllLevels); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->InitEx(theAllLevels); + } else _corba_impl->InitEx(theAllLevels); } bool SALOMEDS_ChildIterator::More() { bool ret; - if(_isLocal) ret = _local_impl->More(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->More(); + } else ret = _corba_impl->More(); return ret; } void SALOMEDS_ChildIterator::Next() { - if(_isLocal) _local_impl->Next(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Next(); + } else _corba_impl->Next(); } _PTR(SObject) SALOMEDS_ChildIterator::Value() { SALOMEDSClient_SObject* aSO; - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->Value()); + if (_isLocal) { + SALOMEDS::Locker lock; + aSO = new SALOMEDS_SObject(_local_impl->Value()); + } else aSO = new SALOMEDS_SObject(_corba_impl->Value()); return _PTR(SObject)(aSO); } diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 295781b88..2f4f085ca 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -41,11 +41,12 @@ unsigned char* SALOMEDS_Driver_i::Save(const Handle(SALOMEDSImpl_SComponent)& th SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); SALOMEDS::TMPFile_var aStream; CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); - SALOMEDS::unlock(); + SALOMEDS::unlock(); aStream = _driver->Save(sco.in(), url, isMultiFile); + SALOMEDS::lock(); theStreamLength = aStream->length(); unsigned char* aRetStream = NULL; - if(theStreamLength > 0) { + if (theStreamLength > 0) { aRetStream = new unsigned char[theStreamLength]; memcpy(aRetStream, aStream->NP_data(), theStreamLength); } @@ -60,11 +61,12 @@ unsigned char* SALOMEDS_Driver_i::SaveASCII(const Handle(SALOMEDSImpl_SComponent SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); SALOMEDS::TMPFile_var aStream; CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); - SALOMEDS::unlock(); + SALOMEDS::unlock(); aStream = _driver->SaveASCII(sco.in(), url, isMultiFile); + SALOMEDS::lock(); theStreamLength = aStream->length(); unsigned char* aRetStream = NULL; - if(theStreamLength > 0) { + if (theStreamLength > 0) { aRetStream = new unsigned char[theStreamLength]; memcpy(aRetStream, aStream->NP_data(), theStreamLength); } @@ -79,16 +81,18 @@ bool SALOMEDS_Driver_i::Load(const Handle(SALOMEDSImpl_SComponent)& theComponent { SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); - CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; + CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; SALOMEDS::TMPFile_var aStream; - if(theStreamLength > 0) + if (theStreamLength > 0) aStream = new SALOMEDS::TMPFile(theStreamLength, theStreamLength, anOctetBuf, 0); else aStream = new SALOMEDS::TMPFile(0); - SALOMEDS::unlock(); - return _driver->Load(sco.in(), aStream.in(), url, isMultiFile); + SALOMEDS::unlock(); + bool isOk = _driver->Load(sco.in(), aStream.in(), url, isMultiFile); + SALOMEDS::lock(); + return isOk; } bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComponent, @@ -99,7 +103,7 @@ bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComp { SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); CORBA::String_var url = CORBA::string_dup(theURL.ToCString()); - CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; + CORBA::Octet* anOctetBuf = (CORBA::Octet*)theStream; SALOMEDS::TMPFile_var aStream; if(theStreamLength > 0) @@ -107,17 +111,20 @@ bool SALOMEDS_Driver_i::LoadASCII(const Handle(SALOMEDSImpl_SComponent)& theComp else aStream = new SALOMEDS::TMPFile(0); - SALOMEDS::unlock(); - return _driver->LoadASCII(sco.in(), aStream.in(), url, isMultiFile); + SALOMEDS::unlock(); + bool isOk = _driver->LoadASCII(sco.in(), aStream.in(), url, isMultiFile); + SALOMEDS::lock(); + return isOk; } void SALOMEDS_Driver_i::Close(const Handle(SALOMEDSImpl_SComponent)& theComponent) { SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (theComponent, _orb); - SALOMEDS::unlock(); + SALOMEDS::unlock(); _driver->Close(sco.in()); + SALOMEDS::lock(); } - + TCollection_AsciiString SALOMEDS_Driver_i::IORToLocalPersistentID(const Handle(SALOMEDSImpl_SObject)& theSObject, @@ -127,8 +134,9 @@ TCollection_AsciiString SALOMEDS_Driver_i::IORToLocalPersistentID(const Handle(S { SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theSObject, _orb); CORBA::String_var ior = CORBA::string_dup(IORString.ToCString()); - SALOMEDS::unlock(); + SALOMEDS::unlock(); CORBA::String_var pers_string =_driver->IORToLocalPersistentID(so.in(), ior.in(), isMultiFile, isASCII); + SALOMEDS::lock(); return TCollection_AsciiString(pers_string); } @@ -140,8 +148,9 @@ TCollection_AsciiString SALOMEDS_Driver_i::LocalPersistentIDToIOR(const Handle(S { SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); CORBA::String_var pers_string = CORBA::string_dup(aLocalPersistentID.ToCString()); - SALOMEDS::unlock(); - CORBA::String_var IOR =_driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII); + SALOMEDS::unlock(); + CORBA::String_var IOR = _driver->LocalPersistentIDToIOR(so.in(), pers_string.in(), isMultiFile, isASCII); + SALOMEDS::lock(); return TCollection_AsciiString(IOR); } @@ -149,7 +158,9 @@ bool SALOMEDS_Driver_i::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject) { SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (theObject, _orb); SALOMEDS::unlock(); - return _driver->CanCopy(so.in()); + bool isOk = _driver->CanCopy(so.in()); + SALOMEDS::lock(); + return isOk; } @@ -163,6 +174,7 @@ unsigned char* SALOMEDS_Driver_i::CopyFrom(const Handle(SALOMEDSImpl_SObject)& t SALOMEDS::unlock(); aStream = _driver->CopyFrom(so.in(), anObjectID); + SALOMEDS::lock(); theObjectID = anObjectID; theStreamLength = aStream->length(); @@ -179,7 +191,9 @@ unsigned char* SALOMEDS_Driver_i::CopyFrom(const Handle(SALOMEDSImpl_SObject)& t bool SALOMEDS_Driver_i::CanPaste(const TCollection_AsciiString& theComponentName, int theObjectID) { SALOMEDS::unlock(); - return _driver->CanPaste(theComponentName.ToCString(), theObjectID); + bool canPaste = _driver->CanPaste(theComponentName.ToCString(), theObjectID); + SALOMEDS::lock(); + return canPaste; } TCollection_AsciiString SALOMEDS_Driver_i::PasteInto(const unsigned char* theStream, @@ -198,6 +212,7 @@ TCollection_AsciiString SALOMEDS_Driver_i::PasteInto(const unsigned char* theStr SALOMEDS::unlock(); SALOMEDS::SObject_var ret_so = _driver->PasteInto(aStream.in(), theObjectID, so.in()); + SALOMEDS::lock(); return TCollection_AsciiString((char*)ret_so->GetID()); } @@ -232,7 +247,8 @@ unsigned char* SALOMEDS_Driver_i::DumpPython(const Handle(SALOMEDSImpl_Study)& t // SALOMEDS_DriverFactory //############################################################################################################### -SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const TCollection_AsciiString& theComponentType) +SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType + (const TCollection_AsciiString& theComponentType) { CORBA::Object_var obj; @@ -240,14 +256,16 @@ SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const TCollection if (theComponentType == "SUPERV") aFactoryType = "SuperVisionContainer"; else aFactoryType = "FactoryServer"; - SALOMEDS::unlock(); - obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType.ToCString(), - theComponentType.ToCString()); - + SALOMEDS::unlock(); + obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component + (aFactoryType.ToCString(), theComponentType.ToCString()); + SALOMEDS::lock(); + if (CORBA::is_nil(obj)) { - obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", theComponentType.ToCString()); + obj = SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component + ("FactoryServerPy", theComponentType.ToCString()); } - + if (!CORBA::is_nil(obj)) { SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); return new SALOMEDS_Driver_i(aDriver, _orb); diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index ca66fdac6..0e338f3b1 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -30,6 +30,7 @@ #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDS_SObject.hxx" #include "SALOMEDS_ClientAttributes.hxx" +#include "SALOMEDS.hxx" #ifdef WIN32 #include @@ -77,7 +78,8 @@ SALOMEDS_GenericAttribute::~SALOMEDS_GenericAttribute() void SALOMEDS_GenericAttribute::CheckLocked() { - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { _local_impl->CheckLocked(); } @@ -93,7 +95,8 @@ void SALOMEDS_GenericAttribute::CheckLocked() std::string SALOMEDS_GenericAttribute::Type() { std::string aType; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; aType = _local_impl->Type().ToCString(); } else { @@ -105,7 +108,8 @@ std::string SALOMEDS_GenericAttribute::Type() std::string SALOMEDS_GenericAttribute::GetClassType() { std::string aType; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; aType = _local_impl->GetClassType().ToCString(); } else { @@ -117,7 +121,8 @@ std::string SALOMEDS_GenericAttribute::GetClassType() _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject() { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; aSO = new SALOMEDS_SObject(_local_impl->GetSObject()); } else { @@ -128,12 +133,15 @@ _PTR(SObject) SALOMEDS_GenericAttribute::GetSObject() } -SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(const Handle(SALOMEDSImpl_GenericAttribute)& theGA) +SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute + (const Handle(SALOMEDSImpl_GenericAttribute)& theGA) { + SALOMEDS::Locker lock; + SALOMEDS_GenericAttribute* aGA = NULL; std::string aTypeOfAttribute = theGA->GetClassType().ToCString(); __CreateGenericClientAttributeLocal - return aGA; + return aGA; } SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS::GenericAttribute_ptr theGA) @@ -141,6 +149,5 @@ SALOMEDS_GenericAttribute* SALOMEDS_GenericAttribute::CreateAttribute(SALOMEDS:: SALOMEDS_GenericAttribute* aGA = NULL; std::string aTypeOfAttribute = theGA->GetClassType(); __CreateGenericClientAttributeCORBA - return aGA; + return aGA; } - diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index d4bd10e18..dcfc75494 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -92,17 +92,18 @@ char* SALOMEDS_GenericAttribute_i::GetClassType() if (!_impl.IsNull()) { return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl)); } - + return ""; -} +} -SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(const Handle(TDF_Attribute)& theAttr, - CORBA::ORB_ptr theOrb) +SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute + (const Handle(TDF_Attribute)& theAttr, + CORBA::ORB_ptr theOrb) { -/* SALOMEDS::Locker lock; - + +/* static std::map _mapOfAttrib; SALOMEDS::GenericAttribute_var anAttribute; SALOMEDS_GenericAttribute_i* attr_servant = NULL; @@ -118,13 +119,14 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(cons } */ // mpv: now servants Destroyed by common algos of CORBA - char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr)->GetClassType().ToCString(); + char* aTypeOfAttribute = Handle(SALOMEDSImpl_GenericAttribute):: + DownCast(theAttr)->GetClassType().ToCString(); SALOMEDS::GenericAttribute_var anAttribute; SALOMEDS_GenericAttribute_i* attr_servant = NULL; __CreateGenericCORBAAttribute return anAttribute._retn(); -} +} //=========================================================================== // PRIVATE FUNCTIONS @@ -135,7 +137,7 @@ long SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostname, CORBA::L long pid = (long)_getpid(); #else long pid = (long)getpid(); -#endif +#endif isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; TDF_Attribute* local_impl = _impl.operator->(); return ((long)local_impl); diff --git a/src/SALOMEDS/SALOMEDS_SComponent.cxx b/src/SALOMEDS/SALOMEDS_SComponent.cxx index eaf98f157..f061fcc5f 100644 --- a/src/SALOMEDS/SALOMEDS_SComponent.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponent.cxx @@ -24,7 +24,10 @@ #include "SALOMEDS_SComponent.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SComponent_i.hxx" + #include #include @@ -44,7 +47,8 @@ SALOMEDS_SComponent::~SALOMEDS_SComponent() std::string SALOMEDS_SComponent::ComponentDataType() { std::string aType; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; aType = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentDataType().ToCString(); } else aType = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentDataType(); @@ -55,7 +59,8 @@ std::string SALOMEDS_SComponent::ComponentDataType() bool SALOMEDS_SComponent::ComponentIOR(std::string& theID) { bool ret; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; TCollection_AsciiString anIOR; ret = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentIOR(anIOR); theID = anIOR.ToCString(); @@ -71,10 +76,10 @@ bool SALOMEDS_SComponent::ComponentIOR(std::string& theID) SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent() { - if(_isLocal) { - if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); - SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), - _orb); + if (_isLocal) { + if (!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl()); + SALOMEDS::SComponent_var aSCO = + SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()), _orb); return aSCO._retn(); } else { @@ -83,4 +88,3 @@ SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent() return SALOMEDS::SComponent::_nil(); } - diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx index 73ab05039..56d6c9427 100644 --- a/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator.cxx @@ -22,8 +22,10 @@ // Module : SALOME #include "SALOMEDS_SComponentIterator.hxx" -#include "SALOMEDSImpl_SComponent.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SComponent.hxx" +#include "SALOMEDSImpl_SComponent.hxx" SALOMEDS_SComponentIterator::SALOMEDS_SComponentIterator(const SALOMEDSImpl_SComponentIterator& theIterator) :_local_impl(theIterator) @@ -45,28 +47,40 @@ SALOMEDS_SComponentIterator::~SALOMEDS_SComponentIterator() void SALOMEDS_SComponentIterator::Init() { - if(_isLocal) _local_impl.Init(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl.Init(); + } else _corba_impl->Init(); } bool SALOMEDS_SComponentIterator::More() { bool ret; - if(_isLocal) ret = _local_impl.More(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl.More(); + } else ret = _corba_impl->More(); return ret; } - + void SALOMEDS_SComponentIterator::Next() { - if(_isLocal) _local_impl.Next(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl.Next(); + } else _corba_impl->Next(); } - + _PTR(SComponent) SALOMEDS_SComponentIterator::Value() { SALOMEDSClient_SComponent* aSCO = NULL; - if(_isLocal) aSCO = new SALOMEDS_SComponent(_local_impl.Value()); + if (_isLocal) { + SALOMEDS::Locker lock; + aSCO = new SALOMEDS_SComponent(_local_impl.Value()); + } else aSCO = new SALOMEDS_SComponent(_corba_impl->Value()); return _PTR(SComponent)(aSCO); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index eaf664e03..233c5fca8 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -28,11 +28,14 @@ #include #include "SALOMEDS_SObject.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SComponent.hxx" -#include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDS_GenericAttribute.hxx" -#include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDS_Study.hxx" + +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_Study.hxx" #include "Utils_ORB_INIT.hxx" @@ -90,15 +93,20 @@ SALOMEDS_SObject::~SALOMEDS_SObject() std::string SALOMEDS_SObject::GetID() { std::string aValue; - if(_isLocal) aValue = _local_impl->GetID().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aValue = _local_impl->GetID().ToCString(); + } else aValue = _corba_impl->GetID(); return aValue; } _PTR(SComponent) SALOMEDS_SObject::GetFatherComponent() { - if(_isLocal) { - Handle(SALOMEDSImpl_SComponent) aSCO = Handle(SALOMEDSImpl_SComponent)::DownCast(_local_impl->GetFatherComponent()); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SComponent) aSCO = + Handle(SALOMEDSImpl_SComponent)::DownCast(_local_impl->GetFatherComponent()); return _PTR(SComponent)(new SALOMEDS_SComponent(aSCO)); } return _PTR(SComponent)(new SALOMEDS_SComponent(_corba_impl->GetFatherComponent())); @@ -106,14 +114,19 @@ _PTR(SComponent) SALOMEDS_SObject::GetFatherComponent() _PTR(SObject) SALOMEDS_SObject::GetFather() { - if(_isLocal) return _PTR(SObject)(new SALOMEDS_SObject(_local_impl->GetFather())); + if (_isLocal) { + SALOMEDS::Locker lock; + return _PTR(SObject)(new SALOMEDS_SObject(_local_impl->GetFather())); + } return _PTR(SObject)(new SALOMEDS_SObject(_corba_impl->GetFather())); } -bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute, const std::string& aTypeOfAttribute) +bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute, + const std::string& aTypeOfAttribute) { bool ret = false; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_GenericAttribute) anAttr; ret = _local_impl->FindAttribute(anAttr, (char*)aTypeOfAttribute.c_str()); if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(anAttr)); @@ -130,7 +143,8 @@ bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute, const bool SALOMEDS_SObject::ReferencedObject(_PTR(SObject)& theObject) { bool ret = false; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_SObject) aSO; ret = _local_impl->ReferencedObject(aSO); if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO)); @@ -148,7 +162,8 @@ bool SALOMEDS_SObject::ReferencedObject(_PTR(SObject)& theObject) bool SALOMEDS_SObject::FindSubObject(int theTag, _PTR(SObject)& theObject) { bool ret = false; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(SALOMEDSImpl_SObject) aSO; ret = _local_impl->FindSubObject(theTag, aSO); if(ret) theObject = _PTR(SObject)(new SALOMEDS_SObject(aSO)); @@ -164,14 +179,20 @@ bool SALOMEDS_SObject::FindSubObject(int theTag, _PTR(SObject)& theObject) _PTR(Study) SALOMEDS_SObject::GetStudy() { - if(_isLocal) return _PTR(Study)(new SALOMEDS_Study(_local_impl->GetStudy())); + if (_isLocal) { + SALOMEDS::Locker lock; + return _PTR(Study)(new SALOMEDS_Study(_local_impl->GetStudy())); + } return _PTR(Study)(new SALOMEDS_Study(_corba_impl->GetStudy())); } std::string SALOMEDS_SObject::Name() { std::string aName; - if(_isLocal) aName = _local_impl->Name().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aName = _local_impl->Name().ToCString(); + } else aName = _corba_impl->Name(); return aName; @@ -179,7 +200,10 @@ std::string SALOMEDS_SObject::Name() void SALOMEDS_SObject::Name(const std::string& theName) { - if(_isLocal) _local_impl->Name((char*)theName.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Name((char*)theName.c_str()); + } else _corba_impl->Name(theName.c_str()); } @@ -189,18 +213,20 @@ vector<_PTR(GenericAttribute)> SALOMEDS_SObject::GetAllAttributes() int aLength = 0; SALOMEDSClient_GenericAttribute* anAttr; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->GetAllAttributes(); aLength = aSeq->Length(); - for(int i = 1; i <= aLength; i++) { - anAttr = SALOMEDS_GenericAttribute::CreateAttribute(Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i))); + for (int i = 1; i <= aLength; i++) { + anAttr = SALOMEDS_GenericAttribute::CreateAttribute + (Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i))); aVector.push_back(_PTR(GenericAttribute)(anAttr)); } } else { SALOMEDS::ListOfAttributes_var aSeq = _corba_impl->GetAllAttributes(); aLength = aSeq->length(); - for(int i = 0; i < aLength; i++) { + for (int i = 0; i < aLength; i++) { anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aSeq[i]); aVector.push_back(_PTR(GenericAttribute)(anAttr)); } @@ -212,7 +238,10 @@ vector<_PTR(GenericAttribute)> SALOMEDS_SObject::GetAllAttributes() std::string SALOMEDS_SObject::GetName() { std::string aName; - if(_isLocal) aName = _local_impl->GetName().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aName = _local_impl->GetName().ToCString(); + } else aName = _corba_impl->GetName(); return aName; @@ -221,7 +250,10 @@ std::string SALOMEDS_SObject::GetName() std::string SALOMEDS_SObject::GetComment() { std::string aComment; - if(_isLocal) aComment = _local_impl->GetComment().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aComment = _local_impl->GetComment().ToCString(); + } else aComment = _corba_impl->GetComment(); return aComment; @@ -230,7 +262,10 @@ std::string SALOMEDS_SObject::GetComment() std::string SALOMEDS_SObject::GetIOR() { std::string anIOR; - if(_isLocal) anIOR = _local_impl->GetIOR().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + anIOR = _local_impl->GetIOR().ToCString(); + } else anIOR = _corba_impl->GetIOR(); return anIOR; @@ -238,20 +273,27 @@ std::string SALOMEDS_SObject::GetIOR() int SALOMEDS_SObject::Tag() { - if(_isLocal) return _local_impl->Tag(); + if (_isLocal) { + SALOMEDS::Locker lock; + return _local_impl->Tag(); + } return _corba_impl->Tag(); } int SALOMEDS_SObject::Depth() { - if(_isLocal) return _local_impl->Depth(); + if (_isLocal) { + SALOMEDS::Locker lock; + return _local_impl->Depth(); + } return _corba_impl->Depth(); } CORBA::Object_ptr SALOMEDS_SObject::GetObject() { CORBA::Object_var obj; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; std::string anIOR = GetIOR(); if (!anIOR.empty()) obj = _orb->string_to_object(anIOR.c_str()); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 1f6c1ee87..17e3fcba0 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -26,19 +26,22 @@ #include "utilities.h" #include "SALOMEDS_Study.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SComponent.hxx" -#include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDS_SObject.hxx" -#include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDS_StudyBuilder.hxx" -#include "SALOMEDSImpl_StudyBuilder.hxx" #include "SALOMEDS_ChildIterator.hxx" -#include "SALOMEDSImpl_ChildIterator.hxx" #include "SALOMEDS_SComponentIterator.hxx" -#include "SALOMEDSImpl_SComponentIterator.hxx" #include "SALOMEDS_AttributeStudyProperties.hxx" -#include "SALOMEDSImpl_AttributeStudyProperties.hxx" #include "SALOMEDS_UseCaseBuilder.hxx" + +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_StudyBuilder.hxx" +#include "SALOMEDSImpl_ChildIterator.hxx" +#include "SALOMEDSImpl_SComponentIterator.hxx" +#include "SALOMEDSImpl_AttributeStudyProperties.hxx" #include "SALOMEDSImpl_UseCaseBuilder.hxx" #include "SALOMEDS_Driver_i.hxx" @@ -98,7 +101,10 @@ SALOMEDS_Study::~SALOMEDS_Study() std::string SALOMEDS_Study::GetPersistentReference() { std::string aRef; - if(_isLocal) aRef = _local_impl->GetPersistentReference().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aRef = _local_impl->GetPersistentReference().ToCString(); + } else aRef = _corba_impl->GetPersistentReference(); return aRef; } @@ -106,7 +112,10 @@ std::string SALOMEDS_Study::GetPersistentReference() std::string SALOMEDS_Study::GetTransientReference() { std::string aRef; - if(_isLocal) aRef = _local_impl->GetTransientReference().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aRef = _local_impl->GetTransientReference().ToCString(); + } else aRef = _corba_impl->GetTransientReference(); return aRef; } @@ -114,7 +123,10 @@ std::string SALOMEDS_Study::GetTransientReference() bool SALOMEDS_Study::IsEmpty() { bool ret; - if(_isLocal) ret = _local_impl->IsEmpty(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->IsEmpty(); + } else ret = _corba_impl->IsEmpty(); return ret; } @@ -122,14 +134,17 @@ bool SALOMEDS_Study::IsEmpty() _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentName) { SALOMEDSClient_SComponent* aSCO = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponent((char*)aComponentName.c_str()); - if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO); + if (_isLocal) { + SALOMEDS::Locker lock; + + Handle(SALOMEDSImpl_SComponent) aSCO_impl = + _local_impl->FindComponent((char*)aComponentName.c_str()); + if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO); aSCO = new SALOMEDS_SComponent(aSCO_impl); } else { SALOMEDS::SComponent_var aSCO_impl = _corba_impl->FindComponent((char*)aComponentName.c_str()); - if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO); + if (CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO); aSCO = new SALOMEDS_SComponent(aSCO_impl); } return _PTR(SComponent)(aSCO); @@ -138,9 +153,12 @@ _PTR(SComponent) SALOMEDS_Study::FindComponent (const std::string& aComponentNam _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID) { SALOMEDSClient_SComponent* aSCO = NULL; - if(_isLocal) { - Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->FindComponentID((char*)aComponentID.c_str()); - if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO); + if (_isLocal) { + SALOMEDS::Locker lock; + + Handle(SALOMEDSImpl_SComponent) aSCO_impl = + _local_impl->FindComponentID((char*)aComponentID.c_str()); + if (aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO); aSCO = new SALOMEDS_SComponent(aSCO_impl); } else { @@ -149,57 +167,64 @@ _PTR(SComponent) SALOMEDS_Study::FindComponentID(const std::string& aComponentID aSCO = new SALOMEDS_SComponent(aSCO_impl); } return _PTR(SComponent)(aSCO); - } _PTR(SObject) SALOMEDS_Study::FindObject(const std::string& anObjectName) { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObject((char*)anObjectName.c_str()); - if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); + if (aSO_impl.IsNull()) return _PTR(SObject)(aSO); Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSO_impl); - if(!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl)); + if (!aSCO_impl.IsNull()) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl)); aSO = new SALOMEDS_SObject(aSO_impl); } else { SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObject((char*)anObjectName.c_str()); - if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); + if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); SALOMEDS::SComponent_var aSCO_impl = SALOMEDS::SComponent::_narrow(aSO_impl); - if(!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl)); + if (!CORBA::is_nil(aSCO_impl)) return _PTR(SObject)(new SALOMEDS_SComponent(aSCO_impl)); aSO = new SALOMEDS_SObject(aSO_impl); } return _PTR(SObject)(aSO); } - + std::vector<_PTR(SObject)> SALOMEDS_Study::FindObjectByName(const std::string& anObjectName, - const std::string& aComponentName) + const std::string& aComponentName) { std::vector<_PTR(SObject)> aVector; int i, aLength = 0; - - if(_isLocal) { - Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str()); + + if (_isLocal) { + SALOMEDS::Locker lock; + + Handle(TColStd_HSequenceOfTransient) aSeq = + _local_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str()); aLength = aSeq->Length(); - for(i = 1; i<= aLength; i++) - aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i))))); + for (i = 1; i<= aLength; i++) + aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject + (Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i))))); } else { SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindObjectByName((char*)anObjectName.c_str(), (char*)aComponentName.c_str()); aLength = aSeq->length(); - for(i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i]))); + for (i = 0; i< aLength; i++) aVector.push_back(_PTR(SObject)(new SALOMEDS_SObject(aSeq[i]))); } return aVector; } - + _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID) { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectID((char*)anObjectID.c_str()); if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); return _PTR(SObject)(new SALOMEDS_SObject(aSO_impl)); @@ -215,22 +240,27 @@ _PTR(SObject) SALOMEDS_Study::FindObjectID(const std::string& anObjectID) _PTR(SObject) SALOMEDS_Study::CreateObjectID(const std::string& anObjectID) { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str())); + if (_isLocal) { + SALOMEDS::Locker lock; + aSO = new SALOMEDS_SObject(_local_impl->CreateObjectID((char*)anObjectID.c_str())); + } else aSO = new SALOMEDS_SObject(_corba_impl->CreateObjectID((char*)anObjectID.c_str())); return _PTR(SObject)(aSO); } - + _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR) { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectIOR((char*)anObjectIOR.c_str()); - if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); + if (aSO_impl.IsNull()) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); } else { SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectIOR((char*)anObjectIOR.c_str()); - if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); + if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); } return _PTR(SObject)(aSO); @@ -239,14 +269,16 @@ _PTR(SObject) SALOMEDS_Study::FindObjectIOR(const std::string& anObjectIOR) _PTR(SObject) SALOMEDS_Study::FindObjectByPath(const std::string& thePath) { SALOMEDSClient_SObject* aSO = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->FindObjectByPath((char*)thePath.c_str()); - if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); + if (aSO_impl.IsNull()) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); } else { SALOMEDS::SObject_var aSO_impl = _corba_impl->FindObjectByPath((char*)thePath.c_str()); - if(CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); + if (CORBA::is_nil(aSO_impl)) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); } return _PTR(SObject)(aSO); @@ -256,21 +288,30 @@ std::string SALOMEDS_Study::GetObjectPath(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); std::string aPath; - if(_isLocal) aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aPath = _local_impl->GetObjectPath(aSO->GetLocalImpl()).ToCString(); + } else aPath = _corba_impl->GetObjectPath(aSO->GetCORBAImpl()); return aPath; } void SALOMEDS_Study::SetContext(const std::string& thePath) { - if(_isLocal) _local_impl->SetContext((char*)thePath.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->SetContext((char*)thePath.c_str()); + } else _corba_impl->SetContext((char*)thePath.c_str()); } std::string SALOMEDS_Study::GetContext() { std::string aPath; - if(_isLocal) aPath = _local_impl->GetContext().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aPath = _local_impl->GetContext().ToCString(); + } else aPath = _corba_impl->GetContext(); return aPath; } @@ -279,15 +320,17 @@ std::vector SALOMEDS_Study::GetObjectNames(const std::string& theCo { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetObjectNames((char*)theContext.c_str()); aLength = aSeq->Length(); - for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } else { SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetObjectNames((char*)theContext.c_str()); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_Study::GetDirectoryNames(const std::string& th { std::vector aVector; int aLength, i; - if(_isLocal) { - Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetDirectoryNames((char*)theContext.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + + Handle(TColStd_HSequenceOfAsciiString) aSeq = + _local_impl->GetDirectoryNames((char*)theContext.c_str()); aLength = aSeq->Length(); - for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } else { SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetDirectoryNames((char*)theContext.c_str()); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_Study::GetFileNames(const std::string& theCont { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetFileNames((char*)theContext.c_str()); aLength = aSeq->Length(); - for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } else { SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetFileNames((char*)theContext.c_str()); aLength = aSeq->length(); - for(i = 0; i SALOMEDS_Study::GetComponentNames(const std::string& th { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetComponentNames((char*)theContext.c_str()); aLength = aSeq->Length(); - for(i = 1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } else { SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetComponentNames((char*)theContext.c_str()); aLength = aSeq->length(); - for(i = 0; i(theSO.get()); SALOMEDSClient_ChildIterator* aCI = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_ChildIterator) aCIimpl = _local_impl->NewChildIterator(aSO->GetLocalImpl()); aCI = new SALOMEDS_ChildIterator(aCIimpl); } @@ -363,7 +415,9 @@ _PTR(ChildIterator) SALOMEDS_Study::NewChildIterator(const _PTR(SObject)& theSO) _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator() { SALOMEDSClient_SComponentIterator* aCI = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + SALOMEDSImpl_SComponentIterator aCIimpl = _local_impl->NewComponentIterator(); aCI = new SALOMEDS_SComponentIterator(aCIimpl); } @@ -374,11 +428,13 @@ _PTR(SComponentIterator) SALOMEDS_Study::NewComponentIterator() return _PTR(SComponentIterator)(aCI); } - + _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder() { SALOMEDSClient_StudyBuilder* aSB = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_StudyBuilder) aSBimpl = _local_impl->NewBuilder(); aSB = new SALOMEDS_StudyBuilder(aSBimpl); } @@ -393,35 +449,50 @@ _PTR(StudyBuilder) SALOMEDS_Study::NewBuilder() std::string SALOMEDS_Study::Name() { std::string aName; - if(_isLocal) aName = _local_impl->Name().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aName = _local_impl->Name().ToCString(); + } else aName = _corba_impl->Name(); return aName; } - + void SALOMEDS_Study::Name(const std::string& theName) { - if(_isLocal) _local_impl->Name((char*)theName.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Name((char*)theName.c_str()); + } else _corba_impl->Name((char*)theName.c_str()); } bool SALOMEDS_Study::IsSaved() { bool isSaved; - if(_isLocal) isSaved = _local_impl->IsSaved(); + if (_isLocal) { + SALOMEDS::Locker lock; + isSaved = _local_impl->IsSaved(); + } else isSaved = _corba_impl->IsSaved(); return isSaved; } void SALOMEDS_Study::IsSaved(bool save) { - if(_isLocal) _local_impl->IsSaved(save); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->IsSaved(save); + } else _corba_impl->IsSaved(save); } bool SALOMEDS_Study::IsModified() { bool isModified; - if(_isLocal) isModified = _local_impl->IsModified(); + if (_isLocal) { + SALOMEDS::Locker lock; + isModified = _local_impl->IsModified(); + } else isModified = _corba_impl->IsModified(); return isModified; } @@ -429,28 +500,40 @@ bool SALOMEDS_Study::IsModified() std::string SALOMEDS_Study::URL() { std::string aURL; - if(_isLocal) aURL = _local_impl->URL().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aURL = _local_impl->URL().ToCString(); + } else aURL = _corba_impl->URL(); return aURL; } void SALOMEDS_Study::URL(const std::string& url) { - if(_isLocal) _local_impl->URL((char*)url.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->URL((char*)url.c_str()); + } else _corba_impl->URL((char*)url.c_str()); } int SALOMEDS_Study::StudyId() { int anID; - if(_isLocal) anID = _local_impl->StudyId(); + if (_isLocal) { + SALOMEDS::Locker lock; + anID = _local_impl->StudyId(); + } else anID = _corba_impl->StudyId(); return anID; } void SALOMEDS_Study::StudyId(int id) { - if(_isLocal) _local_impl->StudyId(id); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->StudyId(id); + } else _corba_impl->StudyId(id); } @@ -459,12 +542,13 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& std::vector<_PTR(SObject)> aVector; SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->FindDependances(aSO->GetLocalImpl()); - if ( !aSeq.IsNull() ) - { + if (!aSeq.IsNull()) { aLength = aSeq->Length(); - for(i=1; i<=aLength; i++) + for (i = 1; i <= aLength; i++) aVector.push_back(_PTR(SObject)( new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i))))); } @@ -472,7 +556,7 @@ std::vector<_PTR(SObject)> SALOMEDS_Study::FindDependances(const _PTR(SObject)& else { SALOMEDS::Study::ListOfSObject_var aSeq = _corba_impl->FindDependances(aSO->GetCORBAImpl()); aLength = aSeq->length(); - for(i=0; i SALOMEDS_Study::FindDependances(const _PTR(SObject)& _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties() { SALOMEDSClient_AttributeStudyProperties* aProp; - if(_isLocal) aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties()); + if (_isLocal) { + SALOMEDS::Locker lock; + aProp = new SALOMEDS_AttributeStudyProperties(_local_impl->GetProperties()); + } else aProp = new SALOMEDS_AttributeStudyProperties(_corba_impl->GetProperties()); return _PTR(AttributeStudyProperties)(aProp); } @@ -488,7 +575,10 @@ _PTR(AttributeStudyProperties) SALOMEDS_Study::GetProperties() std::string SALOMEDS_Study::GetLastModificationDate() { std::string aDate; - if(_isLocal) aDate = _local_impl->GetLastModificationDate().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aDate = _local_impl->GetLastModificationDate().ToCString(); + } else aDate = _corba_impl->GetLastModificationDate(); return aDate; } @@ -497,15 +587,17 @@ std::vector SALOMEDS_Study::GetModificationsDate() { std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfAsciiString) aSeq = _local_impl->GetModificationsDate(); aLength = aSeq->Length(); - for(i=1; i<=aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); + for (i = 1; i <= aLength; i++) aVector.push_back(aSeq->Value(i).ToCString()); } else { SALOMEDS::ListOfDates_var aSeq = _corba_impl->GetModificationsDate(); aLength = aSeq->length(); - for(i=0; i SALOMEDS_Study::GetModificationsDate() _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder() { SALOMEDSClient_UseCaseBuilder* aUB = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_UseCaseBuilder) aUBimpl = _local_impl->GetUseCaseBuilder(); aUB = new SALOMEDS_UseCaseBuilder(aUBimpl); } @@ -527,7 +621,10 @@ _PTR(UseCaseBuilder) SALOMEDS_Study::GetUseCaseBuilder() void SALOMEDS_Study::Close() { - if(_isLocal) _local_impl->Close(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Close(); + } else _corba_impl->Close(); } @@ -539,13 +636,8 @@ void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled) bool SALOMEDS_Study::DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished) { - bool ret; - if(_isLocal) { - SALOMEDS_DriverFactory_i* aFactory = new SALOMEDS_DriverFactory_i(_orb); - ret = _local_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished, aFactory); - delete aFactory; - } - else ret = _corba_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished); + //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one + bool ret = _corba_impl->DumpStudy((char*)thePath.c_str(), (char*)theBaseName.c_str(), isPublished); return ret; } @@ -568,11 +660,13 @@ void SALOMEDS_Study::init_orb() SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() { - if(_isLocal) { - if(!CORBA::is_nil(_corba_impl)) return _corba_impl; + if (_isLocal) { + SALOMEDS::Locker lock; + + if (!CORBA::is_nil(_corba_impl)) return _corba_impl; std::string anIOR = _local_impl->GetTransientReference().ToCString(); SALOMEDS::Study_var aStudy; - if(!_local_impl->IsError() && anIOR != "") { + if (!_local_impl->IsError() && anIOR != "") { aStudy = SALOMEDS::Study::_narrow(_orb->string_to_object(anIOR.c_str())); } else { @@ -585,6 +679,6 @@ SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() else { return _corba_impl; } - + return SALOMEDS::Study::_nil(); } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index 045fdea8d..e11a77eb4 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -26,17 +26,23 @@ #include "utilities.h" #include "SALOMEDS_StudyBuilder.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SObject.hxx" -#include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDS_SComponent.hxx" -#include "SALOMEDSImpl_SComponent.hxx" -#include "SALOMEDS_Driver_i.hxx" #include "SALOMEDS_GenericAttribute.hxx" +#include "SALOMEDS_StudyManager.hxx" + +#include "SALOMEDS_Driver_i.hxx" + +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" + #include + #include #include -#include "SALOMEDS_StudyManager.hxx" #include "Utils_CorbaException.hxx" #include "Utils_ORB_INIT.hxx" @@ -68,11 +74,12 @@ SALOMEDS_StudyBuilder::~SALOMEDS_StudyBuilder() _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& ComponentDataType) { - CheckLocked(); - SALOMEDSClient_SComponent* aSCO = NULL; - - if(_isLocal) { + + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SComponent) aSCO_impl =_local_impl->NewComponent((char*)ComponentDataType.c_str()); if(aSCO_impl.IsNull()) return _PTR(SComponent)(aSCO); aSCO = new SALOMEDS_SComponent(aSCO_impl); @@ -82,18 +89,21 @@ _PTR(SComponent) SALOMEDS_StudyBuilder::NewComponent(const std::string& Componen if(CORBA::is_nil(aSCO_impl)) return _PTR(SComponent)(aSCO); aSCO = new SALOMEDS_SComponent(aSCO_impl); } - + return _PTR(SComponent)(aSCO); } void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& theSCO, const std::string& ComponentIOR) { - CheckLocked(); - SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); - if(_isLocal) _local_impl->DefineComponentInstance(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()), - (char*)ComponentIOR.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->DefineComponentInstance(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()), + (char*)ComponentIOR.c_str()); + } else { CORBA::Object_var obj = _orb->string_to_object(ComponentIOR.c_str()); _corba_impl->DefineComponentInstance(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl()), obj); @@ -102,10 +112,13 @@ void SALOMEDS_StudyBuilder::DefineComponentInstance (const _PTR(SComponent)& the void SALOMEDS_StudyBuilder::RemoveComponent(const _PTR(SComponent)& theSCO) { - CheckLocked(); - SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); - if(_isLocal) _local_impl->RemoveComponent(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl())); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->RemoveComponent(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl())); + } else _corba_impl->RemoveComponent(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl())); } @@ -115,8 +128,10 @@ _PTR(SObject) SALOMEDS_StudyBuilder::NewObject(const _PTR(SObject)& theFatherObj SALOMEDSClient_SObject* aSO = NULL; SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get()); - if(father == NULL) return _PTR(SObject)(aSO); - if(_isLocal) { + if (father == NULL) return _PTR(SObject)(aSO); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObject(father->GetLocalImpl()); if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); @@ -136,8 +151,10 @@ _PTR(SObject) SALOMEDS_StudyBuilder::NewObjectToTag(const _PTR(SObject)& theFath SALOMEDSClient_SObject* aSO = NULL; SALOMEDS_SObject* father = dynamic_cast< SALOMEDS_SObject*>(theFatherObject.get()); - if(father == NULL) return _PTR(SObject)(aSO); - if(_isLocal) { + if (father == NULL) return _PTR(SObject)(aSO); + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = _local_impl->NewObjectToTag(father->GetLocalImpl(), theTag); if(aSO_impl.IsNull()) return _PTR(SObject)(aSO); aSO = new SALOMEDS_SObject(aSO_impl); @@ -149,20 +166,20 @@ _PTR(SObject) SALOMEDS_StudyBuilder::NewObjectToTag(const _PTR(SObject)& theFath } return _PTR(SObject)(aSO); - } void SALOMEDS_StudyBuilder::AddDirectory(const std::string& thePath) { - CheckLocked(); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; - if(_isLocal) { _local_impl->AddDirectory((char*)thePath.c_str()); - if(_local_impl->IsError()) { + if (_local_impl->IsError()) { std::string anErrorCode = _local_impl->GetErrorCode().ToCString(); - if(anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed(); - if(anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory(); - if(anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent(); + if (anErrorCode == "StudyNameAlreadyUsed") throw SALOMEDS::Study::StudyNameAlreadyUsed(); + if (anErrorCode == "StudyInvalidDirectory") throw SALOMEDS::Study::StudyInvalidDirectory(); + if (anErrorCode == "StudyInvalidComponent") throw SALOMEDS::Study::StudyInvalidComponent(); } } else _corba_impl->AddDirectory((char*)thePath.c_str()); @@ -174,9 +191,12 @@ void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std:: CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str()); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb); - Handle(SALOMEDSImpl_SComponent) aSCO_impl = Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()); + Handle(SALOMEDSImpl_SComponent) aSCO_impl = + Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl()); bool isDone = _local_impl->LoadWith(aSCO_impl, drv); delete drv; if(!isDone && _local_impl->IsError()) @@ -190,46 +210,55 @@ void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std:: void SALOMEDS_StudyBuilder::Load(const _PTR(SObject)& theSCO) { SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); - if(_isLocal) _local_impl->Load(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl())); + if (_isLocal) _local_impl->Load(Handle(SALOMEDSImpl_SComponent)::DownCast(aSCO->GetLocalImpl())); else _corba_impl->Load(SALOMEDS::SComponent::_narrow(aSCO->GetCORBAImpl())); } void SALOMEDS_StudyBuilder::RemoveObject(const _PTR(SObject)& theSO) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->RemoveObject(aSO->GetLocalImpl()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->RemoveObject(aSO->GetLocalImpl()); + } else _corba_impl->RemoveObject(aSO->GetCORBAImpl()); } void SALOMEDS_StudyBuilder::RemoveObjectWithChildren(const _PTR(SObject)& theSO) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->RemoveObjectWithChildren(aSO->GetLocalImpl()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->RemoveObjectWithChildren(aSO->GetLocalImpl()); + } else _corba_impl->RemoveObjectWithChildren(aSO->GetCORBAImpl()); } - + _PTR(GenericAttribute) SALOMEDS_StudyBuilder::FindOrCreateAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); SALOMEDSClient_GenericAttribute* anAttr = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_GenericAttribute) aGA; try { - aGA=Handle(SALOMEDSImpl_GenericAttribute)::DownCast(_local_impl->FindOrCreateAttribute(aSO->GetLocalImpl(), - (char*)aTypeOfAttribute.c_str())); - } + aGA = Handle(SALOMEDSImpl_GenericAttribute)::DownCast + (_local_impl->FindOrCreateAttribute(aSO->GetLocalImpl(), (char*)aTypeOfAttribute.c_str())); + } catch (...) { throw SALOMEDS::StudyBuilder::LockProtection(); - } + } anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA); } else { - SALOMEDS::GenericAttribute_var aGA = _corba_impl->FindOrCreateAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str()); + SALOMEDS::GenericAttribute_var aGA = + _corba_impl->FindOrCreateAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str()); anAttr = SALOMEDS_GenericAttribute::CreateAttribute(aGA); } @@ -242,7 +271,9 @@ bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO, { bool ret; SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_GenericAttribute) aGA; ret = _local_impl->FindAttribute(aSO->GetLocalImpl(), aGA, (char*)aTypeOfAttribute.c_str()); if(ret) anAttribute = _PTR(GenericAttribute)(SALOMEDS_GenericAttribute::CreateAttribute(aGA)); @@ -255,41 +286,53 @@ bool SALOMEDS_StudyBuilder::FindAttribute(const _PTR(SObject)& theSO, return ret; } - + void SALOMEDS_StudyBuilder::RemoveAttribute(const _PTR(SObject)& theSO, const std::string& aTypeOfAttribute) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->RemoveAttribute(aSO->GetLocalImpl(), (char*)aTypeOfAttribute.c_str()); - else _corba_impl->RemoveAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->RemoveAttribute(aSO->GetLocalImpl(), (char*)aTypeOfAttribute.c_str()); + } + else _corba_impl->RemoveAttribute(aSO->GetCORBAImpl(), (char*)aTypeOfAttribute.c_str()); } void SALOMEDS_StudyBuilder::Addreference(const _PTR(SObject)& me, const _PTR(SObject)& thereferencedObject) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(me.get()); SALOMEDS_SObject* aRefSO = dynamic_cast(thereferencedObject.get()); - if(_isLocal) _local_impl->Addreference(aSO->GetLocalImpl(), aRefSO->GetLocalImpl()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->Addreference(aSO->GetLocalImpl(), aRefSO->GetLocalImpl()); + } else _corba_impl->Addreference(aSO->GetCORBAImpl(), aRefSO->GetCORBAImpl()); } void SALOMEDS_StudyBuilder::RemoveReference(const _PTR(SObject)& me) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(me.get()); - if(_isLocal) _local_impl->RemoveReference(aSO->GetLocalImpl()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->RemoveReference(aSO->GetLocalImpl()); + } else _corba_impl->RemoveReference(aSO->GetCORBAImpl()); } void SALOMEDS_StudyBuilder::SetGUID(const _PTR(SObject)& theSO, const std::string& theGUID) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->SetGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->SetGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str()); + } else _corba_impl->SetGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str()); } @@ -297,7 +340,11 @@ bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); bool ret; - if(_isLocal) ret = _local_impl->IsGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + + ret = _local_impl->IsGUID(aSO->GetLocalImpl(), (char*)theGUID.c_str()); + } else ret = _corba_impl->IsGUID(aSO->GetCORBAImpl(), (char*)theGUID.c_str()); return ret; @@ -305,13 +352,17 @@ bool SALOMEDS_StudyBuilder::IsGUID(const _PTR(SObject)& theSO, const std::string void SALOMEDS_StudyBuilder::NewCommand() { - if(_isLocal) _local_impl->NewCommand(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->NewCommand(); + } else _corba_impl->NewCommand(); } void SALOMEDS_StudyBuilder::CommitCommand() { - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { _local_impl->CommitCommand(); } @@ -325,20 +376,27 @@ void SALOMEDS_StudyBuilder::CommitCommand() bool SALOMEDS_StudyBuilder::HasOpenCommand() { bool ret; - if(_isLocal) ret = _local_impl->HasOpenCommand(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->HasOpenCommand(); + } else ret = _corba_impl->HasOpenCommand(); return ret; } void SALOMEDS_StudyBuilder::AbortCommand() { - if(_isLocal) _local_impl->AbortCommand(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->AbortCommand(); + } else _corba_impl->AbortCommand(); } void SALOMEDS_StudyBuilder::Undo() { - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { _local_impl->Undo(); } @@ -348,10 +406,11 @@ void SALOMEDS_StudyBuilder::Undo() } else _corba_impl->Undo(); } - + void SALOMEDS_StudyBuilder::Redo() { - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { _local_impl->Redo(); } @@ -361,11 +420,14 @@ void SALOMEDS_StudyBuilder::Redo() } else _corba_impl->Redo(); } - + bool SALOMEDS_StudyBuilder::GetAvailableUndos() { bool ret; - if(_isLocal) ret = _local_impl->GetAvailableUndos(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->GetAvailableUndos(); + } else ret = _corba_impl->GetAvailableUndos(); return ret; } @@ -373,7 +435,10 @@ bool SALOMEDS_StudyBuilder::GetAvailableUndos() bool SALOMEDS_StudyBuilder::GetAvailableRedos() { bool ret; - if(_isLocal) ret = _local_impl->GetAvailableRedos(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->GetAvailableRedos(); + } else ret = _corba_impl->GetAvailableRedos(); return ret; } @@ -381,23 +446,30 @@ bool SALOMEDS_StudyBuilder::GetAvailableRedos() int SALOMEDS_StudyBuilder::UndoLimit() { int aLimit; - if(_isLocal) aLimit = _local_impl->UndoLimit(); + if (_isLocal) { + SALOMEDS::Locker lock; + aLimit = _local_impl->UndoLimit(); + } else aLimit = _corba_impl->UndoLimit(); return aLimit; } void SALOMEDS_StudyBuilder::UndoLimit(int theLimit) { - CheckLocked(); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; - if(_isLocal) _local_impl->UndoLimit(theLimit); + _local_impl->UndoLimit(theLimit); + } else _corba_impl->UndoLimit(theLimit); } void SALOMEDS_StudyBuilder::CheckLocked() { //There is only local part as CORBA part throws the correct exeception - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; try { _local_impl->CheckLocked(); } @@ -409,34 +481,43 @@ void SALOMEDS_StudyBuilder::CheckLocked() void SALOMEDS_StudyBuilder::SetName(const _PTR(SObject)& theSO, const std::string& theValue) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->SetName(aSO->GetLocalImpl(), (char*)theValue.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->SetName(aSO->GetLocalImpl(), (char*)theValue.c_str()); + } else _corba_impl->SetName(aSO->GetCORBAImpl(), (char*)theValue.c_str()); } void SALOMEDS_StudyBuilder::SetComment(const _PTR(SObject)& theSO, const std::string& theValue) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->SetComment(aSO->GetLocalImpl(), (char*)theValue.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->SetComment(aSO->GetLocalImpl(), (char*)theValue.c_str()); + } else _corba_impl->SetComment(aSO->GetCORBAImpl(), (char*)theValue.c_str()); } void SALOMEDS_StudyBuilder::SetIOR(const _PTR(SObject)& theSO, const std::string& theValue) { - CheckLocked(); - SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); - if(_isLocal) _local_impl->SetIOR(aSO->GetLocalImpl(), (char*)theValue.c_str()); + if (_isLocal) { + CheckLocked(); + SALOMEDS::Locker lock; + + _local_impl->SetIOR(aSO->GetLocalImpl(), (char*)theValue.c_str()); + } else _corba_impl->SetIOR(aSO->GetCORBAImpl(), (char*)theValue.c_str()); } void SALOMEDS_StudyBuilder::init_orb() { - ORB_INIT &init = *SINGLETON_::Instance() ; + ORB_INIT &init = *SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ) ; + _orb = init(0 , 0 ); } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 21d2551cd..17e273f0e 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -24,11 +24,14 @@ #include "SALOMEDS_StudyManager.hxx" -#include "SALOMEDSImpl_Study.hxx" +#include "SALOMEDS.hxx" #include "SALOMEDS_Study.hxx" #include "SALOMEDS_SObject.hxx" + #include "SALOMEDS_Driver_i.hxx" +#include "SALOMEDSImpl_Study.hxx" + #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" @@ -45,7 +48,7 @@ #include "OpUtil.hxx" -using namespace std; +using namespace std; SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb); @@ -107,7 +110,7 @@ _PTR(Study) SALOMEDS_StudyManager::NewStudy(const std::string& study_name) SALOMEDSClient_Study* aStudy = NULL; SALOMEDS::Study_var aStudy_impl = _corba_impl->NewStudy((char*)study_name.c_str()); - if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); return _PTR(Study)(aStudy); @@ -119,7 +122,7 @@ _PTR(Study) SALOMEDS_StudyManager::Open(const std::string& theStudyUrl) SALOMEDSClient_Study* aStudy = NULL; SALOMEDS::Study_var aStudy_impl = _corba_impl->Open((char*)theStudyUrl.c_str()); - if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl.in()); @@ -133,32 +136,32 @@ void SALOMEDS_StudyManager::Close(const _PTR(Study)& theStudy) _corba_impl->Close(aStudy); } -void SALOMEDS_StudyManager::Save(const _PTR(Study)& theStudy, bool theMultiFile) +bool SALOMEDS_StudyManager::Save(const _PTR(Study)& theStudy, bool theMultiFile) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - _corba_impl->Save(aStudy, theMultiFile); + return _corba_impl->Save(aStudy, theMultiFile); } -void SALOMEDS_StudyManager::SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile) +bool SALOMEDS_StudyManager::SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - _corba_impl->SaveASCII(aStudy, theMultiFile); + return _corba_impl->SaveASCII(aStudy, theMultiFile); } -void SALOMEDS_StudyManager::SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) +bool SALOMEDS_StudyManager::SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - _corba_impl->SaveAs((char*)theUrl.c_str(), aStudy, theMultiFile); + return _corba_impl->SaveAs((char*)theUrl.c_str(), aStudy, theMultiFile); } -void SALOMEDS_StudyManager::SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) +bool SALOMEDS_StudyManager::SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - _corba_impl->SaveAsASCII((char*)theUrl.c_str(), aStudy, theMultiFile); + return _corba_impl->SaveAsASCII((char*)theUrl.c_str(), aStudy, theMultiFile); } std::vector SALOMEDS_StudyManager::GetOpenStudies() @@ -166,7 +169,9 @@ std::vector SALOMEDS_StudyManager::GetOpenStudies() std::vector aVector; int aLength, i; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(TColStd_HSequenceOfTransient) aSeq = _local_impl->GetOpenStudies(); aLength = aSeq->Length(); for(i = 1; i <= aLength; i++) @@ -180,18 +185,20 @@ std::vector SALOMEDS_StudyManager::GetOpenStudies() } return aVector; } - + _PTR(Study) SALOMEDS_StudyManager::GetStudyByName(const std::string& theStudyName) { SALOMEDSClient_Study* aStudy = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByName((char*)theStudyName.c_str()); if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); } else { SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByName((char*)theStudyName.c_str()); - if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); } return _PTR(Study)(aStudy); @@ -200,25 +207,29 @@ _PTR(Study) SALOMEDS_StudyManager::GetStudyByName(const std::string& theStudyNam _PTR(Study) SALOMEDS_StudyManager::GetStudyByID(int theStudyID) { SALOMEDSClient_Study* aStudy = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_Study) aStudy_impl = _local_impl->GetStudyByID(theStudyID); if(aStudy_impl.IsNull()) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); } else { SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByID(theStudyID); - if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); } - return _PTR(Study)(aStudy); + return _PTR(Study)(aStudy); } - + bool SALOMEDS_StudyManager::CanCopy(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); bool ret; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); ret = _local_impl->CanCopy(aSO_impl, aDriver); @@ -230,12 +241,14 @@ bool SALOMEDS_StudyManager::CanCopy(const _PTR(SObject)& theSO) return ret; } - + bool SALOMEDS_StudyManager::Copy(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); bool ret; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); ret = _local_impl->Copy(aSO_impl, aDriver); @@ -246,13 +259,15 @@ bool SALOMEDS_StudyManager::Copy(const _PTR(SObject)& theSO) } return ret; } - + bool SALOMEDS_StudyManager::CanPaste(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); bool ret; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); ret = _local_impl->CanPaste(aSO_impl, aDriver); @@ -264,13 +279,15 @@ bool SALOMEDS_StudyManager::CanPaste(const _PTR(SObject)& theSO) return ret; } - + _PTR(SObject) SALOMEDS_StudyManager::Paste(const _PTR(SObject)& theSO) { SALOMEDS_SObject* aSO = dynamic_cast(theSO.get()); SALOMEDSClient_SObject* aResult = NULL; - if(_isLocal) { + if (_isLocal) { + SALOMEDS::Locker lock; + Handle(SALOMEDSImpl_SObject) aSO_impl = aSO->GetLocalImpl(); SALOMEDS_Driver_i* aDriver = GetDriver(aSO_impl, _orb); Handle(SALOMEDSImpl_SObject) aNewSO = _local_impl->Paste(aSO_impl, aDriver); @@ -290,9 +307,9 @@ _PTR(SObject) SALOMEDS_StudyManager::Paste(const _PTR(SObject)& theSO) void SALOMEDS_StudyManager::init_orb() { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ) ; + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init(0 , 0 ); } SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORBA::ORB_ptr orb) @@ -307,7 +324,7 @@ SALOMEDS_Driver_i* GetDriver(const Handle(SALOMEDSImpl_SObject)& theObject, CORB SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; driver = new SALOMEDS_Driver_i(Engine, orb); } - } + } return driver; } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.hxx b/src/SALOMEDS/SALOMEDS_StudyManager.hxx index 853039564..8de05cf6f 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.hxx @@ -52,10 +52,10 @@ public: virtual _PTR(Study) NewStudy(const std::string& study_name); virtual _PTR(Study) Open(const std::string& theStudyUrl); virtual void Close(const _PTR(Study)& theStudy); - virtual void Save(const _PTR(Study)& theStudy, bool theMultiFile); - virtual void SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile); - virtual void SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile); - virtual void SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile); + virtual bool Save(const _PTR(Study)& theStudy, bool theMultiFile); + virtual bool SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile); + virtual bool SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile); + virtual bool SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile); virtual std::vector GetOpenStudies(); virtual _PTR(Study) GetStudyByName(const std::string& theStudyName) ; virtual _PTR(Study) GetStudyByID(int theStudyID) ; diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index cb1a066ed..1bcaf8caa 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -207,30 +207,30 @@ void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) * Purpose : Save a Study to it's persistent reference */ //============================================================================ -void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { MESSAGE("Save error: Study is null"); - return; + return false; } Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - _impl->Save(aStudyImpl, _factory, theMultiFile); + return _impl->Save(aStudyImpl, _factory, theMultiFile); } -void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { MESSAGE("SaveASCII error: Study is null"); - return; + return false; } Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - _impl->SaveASCII(aStudyImpl, _factory, theMultiFile); + return _impl->SaveASCII(aStudyImpl, _factory, theMultiFile); } //============================================================================= @@ -238,30 +238,30 @@ void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boole * Purpose : Save a study to the persistent reference aUrl */ //============================================================================ -void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { MESSAGE("SaveASCII error: Study is null"); - return; + return false; } Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - _impl->SaveAs(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAs(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile); } -void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { MESSAGE("SaveASCII error: Study is null"); - return; + return false; } Handle(SALOMEDSImpl_Study) aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - _impl->SaveAsASCII(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAsASCII(TCollection_AsciiString((char*)aUrl), aStudyImpl, _factory, theMultiFile); } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 139cb86d3..ef428ed4c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -100,17 +100,17 @@ public: /*! \param Study_ptr arguments */ - virtual void Save( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean Save( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); - virtual void SaveASCII( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean SaveASCII( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); //! method to save a Study to the persistent reference aUrl /*! \param char* arguments, the new URL of the study \param Study_ptr arguments */ - virtual void SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); - virtual void SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); //! method to Get name list of open studies in the session /*! diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx index 3ac01ede8..2c4cdc52c 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder.cxx @@ -25,10 +25,13 @@ #include "SALOMEDS_UseCaseBuilder.hxx" -#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDS.hxx" #include "SALOMEDS_SObject.hxx" -#include "SALOMEDSImpl_UseCaseIterator.hxx" #include "SALOMEDS_UseCaseIterator.hxx" + +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_UseCaseIterator.hxx" + #include #include @@ -57,7 +60,10 @@ bool SALOMEDS_UseCaseBuilder::Append(const _PTR(SObject)& theObject) { bool ret; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->Append(obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->Append(obj->GetLocalImpl()); + } else ret = _corba_impl->Append(obj->GetCORBAImpl()); return ret; } @@ -66,7 +72,10 @@ bool SALOMEDS_UseCaseBuilder::Remove(const _PTR(SObject)& theObject) { bool ret; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->Remove(obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->Remove(obj->GetLocalImpl()); + } else ret = _corba_impl->Remove(obj->GetCORBAImpl()); return ret; } @@ -76,7 +85,10 @@ bool SALOMEDS_UseCaseBuilder::AppendTo(const _PTR(SObject)& theFather, _PTR(SObj bool ret; SALOMEDS_SObject* father = dynamic_cast(theFather.get()); SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->AppendTo(father->GetLocalImpl(), obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->AppendTo(father->GetLocalImpl(), obj->GetLocalImpl()); + } else ret = _corba_impl->AppendTo(father->GetCORBAImpl(), obj->GetCORBAImpl()); return ret; } @@ -86,7 +98,10 @@ bool SALOMEDS_UseCaseBuilder::InsertBefore(const _PTR(SObject)& theFirst, _PTR(S bool ret; SALOMEDS_SObject* first = dynamic_cast(theFirst.get()); SALOMEDS_SObject* next = dynamic_cast(theNext.get()); - if(_isLocal) ret = _local_impl->InsertBefore(first->GetLocalImpl(), next->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->InsertBefore(first->GetLocalImpl(), next->GetLocalImpl()); + } else ret = _corba_impl->InsertBefore(first->GetCORBAImpl(), next->GetCORBAImpl()); return ret; } @@ -95,7 +110,10 @@ bool SALOMEDS_UseCaseBuilder::SetCurrentObject(const _PTR(SObject)& theObject) { bool ret; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->SetCurrentObject(obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->SetCurrentObject(obj->GetLocalImpl()); + } else ret = _corba_impl->SetCurrentObject(obj->GetCORBAImpl()); return ret; } @@ -103,7 +121,10 @@ bool SALOMEDS_UseCaseBuilder::SetCurrentObject(const _PTR(SObject)& theObject) bool SALOMEDS_UseCaseBuilder::SetRootCurrent() { bool ret; - if(_isLocal) ret = _local_impl->SetRootCurrent(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->SetRootCurrent(); + } else ret = _corba_impl->SetRootCurrent(); return ret; } @@ -112,7 +133,10 @@ bool SALOMEDS_UseCaseBuilder::HasChildren(const _PTR(SObject)& theObject) { bool ret; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->HasChildren(obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->HasChildren(obj->GetLocalImpl()); + } else ret = _corba_impl->HasChildren(obj->GetCORBAImpl()); return ret; } @@ -121,7 +145,10 @@ bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject) { bool ret; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) ret = _local_impl->IsUseCase(obj->GetLocalImpl()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->IsUseCase(obj->GetLocalImpl()); + } else ret = _corba_impl->IsUseCase(obj->GetCORBAImpl()); return ret; } @@ -129,7 +156,10 @@ bool SALOMEDS_UseCaseBuilder::IsUseCase(const _PTR(SObject)& theObject) bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName) { bool ret; - if(_isLocal) ret = _local_impl->SetName((char*)theName.c_str()); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->SetName((char*)theName.c_str()); + } else ret = _corba_impl->SetName((char*)theName.c_str()); return ret; } @@ -137,7 +167,10 @@ bool SALOMEDS_UseCaseBuilder::SetName(const std::string& theName) _PTR(SObject) SALOMEDS_UseCaseBuilder::GetCurrentObject() { SALOMEDS_SObject* obj = NULL; - if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->GetCurrentObject()); + if (_isLocal) { + SALOMEDS::Locker lock; + obj = new SALOMEDS_SObject(_local_impl->GetCurrentObject()); + } else obj = new SALOMEDS_SObject(_corba_impl->GetCurrentObject()); return _PTR(SObject)(obj); } @@ -145,7 +178,10 @@ _PTR(SObject) SALOMEDS_UseCaseBuilder::GetCurrentObject() std::string SALOMEDS_UseCaseBuilder::GetName() { std::string aName; - if(_isLocal) aName = _local_impl->GetName().ToCString(); + if (_isLocal) { + SALOMEDS::Locker lock; + aName = _local_impl->GetName().ToCString(); + } else aName = _corba_impl->GetName(); return aName; } @@ -153,7 +189,10 @@ std::string SALOMEDS_UseCaseBuilder::GetName() _PTR(SObject) SALOMEDS_UseCaseBuilder::AddUseCase(const std::string& theName) { SALOMEDS_SObject* obj = NULL; - if(_isLocal) obj = new SALOMEDS_SObject(_local_impl->AddUseCase((char*)theName.c_str())); + if (_isLocal) { + SALOMEDS::Locker lock; + obj = new SALOMEDS_SObject(_local_impl->AddUseCase((char*)theName.c_str())); + } else obj = new SALOMEDS_SObject(_corba_impl->AddUseCase((char*)theName.c_str())); return _PTR(SObject)(obj); } @@ -162,7 +201,10 @@ _PTR(UseCaseIterator) SALOMEDS_UseCaseBuilder::GetUseCaseIterator(const _PTR(SOb { SALOMEDS_UseCaseIterator* it = NULL; SALOMEDS_SObject* obj = dynamic_cast(theObject.get()); - if(_isLocal) it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl())); + if (_isLocal) { + SALOMEDS::Locker lock; + it = new SALOMEDS_UseCaseIterator(_local_impl->GetUseCaseIterator(obj->GetLocalImpl())); + } else it = new SALOMEDS_UseCaseIterator(_corba_impl->GetUseCaseIterator(obj->GetCORBAImpl())); return _PTR(UseCaseIterator)(it); } diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator.cxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator.cxx index 71fc2d899..006658d15 100644 --- a/src/SALOMEDS/SALOMEDS_UseCaseIterator.cxx +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator.cxx @@ -24,6 +24,8 @@ #include "SALOMEDS_UseCaseIterator.hxx" + +#include "SALOMEDS.hxx" #include "SALOMEDS_SObject.hxx" using namespace std; @@ -49,28 +51,40 @@ SALOMEDS_UseCaseIterator::~SALOMEDS_UseCaseIterator() void SALOMEDS_UseCaseIterator::Init(bool theAllLevels) { - if(_isLocal) _local_impl->Init(theAllLevels); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Init(theAllLevels); + } else _corba_impl->Init(theAllLevels); } bool SALOMEDS_UseCaseIterator::More() { bool ret; - if(_isLocal) ret = _local_impl->More(); + if (_isLocal) { + SALOMEDS::Locker lock; + ret = _local_impl->More(); + } else ret = _corba_impl->More(); return ret; } void SALOMEDS_UseCaseIterator::Next() { - if(_isLocal) _local_impl->Next(); + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->Next(); + } else _corba_impl->Next(); } _PTR(SObject) SALOMEDS_UseCaseIterator::Value() { SALOMEDS_SObject* aSO; - if(_isLocal) aSO = new SALOMEDS_SObject(_local_impl->Value()); + if (_isLocal) { + SALOMEDS::Locker lock; + aSO = new SALOMEDS_SObject(_local_impl->Value()); + } else aSO = new SALOMEDS_SObject(_corba_impl->Value()); return _PTR(SObject)(aSO); } diff --git a/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx b/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx index 51e603cd8..1341fafcc 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx @@ -38,10 +38,10 @@ public: virtual _PTR(Study) NewStudy(const std::string& study_name) = 0; virtual _PTR(Study) Open(const std::string& theStudyUrl) = 0; virtual void Close(const _PTR(Study)& theStudy) = 0; - virtual void Save(const _PTR(Study)& theStudy, bool theMultiFile) = 0; - virtual void SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile) = 0; - virtual void SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) = 0; - virtual void SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) = 0; + virtual bool Save(const _PTR(Study)& theStudy, bool theMultiFile) = 0; + virtual bool SaveASCII(const _PTR(Study)& theStudy, bool theMultiFile) = 0; + virtual bool SaveAs(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) = 0; + virtual bool SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) = 0; virtual std::vector GetOpenStudies() = 0; virtual _PTR(Study) GetStudyByName(const std::string& theStudyName) = 0; virtual _PTR(Study) GetStudyByID(int theStudyID) = 0; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index b181b0fb2..b3452db04 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1265,14 +1265,18 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value(); aCompType = sco->ComponentDataType(); //GEOM and MED are independent components - if(aCompType == "GEOM" || aCompType == "MED") aSeq.Prepend(TCollection_ExtendedString(aCompType)); - else aSeq.Append(TCollection_ExtendedString(aCompType)); + if (aCompType == "GEOM" || aCompType == "MED") + aSeq.Prepend(TCollection_ExtendedString(aCompType)); + else + aSeq.Append(TCollection_ExtendedString(aCompType)); } #ifdef WIN32 - TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("\\")+theBaseName+TCollection_AsciiString(".py"); + TCollection_AsciiString aFileName = + thePath + TCollection_AsciiString("\\") + theBaseName + TCollection_AsciiString(".py"); #else - TCollection_AsciiString aFileName=thePath+TCollection_AsciiString("/")+theBaseName+TCollection_AsciiString(".py"); + TCollection_AsciiString aFileName = + thePath + TCollection_AsciiString("/") + theBaseName + TCollection_AsciiString(".py"); #endif //Create a file that will contain a main Study script @@ -1292,7 +1296,8 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, TCollection_AsciiString aBatchModeScript = "salome"; - //Output to the main Study script required Python modules import, set sys.path and add a creation of the study. + //Output to the main Study script required Python modules import, + //set sys.path and add a creation of the study. fp << GetDumpStudyComment().ToCString() << endl << endl; fp << "import sys" << endl; fp << "import " << aBatchModeScript << "\n" << endl; @@ -1362,9 +1367,9 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, fp2.open(aFileName.ToCString(), ios::out); #ifdef WIN32 - isOpened = fp.is_open(); + isOpened = fp2.is_open(); #else - isOpened = fp.rdbuf()->is_open(); + isOpened = fp2.rdbuf()->is_open(); #endif if(!isOpened) { @@ -1377,6 +1382,8 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, fp2 << aStream; fp2.close(); + if (aStream != NULL) delete [] aStream; + //Add to the main script a call to RebuildData of the generated by the component the Python script fp << "import " << aScriptName << endl; fp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << endl; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index 4dcefc7c6..d527211d7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -280,7 +280,8 @@ bool SALOMEDSImpl_StudyBuilder::RemoveObjectWithChildren(const Handle(SALOMEDSIm * Purpose : */ //============================================================================ -bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& anSCO, SALOMEDSImpl_Driver* aDriver) +bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& anSCO, + SALOMEDSImpl_Driver* aDriver) { _errorCode = ""; @@ -291,7 +292,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& if (_doc->Main().FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),Att)) { int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked(); if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); - + TCollection_ExtendedString Res(Att->Value()); Handle(SALOMEDSImpl_AttributeComment) type; @@ -313,24 +314,22 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& } DefineComponentInstance (anSCO, aDriver->GetIOR()); - + TCollection_AsciiString aHDFPath(Res); - - char* aHDFUrl; + + TCollection_AsciiString aHDFUrl; bool isASCII = false; if (HDFascii::isASCII(aHDFPath.ToCString())) { isASCII = true; - char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString()); - aHDFUrl = new char[strlen(aResultPath) + 19]; - sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath); - delete(aResultPath); + aHDFUrl = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString()); + aHDFUrl += "hdf_from_ascii.hdf"; } else { - aHDFUrl = aHDFPath.ToCString(); + aHDFUrl = aHDFPath; } //Open the Study HDF file - HDFfile *hdf_file = new HDFfile(aHDFUrl); - + HDFfile *hdf_file = new HDFfile(aHDFUrl.ToCString()); + char aMultifileState[2]; char ASCIIfileState[2]; try { @@ -340,7 +339,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& hdf_group->OpenOnDisk(); HDFgroup *hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group); hdf_sco_group->OpenOnDisk(); - + unsigned char* aStreamFile = NULL; int aStreamSize = 0; @@ -353,16 +352,17 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& hdf_dataset->ReadFromDisk(aStreamFile); hdf_dataset->CloseOnDisk(); hdf_dataset = 0; - } else aStreamFile = NULL; - + } else + aStreamFile = NULL; + HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); multifile_hdf_dataset->OpenOnDisk(); multifile_hdf_dataset->ReadFromDisk(aMultifileState); - + HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group); ascii_hdf_dataset->OpenOnDisk(); ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); - + // set path without file name from URL int aFileNameSize = Res.Length(); char* aDir = new char[aFileNameSize]; @@ -372,7 +372,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& aDir[aCounter+1] = 0; break; } - + bool aResult = (ASCIIfileState[0]=='A')? aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'): aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'); @@ -385,14 +385,14 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& _errorCode = "Can't load component"; throw HDFexception("Unable to load component"); } - + if(aDir != NULL) delete []aDir; multifile_hdf_dataset->CloseOnDisk(); multifile_hdf_dataset = 0; ascii_hdf_dataset->CloseOnDisk(); ascii_hdf_dataset = 0; - + hdf_sco_group->CloseOnDisk(); hdf_sco_group = 0; hdf_group->CloseOnDisk(); @@ -403,10 +403,9 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& if (isASCII) { Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString; aFilesToRemove->Append(aHDFUrl); - SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); + SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), + aFilesToRemove, true); } - - delete aHDFUrl; } catch (HDFexception) { delete hdf_file; @@ -416,7 +415,6 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& aFilesToRemove->Append(aHDFUrl); SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true); } - delete aHDFUrl; if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); _errorCode = "No persistent file"; -- 2.39.2