Changeset 8771 for code/branches/output/src/libraries/util
- Timestamp:
- Jul 24, 2011, 1:22:11 AM (13 years ago)
- Location:
- code/branches/output/src/libraries/util/output
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/util/output/OutputDefinitions.h
r8765 r8771 31 31 32 32 #include "util/UtilPrereqs.h" 33 #include <string> 33 34 34 35 namespace orxonox … … 58 59 typedef uint64_t OutputContext; 59 60 61 extern _UtilExport OutputContext registerContext(const std::string& name); 62 60 63 namespace context 61 64 { 62 65 static const OutputContext all = 0xFFFFFFFFFFFFFFFF; 63 66 static const OutputContext none = 0x0000000000000000; 64 static const OutputContext undefined = 0x0000000000000001;67 static const OutputContext undefined = registerContext("undefined"); 65 68 66 static const OutputContext test1 = 0x0000000000000002;67 static const OutputContext test2 = 0x0000000000000004;69 static const OutputContext test1 = registerContext("test1"); 70 static const OutputContext test2 = registerContext("test2"); 68 71 } 69 72 } -
code/branches/output/src/libraries/util/output/OutputManager.cc
r8765 r8771 47 47 virtual void output(OutputLevel level, OutputContext context, const std::string& message) 48 48 { 49 COUT(0) << (int)level << " / " << context<< " : " << message << endl;49 COUT(0) << OutputManager::getInstance().getLevelName(level) << " / " << OutputManager::getInstance().getContextName(context) << " : " << message << endl; 50 50 } 51 51 }; … … 119 119 this->combinedContextMask_ |= this->listeners_[i]->getContextMask(); 120 120 } 121 122 OutputContext OutputManager::registerContext(const std::string& name) 123 { 124 boost::bimap<OutputContext, std::string>::right_map::iterator it = this->contexts_.right.find(name); 125 if (it == this->contexts_.right.end()) 126 { 127 OutputContext context = 0x1 << this->contexts_.size(); 128 this->contexts_.insert(boost::bimap<OutputContext, std::string>::value_type(context, name)); 129 return context; 130 } 131 else 132 { 133 return it->second; 134 } 135 } 136 137 OutputContext registerContext(const std::string& name) 138 { 139 COUT(0) << "### register context " << name << std::endl; 140 return OutputManager::getInstance().registerContext(name); 141 } 142 143 const std::string& OutputManager::getLevelName(OutputLevel level) const 144 { 145 switch (level) 146 { 147 case level::none: { static std::string name = "None"; return name; } 148 case level::debug_output: { static std::string name = "Debug"; return name; } 149 case level::user_error: { static std::string name = "Error"; return name; } 150 case level::user_warning: { static std::string name = "Warning"; return name; } 151 case level::user_status: { static std::string name = "Status"; return name; } 152 case level::user_info: { static std::string name = "Info"; return name; } 153 case level::internal_error: { static std::string name = "Error (internal)"; return name; } 154 case level::internal_warning: { static std::string name = "Warning (internal)"; return name; } 155 case level::internal_status: { static std::string name = "Status (internal)"; return name; } 156 case level::internal_info: { static std::string name = "Info (internal)"; return name; } 157 case level::verbose: { static std::string name = "Verbose"; return name; } 158 case level::verbose_more: { static std::string name = "Verbose (more)"; return name; } 159 case level::verbose_ultra: { static std::string name = "Verbose (ultra)"; return name; } 160 default: { static std::string name = ""; return name; } 161 } 162 } 163 164 const std::string& OutputManager::getContextName(OutputContext context) const 165 { 166 if (context != context::undefined) 167 { 168 boost::bimap<OutputContext, std::string>::left_map::const_iterator it = this->contexts_.left.find(context); 169 if (it != this->contexts_.left.end()) 170 { 171 return it->second; 172 } 173 else 174 { 175 static std::string composed_context; 176 composed_context = ""; 177 size_t counter = 0; 178 for (OutputContext context_test = 0x1; context_test != 0x0; context_test = context_test << 1) 179 { 180 if (context & context_test) 181 { 182 it = this->contexts_.left.find(context_test); 183 if (it != this->contexts_.left.end()) 184 { 185 if (counter) 186 composed_context += ", "; 187 188 composed_context += it->second; 189 ++counter; 190 } 191 } 192 } 193 return composed_context; 194 } 195 } 196 return BLANKSTRING; 197 } 121 198 } 122 199 } -
code/branches/output/src/libraries/util/output/OutputManager.h
r8765 r8771 34 34 #include <vector> 35 35 36 #include <boost/bimap.hpp> 37 36 38 #include "OutputDefinitions.h" 37 39 … … 66 68 { return ((this->combinedLevelMask_ & level) && (this->combinedContextMask_ & context)); } 67 69 70 OutputContext registerContext(const std::string& name); 71 72 const std::string& getLevelName(OutputLevel level) const; 73 const std::string& getContextName(OutputContext context) const; 74 68 75 private: 69 76 OutputManager(); … … 77 84 OutputLevel combinedLevelMask_; 78 85 OutputContext combinedContextMask_; 86 87 boost::bimap<OutputContext, std::string> contexts_; 79 88 }; 80 89 } -
code/branches/output/src/libraries/util/output/OutputStream.h
r8765 r8771 40 40 namespace test 41 41 { 42 class _UtilExportOutputStream : public std::ostringstream42 class OutputStream : public std::ostringstream 43 43 { 44 44 typedef std::ostream& (*EndlType)(std::ostream&); 45 45 46 46 public: 47 OutputStream();47 _UtilExport OutputStream(); 48 48 49 void setOutputAttributes(OutputLevel level, OutputContext context);49 void _UtilExport setOutputAttributes(OutputLevel level, OutputContext context); 50 50 51 51 template <class T> … … 74 74 } 75 75 76 void sendMessage();76 void _UtilExport sendMessage(); 77 77 78 78 OutputLevel level_;
Note: See TracChangeset
for help on using the changeset viewer.