Changeset 6e2f3b for src/Observer/ObserverLog.cpp
- Timestamp:
- Oct 30, 2015, 11:43:20 AM (10 years ago)
- Children:
- 3681dd
- Parents:
- dd7c44
- git-author:
- Frederik Heber <heber@…> (08/04/15 19:57:52)
- git-committer:
- Frederik Heber <heber@…> (10/30/15 11:43:20)
- File:
-
- 1 edited
-
src/Observer/ObserverLog.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Observer/ObserverLog.cpp
rdd7c44 r6e2f3b 24 24 #include <sstream> 25 25 26 #include <boost/thread/locks.hpp> 27 26 28 #include "CodePatterns/Observer/ObserverLog.hpp" 27 29 #include "CodePatterns/Singleton_impl.hpp" … … 33 35 count(0) 34 36 { 37 boost::lock_guard<boost::recursive_mutex> guard(mutex); 35 38 nullstream = new std::ofstream("/dev/null"); 36 39 outstream = nullstream; … … 39 42 ObserverLog::~ObserverLog() 40 43 { 44 boost::lock_guard<boost::recursive_mutex> guard(mutex); 41 45 outstream = NULL; 42 46 delete nullstream; … … 69 73 void ObserverLog::disableLogging() 70 74 { 75 boost::lock_guard<boost::recursive_mutex> guard(mutex); 71 76 outstream = nullstream; 72 77 } … … 74 79 void ObserverLog::enableLogging() 75 80 { 81 boost::lock_guard<boost::recursive_mutex> guard(mutex); 76 82 outstream = &std::cout; 77 83 } … … 80 86 81 87 std::string ObserverLog::getName(void* obj){ 88 boost::lock_guard<boost::recursive_mutex> guard(mutex); 82 89 return names[obj]; 83 90 } 84 91 85 92 bool ObserverLog::isObservable(void* obj){ 93 boost::lock_guard<boost::recursive_mutex> guard(mutex); 86 94 return observables.count(obj); 87 95 } 88 96 89 97 void ObserverLog::addName(void* obj , std::string name){ 98 boost::lock_guard<boost::recursive_mutex> guard(mutex); 90 99 std::stringstream sstr; 91 100 sstr << name << "_" << count++; … … 94 103 95 104 void ObserverLog::addObservable(void* obj){ 105 boost::lock_guard<boost::recursive_mutex> guard(mutex); 96 106 observables.insert(obj); 97 107 } 98 108 99 109 void ObserverLog::deleteName(void* obj){ 110 boost::lock_guard<boost::recursive_mutex> guard(mutex); 100 111 names.erase(obj); 101 112 } 102 113 103 114 void ObserverLog::deleteObservable(void* obj){ 115 boost::lock_guard<boost::recursive_mutex> guard(mutex); 104 116 observables.erase(obj); 105 117 } … … 114 126 */ 115 127 boost::shared_ptr<ObserverLog::Log> ObserverLog::addMessage(int depth){ 128 boost::lock_guard<boost::recursive_mutex> guard(mutex); 116 129 boost::shared_ptr<ObserverLog::Log> L(new Log(this)); 117 130 for(int i=depth;i--;)
Note:
See TracChangeset
for help on using the changeset viewer.
