CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Exceptions/ZMexClassInfo.h
Go to the documentation of this file.
1 #ifndef ZMEXCLASSINFO_H
2 #define ZMEXCLASSINFO_H
3 
4 
5 // ----------------------------------------------------------------------
6 //
7 // ZMexClassInfo.h - class declaration for the member of ZOOM Exception
8 // classes that contains all the static information
9 // that does NOT depend on the parent class.
10 //
11 // Every ZOOM exception must have a static member classInfo, of type
12 // ZMexClassInfo. This is done in the macro ZMexStandardContents.
13 // See ZMexception.h.
14 //
15 // Methods (in .icc):
16 // ZMexClassInfo() constructor
17 // const string name() const;
18 // const string facility() const;
19 // int nextCount();
20 // ZMexHandler getHandler() const;
21 // ZMexHandler setHandler(const ZMexHandler & newHandler);
22 // ZMexLogger getLogger() const;
23 // ZMexLogger setLogger(const ZMexLogger & newLogger);
24 // void logNMore();
25 // bool OKtoLog() const;
26 // int count() const;
27 // int filterMax() const;
28 //
29 // A related header is ZMexHeritage.h which contains class static info
30 // which DOES depend on the parent class.
31 //
32 // Revision History
33 // 970911 MF Initial version
34 // 970914 MF Added nextCount to be able to keep count_ private
35 // 970916 WEB Updated per code review
36 // 970917 WEB Updated per code review 2
37 // 971112 WEB Updated for conformance to standard and the zoom
38 // compatability headers
39 // 971211 WEB Updated per code walkthrough
40 // 971217 WEB Added count() and filterMax() member functions
41 // 980219 WEB Fixed get/set Logger/Handler return type
42 // 980615 WEB Added namespace support
43 // 990721 JVR Added setName, setFacility, and setSeverity functions
44 // 000217 WEB Improve C++ standard compliance
45 // 000503 WEB Avoid global using
46 // 010411 MF setName, setFacility and setSeverity return old value
47 // and take const argument reference
48 // 011212 WEB Pass all std::strings by const &; add new 3- and
49 // 4-arg constructors in lieu of a single 5-arg
50 // constructor taking default arguments
51 // 031105 LG Get rid of all ZMutility references
52 
53 //
54 // ----------------------------------------------------------------------
55 
56 #ifndef STRING_INCLUDED
57  #define STRING_INCLUDED
58  #include <string>
59 #endif
60 
61 #ifndef ZMEXHANDLER_H
63 #endif
64 
65 #ifndef ZMEXLOGGER_H
67 #endif
68 
69 #ifndef ZMEXSEVERITY_H
71 #endif
72 
73 
74 namespace zmex {
75 
76 
77 // ******************************************************
78 //
79 // ZMexClassInfo
80 //
81 // Template for ZMexClassInfo (used to define classInfo)
82 //
83 // ******************************************************
84 
85 // Contains all the methods which are logically "virtual class statics",
86 // and which do not depend on a Parent's method (see note (1)).
87 // Each derived exception contains a ZMexClassInfo member named classInfo.
88 
89 // The members and functions of ZMexClassInfo are public so that when the
90 // exception class uses classInfo it can get at the info. But classInfo itself
91 // is declared protected, to isolate this from the actual interface.
92 
93 
94 class ZMexClassInfo {
95 
96  // - Methods - //
97 
98 public:
99 
101  const std::string & name
102  , const std::string & facility
103  , const ZMexSeverity s = ZMexERROR
104  );
105 
107  const std::string & name
108  , const std::string & facility
109  , const ZMexSeverity s
110  , const ZMexHandler & h
111  );
112 
114  const std::string & name
115  , const std::string & facility
116  , const ZMexSeverity s
117  , const ZMexHandler & h
118  , const ZMexLogger & l
119  );
120 
121  const std::string name() const;
122  // return the name_ of this exception type, which ought to match the
123  // class name ZMexWhatever.
124  const std::string setName(const std::string& newName);
125 
126  const std::string facility() const;
127  // return the name of facility_ this exception type is under.
128  const std::string setFacility(const std::string& newFacility);
129 
130  ZMexSeverity severity() const;
131  // return the severity_ of the exception class.
132  ZMexSeverity setSeverity(const ZMexSeverity& newSeverity);
133 
134  int nextCount();
135  // increment the count_ and return that value
136  int count() const;
137  // return the current count_ value
138 
139  ZMexHandler getHandler () const ;
140  ZMexHandler setHandler( const ZMexHandler & newHandler );
141  // Replace previous handler with this new one.
142 
143  ZMexLogger getLogger() const;
144  ZMexLogger setLogger( const ZMexLogger & newLogger );
145  // Replace previous logger with this new one.
146 
147  void logNMore( const int N );
148  // Allow logging the next N exceptions of this class.
149 
150  bool OKtoLog() const;
151  // May the currently-thrown exception be logged
152  // (based on count_ <= filterMax_)?
153 
154  int filterMax() const;
155  // return the current filterMax_ value
156 
157  // - Data Members - //
158 
159 private:
160  int count_;
161  int filterMax_;
162  std::string name_; // was const
163  std::string facility_; // was const
164  ZMexSeverity severity_; // was const
165 
166  ZMexHandler handler_;
167  ZMexLogger logger_;
168 
169 }; // ZMexClassInfo
170 
171 
172 } // namespace zmex
173 
174 
175 #define ZMEXCLASSINFO_ICC
176 #include "CLHEP/Exceptions/ZMexClassInfo.icc"
177 #undef ZMEXCLASSINFO_ICC
178 
179 
180 #endif // ZMEXCLASSINFO_H
const std::string name() const
void logNMore(const int N)
ZMexSeverity severity() const
const std::string setName(const std::string &newName)
ZMexHandler setHandler(const ZMexHandler &newHandler)
ZMexClassInfo(const std::string &name, const std::string &facility, const ZMexSeverity s=ZMexERROR)
ZMexSeverity setSeverity(const ZMexSeverity &newSeverity)
const std::string facility() const
ZMexHandler getHandler() const
ZMexLogger setLogger(const ZMexLogger &newLogger)
bool OKtoLog() const
ZMexLogger getLogger() const
int filterMax() const
const std::string setFacility(const std::string &newFacility)