00001 #ifndef toast_log_verbosity_policies_hpp_INCLUDED 00002 #define toast_log_verbosity_policies_hpp_INCLUDED 00003 00004 #include <toast/log/severity.hpp> 00005 00017 namespace toast { 00018 namespace log { 00019 00036 template <typename Policy> 00037 struct VerbosityPolicyConcept 00038 { 00043 void constraints() { 00044 b = p.check(DEBUG); 00045 } 00046 private: 00047 bool b; 00048 Policy p; 00049 }; 00050 00055 struct always_output { 00056 bool check(log::severity severity) const { return true; } 00057 protected: 00058 ~always_output() {} 00059 }; 00060 00066 struct never_output { 00067 bool check(log::severity severity) const { return false; } 00068 protected: 00069 ~never_output() {} 00070 }; 00071 00077 struct check_verbosity 00078 { 00079 check_verbosity() : verbosity_(DEBUG) {} 00080 00081 bool check(log::severity severity) const 00082 { 00083 return verbosity_ >= severity; 00084 } 00085 00086 log::severity verbosity() { return verbosity_; } 00087 void verbosity(log::severity v) { verbosity_ = v; } 00088 protected: 00089 ~check_verbosity() {} 00090 private: 00091 log::severity verbosity_; 00092 }; 00093 00096 } 00097 } 00098 00099 #endif // toast_log_verbosity_policies_hpp_INCLUDED