CLHEP  2.4.7.2
C++ Class Library for High Energy Physics
ZMexception.icc
Go to the documentation of this file.
1 #ifndef ZMEXCEPTION_ICC
2 #error "Exceptions/ZMexception.icc included without Exceptions/ZMexception.h"
3 #endif
4 
5 
6 // ----------------------------------------------------------------------
7 //
8 // ZMexception.icc
9 //
10 // Constructor ZMexception
11 // message()
12 // count()
13 // wasThrown()
14 // handlerUsed()
15 // severity()
16 // location(line, filename)
17 // fileName()
18 // line()
19 //
20 // Revision History:
21 // 970912 MF Initial version after separating .icc versus .cc
22 // 970916 WEB Updated per code review
23 // 970917 WEB Updated per code review 2
24 // 971211 WEB Updated per code walkthrough
25 // 980421 WEB Moved name() and facility() from .icc to .cc
26 // 980617 WEB Added namespace support
27 // 990318 MF Modified intializer list orders to avoid warnings
28 //
29 // ----------------------------------------------------------------------
30 
31 
32 namespace zmex {
33 
34 
35 // ********************************
36 //
37 // Member functions in base class
38 //
39 // ********************************
40 
41 
42 //**********************
43 // Constructor
44 //**********************
45 
46 inline ZMexception::ZMexception(
47  const std::string & mesg
48 , const ZMexSeverity howBad
49 , int icount
50 ) :
51  message_(mesg)
52 , line_( 0 )
53 , sourceFileName_( "not ZMthrow'n as of yet" )
54 , mySeverity_( howBad == ZMexSEVERITYenumLAST ? _classInfo.severity() : howBad )
55 , myCount_( icount )
56 , wasThrown_( false )
57 { }
58 
59 //**********************
60 // Information accessors
61 //**********************
62 
63 // message()
64 //----------
65 
66 inline std::string ZMexception::message() const {
67  return message_;
68 }
69 
70 // count()
71 //--------
72 
73 inline int ZMexception::count() const {
74  return myCount_;
75 }
76 
77 // wasThrown()
78 //------------
79 
80 inline bool ZMexception::wasThrown() const {
81  return wasThrown_;
82 }
83 
84 inline void ZMexception::wasThrown( bool b ) const {
85 #ifdef DEFECT_NO_MUTABLE
86  ZMexception * localThis = const_cast<ZMexception * const>(this);
87  localThis->wasThrown_ = b;
88 #else
89  wasThrown_ = b;
90 #endif
91 }
92 
93 
94 //**************
95 // handler names
96 //**************
97 
98 // handlerUsed()
99 //--------------
100 
101 inline std::string ZMexception::handlerUsed() const {
102  return handlerUsed_;
103 }
104 
105 inline void ZMexception::handlerUsed( const std::string handlerName ) const {
106 #ifdef DEFECT_NO_MUTABLE
107  ZMexception * localThis = const_cast<ZMexception * const>(this);
108  localThis->handlerUsed_ = handlerName;
109 #else
110  handlerUsed_ = handlerName;
111 #endif
112 }
113 
114 
115 //***********
116 // severity()
117 //***********
118 
119 inline ZMexSeverity ZMexception::severity() const {
120  return mySeverity_;
121 }
122 
123 
124 
125 //******************************
126 // location setter and accessors
127 //******************************
128 
129 // location(line, filename)
130 // fileName()
131 // line()
132 //-------------------------
133 
134 inline void ZMexception::location( int iline, const std::string filename ) const {
135 #ifdef DEFECT_NO_MUTABLE
136  ZMexception * localThis = const_cast<ZMexception * const>(this);
137  localThis->line_ = iline;
138  localThis->sourceFileName_ = filename;
139 #else
140  line_ = iline;
141  sourceFileName_ = filename;
142 #endif
143 }
144 
145 inline std::string ZMexception::fileName() const {
146  return sourceFileName_;
147 }
148 
149 inline int ZMexception::line() const {
150  return line_;
151 }
152 
153 inline bool ZMexception::OKtoLog() const {
154  return classInfo().OKtoLog();
155 }
156 
157 
158 } // namespace zmex
Definition: ZMerrno.icc:27