Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ZORBA_INTERNAL_SYSTEM_DIAGNOSTIC_H
00018 #define ZORBA_INTERNAL_SYSTEM_DIAGNOSTIC_H
00019
00020 #include <map>
00021
00022 #include <zorba/diagnostic.h>
00023
00024 #include "ztd.h"
00025
00026 namespace zorba {
00027 namespace internal {
00028
00029
00030
00031 class ZORBA_DLL_PUBLIC SystemDiagnosticBase : public Diagnostic {
00032 public:
00033
00034
00035
00036
00037
00038
00039
00040
00041 static Diagnostic const* find( char const *localname ) {
00042 map_type const &m = get_map();
00043 map_type::const_iterator const i = m.find( localname );
00044 return i != m.end() ? i->second : 0;
00045 }
00046
00047 private:
00048 typedef std::map<char const*,Diagnostic const*,ztd::less<char const*> >
00049 map_type;
00050
00051 static map_type& get_map();
00052
00053 SystemDiagnosticBase( char const *localname ) {
00054 get_map()[ localname ] = this;
00055 }
00056
00057
00058 template<class QNameType> friend class SystemDiagnostic;
00059 };
00060
00061
00062
00063
00064
00065
00066
00067 template<class QNameType>
00068 class ZORBA_DLL_PUBLIC SystemDiagnostic : public SystemDiagnosticBase {
00069 public:
00070
00071
00072
00073
00074
00075
00076 SystemDiagnostic( char const *localname ) :
00077 SystemDiagnosticBase( localname ), qname_( localname )
00078 {
00079 }
00080
00081
00082 zorba::diagnostic::category category() const { return qname_.category(); }
00083 zorba::diagnostic::kind kind() const { return qname_.kind(); }
00084 zorba::diagnostic::QName const& qname() const { return qname_; }
00085
00086 protected:
00087
00088 Diagnostic const* clone() const { return this; }
00089 void destroy() const { }
00090
00091 private:
00092 QNameType qname_;
00093 };
00094
00095
00096
00097 }
00098 }
00099 #endif
00100