Changeset 2c11c1 for src/Patterns/Observer/ObserverLog.hpp
- Timestamp:
- Dec 13, 2011, 10:45:00 AM (14 years ago)
- Children:
- d85532
- Parents:
- 40f2e6
- git-author:
- Frederik Heber <heber@…> (12/02/11 13:05:49)
- git-committer:
- Frederik Heber <heber@…> (12/13/11 10:45:00)
- File:
-
- 1 edited
-
src/Patterns/Observer/ObserverLog.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Observer/ObserverLog.hpp
r40f2e6 r2c11c1 14 14 #endif 15 15 16 #include <boost/shared_ptr.hpp> 16 17 #include <map> 17 18 #include <set> 19 #include <iosfwd> 20 #include <string> 18 21 #include <sstream> 19 #include <string>20 22 21 23 #include "Observable.hpp" 22 24 #include "Observer.hpp" 23 25 #include "Singleton.hpp" 24 26 25 27 /** … … 28 30 * TODO: make this conditional dependent on compiler Flag. 29 31 */ 30 class ObserverLog {32 class ObserverLog : public Singleton<ObserverLog> { 31 33 friend class Observable; 32 34 friend class Observer; 35 friend class Relay; 33 36 template <typename> friend class Cacheable; 37 friend class Singleton<ObserverLog>; 34 38 public: 35 ObserverLog();36 ~ObserverLog();37 39 std::string getLog(); // get everything that has been logged 38 40 std::string getName(void*); // get the name of an actor 39 41 bool isObservable(void*); 42 void disableLogging(); 43 void enableLogging(); 44 45 /** tiny helper class to allow for both capturing and printing of messages. 46 * 47 */ 48 class Log { 49 public: 50 Log(ObserverLog *_callback_ref); 51 ~Log(); 52 53 std::stringstream log; // the internal stream that later gets appended 54 ObserverLog *callback_ref; // internal stringstream to capture messages 55 }; 56 40 57 private: 58 ObserverLog(); 59 ~ObserverLog(); 41 60 int count; // number to reference each actor in this framework 42 61 std::map<void*,std::string> names; // List of names assigned to actors … … 46 65 void deleteName(void*); // delete the name of an Actor 47 66 void deleteObservable(void*); 48 std::stringstream &addMessage(int depth=0); // Add a Message to the logging 49 std::stringstream log; // The internal log object 67 boost::shared_ptr<ObserverLog::Log> addMessage(int depth=0); // Add a Message to the logging 68 std::stringstream log; 69 static std::ostream *nullstream; // stream that is not displayed 70 static std::ostream *outstream; // stream that is currently used 50 71 }; 51 72 52 73 ObserverLog &observerLog(); 53 74 54 75 template <class T> 76 boost::shared_ptr<ObserverLog::Log> operator<<(boost::shared_ptr<ObserverLog::Log> L, const T msg) 77 { 78 L->log << msg; 79 return L; 80 } 55 81 56 82 #endif /* OBSERVERLOG_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.
