/*!
Attach an observer to the Study
- \param theObserver
+ \param theObserver observer being attached
+ \param modify when \c true, observer receives any object's modification events;
+ otherwise observer receives object's creation events only
*/
void attach(in SALOMEDS::Observer theObserver, in boolean modify);
+/*!
+ Detach an observer from the Study
+
+ \param theObserver observer to be detached
+*/
+ void detach(in SALOMEDS::Observer theObserver);
};
//===========================================================================
if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
_corba_impl->attach(theObserver,modify);
}
+
+void SALOMEDS_Study::detach(SALOMEDS::Observer_ptr theObserver)
+{
+ if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it
+ _corba_impl->detach(theObserver);
+}
virtual bool IsVariableUsed(const std::string& theVarName);
virtual std::vector< std::vector<std::string> > ParseVariables(const std::string& theVars);
virtual void attach(SALOMEDS::Observer_ptr theObserver,bool modify);
+ virtual void detach(SALOMEDS::Observer_ptr theObserver);
std::string ConvertObjectToIOR(CORBA::Object_ptr theObject);
CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);
myObservers.push_back(std::make_pair(SALOMEDS::Observer::_duplicate(theObs),modify));
}
+ //============================================================================
+ /*! Function : detach
+ * Purpose : unregister an Observer
+ */
+ //============================================================================
+
+ virtual void detach(SALOMEDS::Observer_ptr theObs)
+ {
+ for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it)
+ {
+ if ( it->first->_is_equivalent(theObs) ) {
+ myObservers.erase( it );
+ break;
+ }
+ }
+ }
+
private:
typedef std::list< std::pair< SALOMEDS::Observer_var, bool > > ObsList;
typedef ObsList::iterator ObsListIter;
static_cast<SALOMEDS::Notifier*>(_notifier)->attach(theObs,modify);
}
+
+//============================================================================
+/*! Function : detach
+ * Purpose : This function detaches an observer from the study
+ */
+//============================================================================
+void SALOMEDS_Study_i::detach(SALOMEDS::Observer_ptr theObs)
+{
+ if(_notifier)
+ static_cast<SALOMEDS::Notifier*>(_notifier)->detach(theObs);
+}
+
//===========================================================================
// PRIVATE FUNCTIONS
//===========================================================================
virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
virtual void attach(SALOMEDS::Observer_ptr theObs, CORBA::Boolean modify);
-
+ virtual void detach(SALOMEDS::Observer_ptr theObs);
};
#endif
virtual std::vector< std::vector<std::string> > ParseVariables(const std::string& theVars) = 0;
virtual void attach(SALOMEDS::Observer_ptr theObserver,bool modify) = 0;
-
+ virtual void detach(SALOMEDS::Observer_ptr theObserver) = 0;
};