Changeset 9530 for code/branches/testing/src/libraries/util
- Timestamp:
- Feb 24, 2013, 4:26:33 PM (12 years ago)
- Location:
- code/branches/testing/src/libraries/util
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/testing/src/libraries/util/UtilPrereqs.h
r8858 r9530 84 84 namespace orxonox 85 85 { 86 class AdditionalContextListener; 86 87 class Clock; 87 88 class Exception; -
code/branches/testing/src/libraries/util/output/OutputListener.cc
r8858 r9530 62 62 63 63 /** 64 @brief Adds a listener to the list. 65 */ 66 void OutputListener::registerListener(AdditionalContextListener* listener) 67 { 68 this->listeners_.push_back(listener); 69 } 70 71 /** 72 @brief Removes a listener from the list. 73 */ 74 void OutputListener::unregisterListener(AdditionalContextListener* listener) 75 { 76 for (std::vector<AdditionalContextListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 77 { 78 if (*it == listener) 79 { 80 this->listeners_.erase(it); 81 break; 82 } 83 } 84 } 85 86 /** 64 87 @brief Defines the level mask in a way which accepts all output up to the level \c max. 65 88 */ … … 88 111 this->levelMask_ = mask; 89 112 90 OutputManager::getInstance().updateCombinedLevelMask(); 113 for (size_t i = 0; i < this->listeners_.size(); ++i) 114 this->listeners_[i]->updatedLevelMask(this); 91 115 } 92 116 … … 118 142 this->additionalContextsLevelMask_ = mask; 119 143 120 OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask(); 144 for (size_t i = 0; i < this->listeners_.size(); ++i) 145 this->listeners_[i]->updatedAdditionalContextsLevelMask(this); 121 146 } 122 147 … … 128 153 this->additionalContextsMask_ = mask; 129 154 130 OutputManager::getInstance().updateCombinedAdditionalContextsMask(); 155 for (size_t i = 0; i < this->listeners_.size(); ++i) 156 this->listeners_[i]->updatedAdditionalContextsMask(this); 131 157 } 132 158 -
code/branches/testing/src/libraries/util/output/OutputListener.h
r8858 r9530 55 55 virtual ~OutputListener(); 56 56 57 void registerListener(AdditionalContextListener* listener); 58 void unregisterListener(AdditionalContextListener* listener); 59 57 60 void setLevelMax(OutputLevel max); 58 61 void setLevelRange(OutputLevel min, OutputLevel max); … … 85 88 virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) = 0; 86 89 90 inline const std::vector<AdditionalContextListener*>& getListeners() const 91 { return this->listeners_; } 92 87 93 private: 88 OutputLevel levelMask_; ///< Mask of accepted output levels, independent of contexts 89 OutputContextMask additionalContextsMask_; ///< Mask of accepted additional contexts 90 OutputLevel additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts 94 std::vector<AdditionalContextListener*> listeners_; ///< List of all registered additional context listeners 95 96 OutputLevel levelMask_; ///< Mask of accepted output levels, independent of contexts 97 OutputContextMask additionalContextsMask_; ///< Mask of accepted additional contexts 98 OutputLevel additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts 91 99 }; 92 100 -
code/branches/testing/src/libraries/util/output/OutputManager.cc
r8858 r9530 113 113 void OutputManager::registerListener(OutputListener* listener) 114 114 { 115 listener->registerListener(this); 115 116 this->listeners_.push_back(listener); 116 117 this->updateMasks(); … … 122 123 void OutputManager::unregisterListener(OutputListener* listener) 123 124 { 125 listener->unregisterListener(this); 124 126 for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 125 127 { -
code/branches/testing/src/libraries/util/output/OutputManager.h
r8858 r9530 43 43 44 44 #include "OutputDefinitions.h" 45 #include "AdditionalContextListener.h" 45 46 46 47 namespace orxonox … … 61 62 Additionally OutputManager is used to register output contexts. 62 63 */ 63 class _UtilExport OutputManager 64 class _UtilExport OutputManager : public AdditionalContextListener 64 65 { 65 66 public: … … 72 73 void unregisterListener(OutputListener* listener); 73 74 74 void updateMasks(); 75 void updateCombinedLevelMask(); 76 void updateCombinedAdditionalContextsLevelMask(); 77 void updateCombinedAdditionalContextsMask(); 75 virtual void updatedLevelMask(const OutputListener* listener) 76 { this->updateCombinedLevelMask(); } 77 virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) 78 { this->updateCombinedAdditionalContextsLevelMask(); } 79 virtual void updatedAdditionalContextsMask(const OutputListener* listener) 80 { this->updateCombinedAdditionalContextsMask(); } 78 81 79 82 /** … … 95 98 std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const; 96 99 100 protected: 101 inline const std::vector<OutputListener*>& getListeners() const 102 { return this->listeners_; } 103 97 104 private: 98 105 OutputManager(); 99 106 OutputManager(const OutputManager&); 100 107 ~OutputManager(); 108 109 void updateMasks(); 110 void updateCombinedLevelMask(); 111 void updateCombinedAdditionalContextsLevelMask(); 112 void updateCombinedAdditionalContextsMask(); 101 113 102 114 std::vector<OutputListener*> listeners_; ///< List of all registered output listeners
Note: See TracChangeset
for help on using the changeset viewer.