|
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
|
| Rev | Line | |
|---|
| [e2e035e] | 1 | /*
|
|---|
| 2 | * ObserverLog.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Dec 1, 2011
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef OBSERVERLOG_HPP_
|
|---|
| 9 | #define OBSERVERLOG_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include <map>
|
|---|
| 17 | #include <set>
|
|---|
| 18 | #include <sstream>
|
|---|
| 19 | #include <string>
|
|---|
| 20 |
|
|---|
| 21 | #include "Observable.hpp"
|
|---|
| 22 | #include "Observer.hpp"
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | /**
|
|---|
| 26 | * This class is used to log the working of the observer mechanism
|
|---|
| 27 | *
|
|---|
| 28 | * TODO: make this conditional dependent on compiler Flag.
|
|---|
| 29 | */
|
|---|
| 30 | class ObserverLog{
|
|---|
| 31 | friend class Observable;
|
|---|
| 32 | friend class Observer;
|
|---|
| 33 | template <typename> friend class Cacheable;
|
|---|
| 34 | public:
|
|---|
| 35 | ObserverLog();
|
|---|
| 36 | ~ObserverLog();
|
|---|
| 37 | std::string getLog(); // get everything that has been logged
|
|---|
| 38 | std::string getName(void*); // get the name of an actor
|
|---|
| 39 | bool isObservable(void*);
|
|---|
| 40 | private:
|
|---|
| 41 | int count; // number to reference each actor in this framework
|
|---|
| 42 | std::map<void*,std::string> names; // List of names assigned to actors
|
|---|
| 43 | std::set<void*> observables; // List of pointers to Observables. Needed to distinguish Observers and Observables
|
|---|
| 44 | void addName(void*, std::string); // Assign a name to an Actor
|
|---|
| 45 | void addObservable(void*);
|
|---|
| 46 | void deleteName(void*); // delete the name of an Actor
|
|---|
| 47 | void deleteObservable(void*);
|
|---|
| 48 | std::stringstream &addMessage(int depth=0); // Add a Message to the logging
|
|---|
| 49 | std::stringstream log; // The internal log object
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | ObserverLog &observerLog();
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | #endif /* OBSERVERLOG_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.