SALOME_PyNode.idl \
Palm_Ports.idl \
SALOME_PACOExtension.idl \
- SALOME_ParamPorts.idl
+ SALOME_ParamPorts.idl \
+ SALOME_Observer.idl
MPIIDL_FILES = \
SALOME_MPIObject.idl \
Calcium_PortsSK.cc \
Palm_PortsSK.cc \
SALOME_PACOExtensionSK.cc \
- SALOME_ParamPortsSK.cc
+ SALOME_ParamPortsSK.cc \
+ SALOME_ObserverSK.cc
DYNIDL_SRCS = \
SALOME_PortsDynSK.cc Calcium_PortsDynSK.cc SALOME_ContainerManagerDynSK.cc \
SALOMEDSDynSK.cc SALOME_SessionDynSK.cc SALOME_RessourcesCatalogDynSK.cc \
DSC_EnginesDynSK.cc SALOME_ComponentDynSK.cc SALOME_GenericObjDynSK.cc \
Palm_PortsDynSK.cc SALOME_ExceptionDynSK.cc SALOMEDS_AttributesDynSK.cc \
- LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc
+ LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc SALOME_ObserverDynSK.cc
MPIIDL_SOURCES = \
SALOME_MPIObjectSK.cc \
#include "SALOME_Exception.idl"
#include "SALOME_GenericObj.idl"
+#include "SALOME_Observer.idl"
+
+module SALOME {
+
+ interface Observer;
+
+};
+
/*! \brief
This package contains the interfaces used for creation, management
\return Variables list.
*/
ListOfListOfStrings ParseVariables( in string theVars );
-
+
+/*!
+ Attach an observer to the Study
+
+ \param theObserver
+*/
+ void attach(in SALOME::Observer theObserver);
};
//==========================================================================
\param theValue The value to be set to the IOR attribute.
*/
void SetIOR(in SObject theSO, in string theValue) raises (LockProtection);
+
};
//==========================================================================
--- /dev/null
+// 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
+//
+
+#ifndef _SALOME_OBSERVER_IDL_
+#define _SALOME_OBSERVER_IDL_
+
+#include "SALOMEDS.idl"
+
+module SALOMEDS {
+
+ interface SObject;
+
+};
+
+module SALOME {
+
+ interface Observer
+ {
+ void notifyObserver(in string theID, in string event);
+ };
+
+};
+
+
+#endif
\ No newline at end of file
SALOMEDS_Server_SOURCES = SALOMEDS_Server.cxx
SALOMEDS_Server_CPPFLAGS = $(COMMON_CPPFLAGS)
SALOMEDS_Server_LDADD = libSalomeDS.la \
+ $(top_builddir)/idl/libSalomeIDLKernel.la \
../Basics/libSALOMEBasics.la \
$(HDF5_LIBS) \
$(CORBA_LIBS)
SALOMEDS_Client_SOURCES = SALOMEDS_Client.cxx
SALOMEDS_Client_CPPFLAGS = $(COMMON_CPPFLAGS)
SALOMEDS_Client_LDADD = libSalomeDS.la \
+ $(top_builddir)/idl/libSalomeIDLKernel.la \
../Basics/libSALOMEBasics.la \
$(HDF5_LIBS) \
$(CORBA_LIBS)
}
}
+//============================================================================
+/*! Function : attach
+ * Purpose : This function attach an observer to the study
+ */
+//============================================================================
+void SALOMEDS_Study_i::attach(SALOME::Observer_ptr theObs){
+ SALOMEDS::Locker lock;
+ _impl->attach(theObs);
+}
+
//===========================================================================
// PRIVATE FUNCTIONS
//===========================================================================
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_GenericObj)
#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOME_Observer)
#include <stdio.h>
SALOMEDSImpl_Study* _impl;
SALOMEDS_StudyBuilder_i* _builder;
static std::map<SALOMEDSImpl_Study*, SALOMEDS_Study_i*> _mapOfStudies;
+ typedef std::list<SALOME::Observer_var> ObsList;
+ typedef ObsList::iterator ObsListIter;
+ ObsList myObservers;
public:
virtual SALOMEDSImpl_Study* GetImpl() { return _impl; }
virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
+
+ virtual void attach(SALOME::Observer_ptr theObs);
+
};
#endif
-I$(srcdir)/../HDFPersist \
-I$(srcdir)/../DF \
-I$(srcdir)/../GenericObj \
+ -I$(srcdir)/../SALOMEDS \
-I$(top_builddir)/idl \
-I$(top_builddir) \
@HDF5_INCLUDES@ \
#include "SALOMEDSImpl_Tool.hxx"
#include "SALOMEDSImpl_IParameters.hxx"
#include "SALOMEDSImpl_ScalarVariable.hxx"
+#include "SALOMEDS_Study_i.hxx"
#include <fstream>
#include <sstream>
return anIORs;
}
+
+//============================================================================
+/*! Function : addSO_Notification
+ * Purpose : This function tells all the observers that a SO has been added
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::addSO_Notification (const SALOMEDSImpl_SObject& theSObject) {
+ CORBA::String_var event="ADD";
+ CORBA::String_var anID=theSObject.GetID().c_str();
+ for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
+ {
+ (*it)->notifyObserver(anID,event);
+ }
+ return true; // NGE return always true but can be modified if needed
+}
+
+//============================================================================
+/*! Function : removeSO_Notification
+ * Purpose : This function tells all the observers that a SO has been removed
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::removeSO_Notification (const SALOMEDSImpl_SObject& theSObject) {
+ CORBA::String_var event="REMOVE";
+ CORBA::String_var anID=theSObject.GetID().c_str();
+ for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
+ {
+ (*it)->notifyObserver(anID,event);
+ }
+ return true; // NGE return always true but can be modified if needed
+}
+
+//============================================================================
+/*! Function : modifySO_Notification
+ * Purpose : This function tells all the observers that a SO has been modified
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::modifySO_Notification (const SALOMEDSImpl_SObject& theSObject) {
+ CORBA::String_var event="MODIFY";
+ CORBA::String_var anID=theSObject.GetID().c_str();
+ for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
+ {
+ (*it)->notifyObserver(anID,event);
+ }
+ return true; // NGE return always true but can be modified if needed
+}
+
+//============================================================================
+/*! Function : attach
+ * Purpose : register an Observer
+ */
+//============================================================================
+void SALOMEDSImpl_Study::attach(SALOME::Observer_ptr theObs)
+{
+ myObservers.push_back(SALOME::Observer::_duplicate(theObs));
+}
#include <string>
#include <vector>
#include <map>
+#include <list>
#include "DF_Document.hxx"
#include "DF_Label.hxx"
#include "SALOMEDSImpl_Driver.hxx"
#include "SALOMEDSImpl_ChildIterator.hxx"
#include "SALOMEDSImpl_GenericVariable.hxx"
+#include "SALOME_Observer.hh"
class SALOMEDSImpl_StudyManager;
class SALOMEDSImpl_GenericAttribute;
std::map<std::string, DF_Label> myIORLabels;
std::vector<SALOMEDSImpl_GenericVariable*> myNoteBookVars;
+ typedef std::list<SALOME::Observer_var> ObsList;
+ typedef ObsList::iterator ObsListIter;
+ ObsList myObservers;
+
SALOMEDSImpl_SObject _FindObject(const SALOMEDSImpl_SObject& SO,
const std::string& anObjectName,
bool& _find);
//Returns a list of IOR's stored in the study
std::vector<std::string> GetIORs();
+ // Notification mechanism
+ virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject);
+ virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject);
+ virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject);
+ virtual void attach(SALOME::Observer_ptr theObs);
+
+
friend class SALOMEDSImpl_StudyManager;
friend class SALOMEDSImpl_GenericAttribute;
friend class SALOMEDSImpl_GenericVariable;