7 #ifndef __IPOBSERVER_HPP__ 8 #define __IPOBSERVER_HPP__ 15 #if IPOPT_CHECKLEVEL > 2 16 # define IP_DEBUG_OBSERVER 18 #ifdef IP_DEBUG_OBSERVER 41 #ifdef IP_DEBUG_OBSERVER 42 static const Index dbg_verbosity;
73 NotifyType notify_type,
85 NotifyType notify_type,
93 virtual void ReceiveNotification(
94 NotifyType notify_type,
132 void ProcessNotification(
152 #ifdef IP_DEBUG_OBSERVER 153 static const Index dbg_verbosity;
232 #ifdef IP_DEBUG_OBSERVER 236 for(
size_t i = 0; i <
subjects_.size(); ++i )
243 for(
size_t i =
subjects_.size(); i > 0; --i )
245 #ifdef IP_DEBUG_OBSERVER 246 DBG_PRINT((1,
"About to detach subjects_[%zd] = %p\n", i, (
const void*)
subjects_[i - 1]));
259 #ifdef IP_DEBUG_OBSERVER 263 std::vector<const Subject*>::iterator attached_subject;
281 #ifdef IP_DEBUG_OBSERVER 283 DBG_PRINT((1,
"Requesting detach of subject: %p\n", (
const void*)subject));
289 std::vector<const Subject*>::iterator attached_subject;
291 #ifdef IP_DEBUG_OBSERVER 296 if( attached_subject !=
subjects_.end() )
298 #ifdef IP_DEBUG_OBSERVER 299 DBG_PRINT((1,
"Removing subject: %p from the list\n", (
const void*)subject));
306 subject->DetachObserver(notify_type,
this);
316 #ifdef IP_DEBUG_OBSERVER 323 std::vector<const Subject*>::iterator attached_subject;
328 #ifdef IP_DEBUG_OBSERVER 345 #ifdef IP_DEBUG_OBSERVER 349 for( std::vector<Observer*>::iterator iter =
observers_.begin(); iter !=
observers_.end(); ++iter )
361 #ifdef IP_DEBUG_OBSERVER 368 std::vector<Observer*>::iterator attached_observer;
384 #ifdef IP_DEBUG_OBSERVER 391 std::vector<Observer*>::iterator attached_observer;
393 #ifdef IP_DEBUG_OBSERVER 410 #ifdef IP_DEBUG_OBSERVER 414 for( std::vector<Observer*>::iterator iter =
observers_.begin(); iter !=
observers_.end(); ++iter )
416 (*iter)->ProcessNotification(notify_type,
this);
std::vector< Observer * > observers_
NotifyType
Enumeration specifying the type of notification.
#define DBG_START_METH(__func_name, __verbose_level)
void RequestAttach(NotifyType notify_type, const Subject *subject)
Derived classes should call this method to request an "Attach" to a Subject.
virtual ~Observer()
Destructor.
virtual ~Subject()
Destructor.
Slight Variation of the Observer Design Pattern (Subject part).
ipindex Index
Type of all indices of vectors, matrices etc.
void Notify(Observer::NotifyType notify_type) const
This file contains a base class for all exceptions and a set of macros to help with exceptions...
Slight Variation of the Observer Design Pattern.
void AttachObserver(Observer::NotifyType notify_type, Observer *observer) const
Attach the specified observer (i.e., begin receiving notifications).
Subject()
Default Constructor.
void ProcessNotification(NotifyType notify_type, const Subject *subject)
Private Method for Receiving Notification should only be called by the friend class Subject...
virtual void ReceiveNotification(NotifyType notify_type, const Subject *subject)=0
Derived classes should overload this method to receive the requested notification from attached Subje...
Observer()
Default Constructor.
#define DBG_PRINT(__printf_args)
void RequestDetach(NotifyType notify_type, const Subject *subject)
Derived classes should call this method to request a "Detach" to a Subject.
std::vector< const Subject * > subjects_
A list of the subjects currently being observed.
void DetachObserver(Observer::NotifyType notify_type, Observer *observer) const
Detach the specified observer (i.e., no longer receive notifications).