00001 #ifndef toast_log_footer_policies_hpp_INCLUDED 00002 #define toast_log_footer_policies_hpp_INCLUDED 00003 00004 #include <string> 00005 #include <toast/concept_check.hpp> 00006 00016 namespace toast { 00017 namespace log { 00018 00036 template <typename Policy> 00037 struct FooterPolicyConcept 00038 { 00043 void constraints() { 00044 s = p.footer(ERROR); 00045 } 00046 private: 00047 Policy p; 00048 std::string s; 00049 }; 00050 00054 struct no_footer { 00055 static char const* footer(log::severity severity) { return ""; } 00056 protected: 00057 ~no_footer() {} 00058 }; 00059 00064 struct newline 00065 { 00066 static char const* footer(log::severity severity) { return "\n"; } 00067 protected: 00068 ~newline() {} 00069 }; 00070 00071 template <typename FirstFooterPolicy, typename SecondFooterPolicy> 00072 struct footer_policy_aggregator 00073 : public FirstFooterPolicy, public SecondFooterPolicy 00074 { 00075 TOAST_CLASS_REQUIRE(FirstFooterPolicy, toast::log, FooterPolicyConcept); 00076 TOAST_CLASS_REQUIRE(SecondFooterPolicy, toast::log, FooterPolicyConcept); 00077 00078 static std::string footer(log::severity severity) 00079 { 00080 std::string ret = FirstFooterPolicy::footer(severity); 00081 ret += SecondFooterPolicy::footer(severity); 00082 return ret; 00083 } 00084 protected: 00085 ~footer_policy_aggregator() {} 00086 }; 00087 00090 } 00091 } 00092 00093 #endif // toast_log_footer_policies_hpp_INCLUDED