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,
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));
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);
#define DBG_PRINT(__printf_args)
#define DBG_START_METH(__func_name, __verbose_level)
Slight Variation of the Observer Design Pattern.
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...
virtual ~Observer()
Destructor.
void RequestDetach(NotifyType notify_type, const Subject *subject)
Derived classes should call this method to request a "Detach" to a Subject.
void operator=(const Observer &)
Default Assignment Operator.
NotifyType
Enumeration specifying the type of notification.
std::vector< const Subject * > subjects_
A list of the subjects currently being observed.
Observer()
Default Constructor.
void RequestAttach(NotifyType notify_type, const Subject *subject)
Derived classes should call this method to request an "Attach" to a Subject.
Observer(const Observer &)
Copy Constructor.
Slight Variation of the Observer Design Pattern (Subject part).
void Notify(Observer::NotifyType notify_type) const
Subject(const Subject &)
Copy Constructor.
Subject()
Default Constructor.
void AttachObserver(Observer::NotifyType notify_type, Observer *observer) const
Attach the specified observer (i.e., begin receiving notifications).
void DetachObserver(Observer::NotifyType notify_type, Observer *observer) const
Detach the specified observer (i.e., no longer receive notifications).
virtual ~Subject()
Destructor.
std::vector< Observer * > observers_
void operator=(const Subject &)
Default Assignment Operator.
This file contains a base class for all exceptions and a set of macros to help with exceptions.
ipindex Index
Type of all indices of vectors, matrices etc.