9 #ifndef __IPOBSERVER_HPP__ 10 #define __IPOBSERVER_HPP__ 17 #if COIN_IPOPT_CHECKLEVEL > 2 18 # define IP_DEBUG_OBSERVER 20 #ifdef IP_DEBUG_OBSERVER 42 #ifdef IP_DEBUG_OBSERVER 44 static const Index dbg_verbosity;
132 #ifdef IP_DEBUG_OBSERVER 134 static const Index dbg_verbosity;
200 #ifdef IP_DEBUG_OBSERVER 210 #ifdef IP_DEBUG_OBSERVER 221 #ifdef IP_DEBUG_OBSERVER 225 std::vector<const Subject*>::iterator attached_subject;
240 #ifdef IP_DEBUG_OBSERVER 242 DBG_PRINT((1,
"Requesting detach of subject: 0x%x\n", subject));
247 std::vector<const Subject*>::iterator attached_subject;
249 #ifdef IP_DEBUG_OBSERVER 254 if (attached_subject !=
subjects_.end()) {
255 #ifdef IP_DEBUG_OBSERVER 256 DBG_PRINT((1,
"Removing subject: 0x%x from the list\n", subject));
270 #ifdef IP_DEBUG_OBSERVER 276 std::vector<const Subject*>::iterator attached_subject;
281 #ifdef IP_DEBUG_OBSERVER 298 #ifdef IP_DEBUG_OBSERVER 302 std::vector<Observer*>::iterator iter;
303 for (iter = observers_.begin(); iter != observers_.end(); iter++) {
311 #ifdef IP_DEBUG_OBSERVER 318 std::vector<Observer*>::iterator attached_observer;
319 attached_observer = std::find(observers_.begin(), observers_.end(), observer);
320 DBG_ASSERT(attached_observer == observers_.end());
325 observers_.push_back(observer);
331 #ifdef IP_DEBUG_OBSERVER 337 std::vector<Observer*>::iterator attached_observer;
338 attached_observer = std::find(observers_.begin(), observers_.end(), observer);
339 #ifdef IP_DEBUG_OBSERVER 341 DBG_ASSERT(attached_observer != observers_.end());
344 if (attached_observer != observers_.end()) {
345 observers_.erase(attached_observer);
353 #ifdef IP_DEBUG_OBSERVER 357 std::vector<Observer*>::iterator iter;
358 for (iter = observers_.begin(); iter != observers_.end(); iter++) {
359 (*iter)->ProcessNotification(notify_type,
this);
void operator=(const Observer &)
Overloaded Equals Operator.
std::vector< Observer * > observers_
NotifyType
Enumeration specifying the type of notification.
int Int
Type of default integer.
#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()
Default destructor.
virtual ~Subject()
Default destructor.
Slight Variation of the Observer Design Pattern (Subject part).
void Notify(Observer::NotifyType notify_type) const
Slight Variation of the Observer Design Pattern.
void AttachObserver(Observer::NotifyType notify_type, Observer *observer) const
Attach the specified observer (i.e., begin recieving notifications).
Subject()
Default Constructor.
void ProcessNotification(NotifyType notify_type, const Subject *subject)
Private Method for Recieving Notification should only be called by the friend class Subject...
int Index
Type of all indices of vectors, matrices etc.
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.
virtual void RecieveNotification(NotifyType notify_type, const Subject *subject)=0
Derived classes should overload this method to recieve the requested notification from attached Subje...
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 recieve notifications).