DABC (Data Acquisition Backbone Core)  2.9.9
Exception.h
Go to the documentation of this file.
1 // $Id: Exception.h 3862 2018-05-11 10:06:18Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_Exception
17 #define DABC_Exception
18 
19 #include <exception>
20 
21 #ifndef DABC_string
22 #include "dabc/string.h"
23 #endif
24 
25 namespace dabc {
26 
28  ex_None, // type is undefined
29  ex_Stop, // stop exception
30  ex_Timeout, // timeout exception
31  ex_Input, // exception with input port
32  ex_Output, // exception with output port
33  ex_Connect, // connect for any port
34  ex_Disconnect, // disconnect for any port
35  ex_Command, // command error,
36  ex_Buffer, // buffer error,
37  ex_Pool, // memory pool error
38  ex_Object, // object error
39  ex_Hierarchy, // hierarchy error
40  ex_Pointer, // pointer error
41  ex_Generic // generic exception, extra info is available
42  };
43 
57  class Exception : public std::exception {
58  protected:
59 
61  std::string fWhat;
62  std::string fItem;
63 
64  public:
65  Exception() throw();
66 
67  Exception(const std::string &info, const std::string &item = "") throw();
68  Exception(ExceptionKind _kind, const std::string &info, const std::string &item) throw();
69  virtual ~Exception() throw();
70 
71  virtual const char* what() const throw();
72 
73  ExceptionKind kind() const { return fKind; }
74  const std::string ItemName() const throw() { return fItem; }
75 
76  bool IsStop() const { return kind() == ex_Stop; }
77  bool IsTimeout() const { return kind() == ex_Timeout; }
78  bool IsInput() const { return kind() == ex_Input; }
79  bool IsOutput() const { return kind() == ex_Output; }
80  bool IsConnect() const { return kind() == ex_Connect; }
81  bool IsDisconnect() const { return kind() == ex_Disconnect; }
82  bool IsCommand() const { return kind() == ex_Command; }
83  bool IsBuffer() const { return kind() == ex_Buffer; }
84  bool IsPool() const { return kind() == ex_Pool; }
85  bool IsPointer() const { return kind() == ex_Pointer; }
86  bool IsObject() const { return kind() == ex_Object; }
87  bool IsHierarchy() const { return kind() == ex_Hierarchy; }
88  };
89 
90 };
91 
92 #endif
DABC exception.
Definition: Exception.h:57
bool IsTimeout() const
Definition: Exception.h:77
const std::string ItemName() const
Definition: Exception.h:74
bool IsObject() const
Definition: Exception.h:86
bool IsStop() const
Definition: Exception.h:76
bool IsHierarchy() const
Definition: Exception.h:87
bool IsBuffer() const
Definition: Exception.h:83
std::string fItem
Definition: Exception.h:62
bool IsPool() const
Definition: Exception.h:84
virtual const char * what() const
Definition: Exception.cxx:53
bool IsCommand() const
Definition: Exception.h:82
bool IsPointer() const
Definition: Exception.h:85
ExceptionKind fKind
Definition: Exception.h:60
bool IsDisconnect() const
Definition: Exception.h:81
bool IsInput() const
Definition: Exception.h:78
bool IsOutput() const
Definition: Exception.h:79
bool IsConnect() const
Definition: Exception.h:80
ExceptionKind kind() const
Definition: Exception.h:73
std::string fWhat
Definition: Exception.h:61
Event manipulation API.
Definition: api.h:23
ExceptionKind
Definition: Exception.h:27
@ ex_Generic
Definition: Exception.h:41
@ ex_Connect
Definition: Exception.h:33
@ ex_Pool
Definition: Exception.h:37
@ ex_Stop
Definition: Exception.h:29
@ ex_Input
Definition: Exception.h:31
@ ex_Output
Definition: Exception.h:32
@ ex_Command
Definition: Exception.h:35
@ ex_Buffer
Definition: Exception.h:36
@ ex_Disconnect
Definition: Exception.h:34
@ ex_Pointer
Definition: Exception.h:40
@ ex_Hierarchy
Definition: Exception.h:39
@ ex_None
Definition: Exception.h:28
@ ex_Timeout
Definition: Exception.h:30
@ ex_Object
Definition: Exception.h:38