1 //
2 // ZoneMinder Exception Class Interface, $Date$, $Revision$
3 // Copyright (C) 2001-2008 Philip Coombes
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 
20 #ifndef ZM_EXCEPTION_H
21 #define ZM_EXCEPTION_H
22 
23 #include <string>
24 
25 class Exception {
26 protected:
27   typedef enum { INFO, WARNING, ERROR, FATAL } Severity;
28 
29 protected:
30   std::string mMessage;
31   Severity mSeverity;
32 
33 public:
34   explicit Exception(const std::string &message, const Severity severity=ERROR) :
mMessage(message)35     mMessage(message),
36     mSeverity(severity)
37   {
38   }
39 
getMessage()40   const std::string &getMessage() const {
41     return mMessage;
42   }
getSeverity()43   Severity getSeverity() const {
44     return mSeverity;
45   }
isInfo()46   bool isInfo() const {
47     return mSeverity == INFO;
48   }
isWarning()49   bool isWarning() const {
50     return( mSeverity == WARNING );
51   }
isError()52   bool isError() const {
53     return( mSeverity == ERROR );
54   }
isFatal()55   bool isFatal() const {
56     return( mSeverity == FATAL );
57   }
58 };
59 
60 #endif // ZM_EXCEPTION_H
61