- Timestamp:
- Mar 10, 2013, 11:29:44 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/testing/src/libraries/util/output/OutputManager.cc
r9539 r9540 55 55 56 56 this->subcontextCounter_ = 0; 57 58 this->isInitialized_ = false; 59 this->memoryWriterInstance_ = 0; 60 this->consoleWriterInstance_ = 0; 61 this->logWriterInstance_ = 0; 57 62 } 58 63 … … 62 67 OutputManager::~OutputManager() 63 68 { 69 while (!this->listeners_.empty()) 70 this->unregisterListener(this->listeners_[0]); 71 72 if (this->memoryWriterInstance_) 73 delete this->memoryWriterInstance_; 74 if (this->consoleWriterInstance_) 75 delete this->consoleWriterInstance_; 76 if (this->logWriterInstance_) 77 delete this->logWriterInstance_; 64 78 } 65 79 … … 88 102 /*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners() 89 103 { 90 static OutputManager& instance = OutputManager::getInstance(); 91 92 static MemoryWriter& memoryWriterInstance = OutputManager::getInstance().getMemoryWriter(); (void)memoryWriterInstance; 93 static ConsoleWriter& consoleWriterInstance = OutputManager::getInstance().getConsoleWriter(); (void)consoleWriterInstance; 94 static LogWriter& logWriterInstance = OutputManager::getInstance().getLogWriter(); (void)logWriterInstance; 95 96 return instance; 97 } 98 99 /** 100 * @brief Returns the main instance of MemoryWriter which is managed by the OutputManager singleton. 101 * @note If OutputManager is ever un-singletonized, this instance must not remain static. 102 */ 103 MemoryWriter& OutputManager::getMemoryWriter() 104 { 105 static MemoryWriter instance; 106 return instance; 107 } 108 109 /** 110 * @brief Returns the main instance of ConsoleWriter which is managed by the OutputManager singleton. 111 * @note If OutputManager is ever un-singletonized, this instance must not remain static. 112 */ 113 ConsoleWriter& OutputManager::getConsoleWriter() 114 { 115 static ConsoleWriter instance(std::cout); 116 return instance; 117 } 118 119 /** 120 * @brief Returns the main instance of LogWriter which is managed by the OutputManager singleton. 121 * @note If OutputManager is ever un-singletonized, this instance must not remain static. 122 */ 123 LogWriter& OutputManager::getLogWriter() 124 { 125 static LogWriter instance; 104 OutputManager& instance = *OutputManager::Testing::getInstancePointer(); 105 106 if (!instance.isInitialized_) { 107 instance.isInitialized_ = true; 108 instance.memoryWriterInstance_ = new MemoryWriter(); 109 instance.consoleWriterInstance_ = new ConsoleWriter(std::cout); 110 instance.logWriterInstance_ = new LogWriter(); 111 } 112 126 113 return instance; 127 114 }
Note: See TracChangeset
for help on using the changeset viewer.