|
Last change
on this file since e2e035e was e2e035e, checked in by Frederik Heber <heber@…>, 14 years ago |
|
Refactored all Observer stuff into own subfolder and split up into distinct modules.
- Observer/all.hpp is all that's needed.
|
-
Property mode
set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * Observer.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Jan 19, 2010
|
|---|
| 12 | * Author: crueger
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "Observer/Observer.hpp"
|
|---|
| 23 |
|
|---|
| 24 | #include <iostream>
|
|---|
| 25 |
|
|---|
| 26 | #include "Assert.hpp"
|
|---|
| 27 | #ifdef LOG_OBSERVER
|
|---|
| 28 | #include "Observer/ObserverLog.hpp"
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | using namespace std;
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | /** Constructor for class Observer.
|
|---|
| 35 | */
|
|---|
| 36 | Observer::Observer(string name)
|
|---|
| 37 | {
|
|---|
| 38 | #ifdef LOG_OBSERVER
|
|---|
| 39 | observerLog().addName(this,name);
|
|---|
| 40 | observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl;
|
|---|
| 41 | #endif
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | /**
|
|---|
| 45 | * Base Constructor for class Observer
|
|---|
| 46 | *
|
|---|
| 47 | * only called from Observable Constructor
|
|---|
| 48 | */
|
|---|
| 49 | Observer::Observer(Observer::BaseConstructor){
|
|---|
| 50 | #ifdef LOG_OBSERVER
|
|---|
| 51 | observerLog().addObservable(this);
|
|---|
| 52 | #endif
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | /** Destructor for class Observer.
|
|---|
| 56 | */
|
|---|
| 57 | Observer::~Observer()
|
|---|
| 58 | {
|
|---|
| 59 | #ifdef LOG_OBSERVER
|
|---|
| 60 | if(!observerLog().isObservable(this)){
|
|---|
| 61 | observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl;
|
|---|
| 62 | }
|
|---|
| 63 | #endif
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | /**
|
|---|
| 67 | * Method for specialized notifications.
|
|---|
| 68 | * Most Observers wont need or use this, so it is implemented
|
|---|
| 69 | * empty in the base case;
|
|---|
| 70 | */
|
|---|
| 71 | void Observer::recieveNotification(Observable *publisher, Notification_ptr notification){
|
|---|
| 72 | ASSERT(0,"Notification received by object that did not sign on for it.");
|
|---|
| 73 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.