From: nge Date: Tue, 1 Jun 2010 18:04:00 +0000 (+0000) Subject: Completing the study observer on the server side X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c1b9a64abe5a719e2d6a9d6bda23f1713845e497;p=modules%2Fkernel.git Completing the study observer on the server side --- diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 85b6e301f..47a33b048 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -159,5 +159,13 @@ SALOMEDS_EXPORT return builder->GetBuilder(); } +/* +SALOMEDS_EXPORT + SALOMEDSClient_Observer* ObserverFactory(SALOME::Observer_ptr theObserver) +{ + if(CORBA::is_nil(theObserver)) return NULL; + return new SALOMEDS_Observer(theObserver); +} +*/ } diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index a041c040b..de2f8bba4 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -999,3 +999,15 @@ _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& } return _PTR(AttributeParameter)(AP); } + +void SALOMEDS_Study::attach(SALOME::Observer_ptr theObserver) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->attach(theObserver); + } + else { + _corba_impl->attach(theObserver); + } +} + diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 1f373fc09..4f17c4d86 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -122,6 +122,7 @@ public: virtual bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName); virtual bool IsVariableUsed(const std::string& theVarName); virtual std::vector< std::vector > ParseVariables(const std::string& theVars); + virtual void attach(SALOME::Observer_ptr theObserver); std::string ConvertObjectToIOR(CORBA::Object_ptr theObject); CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); diff --git a/src/SALOMEDSClient/Makefile.am b/src/SALOMEDSClient/Makefile.am index 98eed253d..38d9160f2 100644 --- a/src/SALOMEDSClient/Makefile.am +++ b/src/SALOMEDSClient/Makefile.am @@ -72,6 +72,7 @@ salomeinclude_HEADERS=\ SALOMEDSClient_UseCaseIterator.hxx \ SALOMEDSClient_ClientFactory.hxx \ SALOMEDSClient_IParameters.hxx \ + SALOMEDSClient_Observer.hxx \ SALOMEDSClient.hxx # diff --git a/src/SALOMEDSClient/SALOMEDSClient_Observer.hxx b/src/SALOMEDSClient/SALOMEDSClient_Observer.hxx new file mode 100644 index 000000000..eb55f97b4 --- /dev/null +++ b/src/SALOMEDSClient/SALOMEDSClient_Observer.hxx @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : SALOMEDSClient_Observer.hxx +// Author : Nicolas GEIMER +// Module : SALOME +// +#ifndef __SALOMEDSClient_OBSERVER_H__ +#define __SALOMEDSClient_OBSERVER_H__ + +#include + +class SALOMEDSClient_Observer +{ + + public: + virtual void notifyObserver(const std::string& theID,const std::string& event) = 0; + +}; + + +#endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 13273ab2a..920104048 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -39,6 +39,8 @@ #include "SALOMEDSClient_UseCaseBuilder.hxx" #include "SALOMEDSClient_AttributeStudyProperties.hxx" #include "SALOMEDSClient_ChildIterator.hxx" +#include "SALOMEDSClient_Observer.hxx" +#include CORBA_CLIENT_HEADER(SALOME_Observer) class SALOMEDSClient_Study { @@ -120,7 +122,9 @@ public: virtual bool IsVariableUsed(const std::string& theVarName) = 0; virtual std::vector< std::vector > ParseVariables(const std::string& theVars) = 0; - + + virtual void attach(SALOME::Observer_ptr theObserver) = 0; + }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index cd7a3133f..1f26a45c2 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -46,6 +46,8 @@ #include #include +#include "utilities.h" + #define DIRECTORYID 16661 #define FILELOCALID 26662 #define FILEID "FILE: " @@ -1991,6 +1993,7 @@ std::vector SALOMEDSImpl_Study::GetIORs() */ //============================================================================ bool SALOMEDSImpl_Study::addSO_Notification (const SALOMEDSImpl_SObject& theSObject) { + MESSAGE("Notification ADD called") CORBA::String_var event="ADD"; CORBA::String_var anID=theSObject.GetID().c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) @@ -2006,6 +2009,7 @@ bool SALOMEDSImpl_Study::addSO_Notification (const SALOMEDSImpl_SObject& theSObj */ //============================================================================ bool SALOMEDSImpl_Study::removeSO_Notification (const SALOMEDSImpl_SObject& theSObject) { + MESSAGE("Notification REMOVE called") CORBA::String_var event="REMOVE"; CORBA::String_var anID=theSObject.GetID().c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) @@ -2021,6 +2025,7 @@ bool SALOMEDSImpl_Study::removeSO_Notification (const SALOMEDSImpl_SObject& theS */ //============================================================================ bool SALOMEDSImpl_Study::modifySO_Notification (const SALOMEDSImpl_SObject& theSObject) { + MESSAGE("Notification MODIFY called") CORBA::String_var event="MODIFY"; CORBA::String_var anID=theSObject.GetID().c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index b1020d2e8..38610cb79 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -91,6 +91,7 @@ SALOMEDSImpl_SComponent SALOMEDSImpl_StudyBuilder::NewComponent(const std::strin SALOMEDSImpl_SComponent so = _study->GetSComponent (NL); if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so); + _study->addSO_Notification(so); _doc->SetModified(true); @@ -148,6 +149,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_StudyBuilder::NewObject(const SALOMEDSImpl_SOb SALOMEDSImpl_SObject so = _study->GetSObject(NewLab); if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so); + _study->addSO_Notification(so); _doc->SetModified(true); return so; @@ -172,6 +174,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_StudyBuilder::NewObjectToTag(const SALOMEDSImp SALOMEDSImpl_SObject so = _study->GetSObject(NewLab); if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so); + _study->addSO_Notification(so); _doc->SetModified(true); return so; @@ -192,6 +195,7 @@ bool SALOMEDSImpl_StudyBuilder::RemoveObject(const SALOMEDSImpl_SObject& anObjec } if(_callbackOnRemove) _callbackOnRemove->OnRemoveSObject(anObject); + _study->removeSO_Notification(anObject); DF_Label Lab = anObject.GetLabel(); @@ -229,6 +233,7 @@ bool SALOMEDSImpl_StudyBuilder::RemoveObjectWithChildren(const SALOMEDSImpl_SObj } if(_callbackOnRemove) _callbackOnRemove->OnRemoveSObject(anObject); + _study->removeSO_Notification(anObject); DF_Label Lab = anObject.GetLabel(); @@ -567,6 +572,7 @@ bool SALOMEDSImpl_StudyBuilder::Addreference(const SALOMEDSImpl_SObject& me, SALOMEDSImpl_AttributeTarget::Set(RefLab)->Add(SALOMEDSImpl_Study::SObject(Lab)); if(_callbackOnRemove && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me); + _study->removeSO_Notification(me); return true; } @@ -924,6 +930,7 @@ bool SALOMEDSImpl_StudyBuilder::SetName(const SALOMEDSImpl_SObject& theSO, SALOMEDSImpl_AttributeName::Set(theSO.GetLabel(), theValue); _doc->SetModified(true); + _study->modifySO_Notification(theSO); return true; } @@ -945,6 +952,7 @@ bool SALOMEDSImpl_StudyBuilder::SetComment(const SALOMEDSImpl_SObject& theSO, SALOMEDSImpl_AttributeComment::Set(theSO.GetLabel(), theValue); _doc->SetModified(true); + _study->modifySO_Notification(theSO); return true; } @@ -966,6 +974,7 @@ bool SALOMEDSImpl_StudyBuilder::SetIOR(const SALOMEDSImpl_SObject& theSO, SALOMEDSImpl_AttributeIOR::Set(theSO.GetLabel(), theValue); _doc->SetModified(true); + _study->modifySO_Notification(theSO); return true; }