Changeset 8850 for code/branches/output
- Timestamp:
- Aug 21, 2011, 6:27:30 PM (13 years ago)
- Location:
- code/branches/output/src/libraries/util
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/util/CMakeLists.txt
r8794 r8850 46 46 output/LogWriter.cc 47 47 output/MemoryWriter.cc 48 output/SubcontextOutputListener.cc 48 49 ) 49 50 -
code/branches/output/src/libraries/util/output/BaseWriter.cc
r8834 r8850 33 33 namespace orxonox 34 34 { 35 BaseWriter::BaseWriter(const std::string& name, bool bRegister) : OutputListener(bRegister)35 BaseWriter::BaseWriter(const std::string& name, bool bRegister) : SubcontextOutputListener(bRegister) 36 36 { 37 37 this->name_ = name; … … 40 40 this->configurableAdditionalContextsMaxLevel_ = level::verbose; 41 41 this->configurableAdditionalContexts_.push_back("example"); 42 43 this->subcontextsCheckMask_ = context::none;44 this->subcontextsNoCheckMask_ = context::none;45 42 46 43 this->changedConfigurableLevel(); … … 55 52 void BaseWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) 56 53 { 57 if (((this->subcontextsCheckMask_ & context.mask) == 0) || 58 (this->subcontextsNoCheckMask_ & context.mask) || 59 (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end())) 60 { 61 const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context); 62 std::string blanks(prefix.length(), ' '); 54 const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context); 55 std::string blanks(prefix.length(), ' '); 63 56 64 for (size_t i = 0; i < lines.size(); ++i) 65 this->printLine((i == 0 ? prefix : blanks) + lines[i], level); 66 } 57 for (size_t i = 0; i < lines.size(); ++i) 58 this->printLine((i == 0 ? prefix : blanks) + lines[i], level); 67 59 } 68 60 … … 91 83 void BaseWriter::changedConfigurableAdditionalContexts() 92 84 { 93 OutputContextMask context_mask = context::none; 94 this->subcontextsCheckMask_ = context::none; 95 this->subcontextsNoCheckMask_ = context::none; 96 97 this->subcontexts_.clear(); 85 OutputContextMask main_contexts = context::none; 86 std::set<const OutputContextContainer*> sub_contexts; 98 87 99 88 for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i) … … 111 100 } 112 101 113 const OutputContextContainer& cont ainer= OutputManager::getInstance().registerContext(name, subname);102 const OutputContextContainer& context = OutputManager::getInstance().registerContext(name, subname); 114 103 115 context_mask |= container.mask; 116 117 if (container.sub_id != context::no_subcontext) 118 { 119 this->subcontexts_.insert(container.sub_id); 120 this->subcontextsCheckMask_ |= container.mask; 121 } 104 if (context.sub_id == context::no_subcontext) 105 main_contexts |= context.mask; 122 106 else 123 { 124 this->subcontextsNoCheckMask_ |= container.mask; 125 } 107 sub_contexts.insert(&context); 126 108 } 127 109 128 this->setAdditionalContextsMask(context_mask); 110 this->setAdditionalContextsMask(main_contexts); 111 this->setAdditionalSubcontexts(sub_contexts); 129 112 } 130 113 } -
code/branches/output/src/libraries/util/output/BaseWriter.h
r8834 r8850 31 31 32 32 #include "util/UtilPrereqs.h" 33 34 #include <set> 35 #include <vector> 36 37 #include "OutputListener.h" 33 #include "SubcontextOutputListener.h" 38 34 39 35 namespace orxonox 40 36 { 41 class _UtilExport BaseWriter : public OutputListener37 class _UtilExport BaseWriter : public SubcontextOutputListener 42 38 { 43 39 public: … … 83 79 84 80 std::string name_; 85 86 OutputContextMask subcontextsCheckMask_;87 OutputContextMask subcontextsNoCheckMask_;88 std::set<OutputContextSubID> subcontexts_;89 81 }; 90 82 } -
code/branches/output/src/libraries/util/output/OutputListener.cc
r8848 r8850 130 130 OutputManager::getInstance().updateCombinedAdditionalContextsMask(); 131 131 } 132 133 /** 134 @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks. 135 */ 136 bool OutputListener::acceptsOutput(OutputLevel level, const OutputContextContainer& context) const 137 { 138 // check if the output level is accepted by the level mask (independent of the context) 139 if (this->levelMask_ & level) 140 return true; 141 142 // check if the output context is accepted by the additional context mask and if the level matches as well 143 if ((this->additionalContextsMask_ & context.mask) && (this->additionalContextsLevelMask_ & level)) 144 return true; 145 146 // otherwise we don't accept the output 147 return false; 148 } 132 149 } -
code/branches/output/src/libraries/util/output/OutputListener.h
r8848 r8850 75 75 { return this->additionalContextsLevelMask_; } 76 76 77 /// @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks. 78 inline bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const 79 { 80 return (this->levelMask_ & level) || 81 ((this->additionalContextsLevelMask_ & level) && (this->additionalContextsMask_ & context.mask)); } 77 virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const; 82 78 83 79 /// @brief Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function.
Note: See TracChangeset
for help on using the changeset viewer.