adevs
adevs_exception.h
1 
31 #ifndef _adevs_exception_h_
32 #define _adevs_exception_h_
33 #include <string>
34 #include <exception>
35 
36 namespace adevs
37 {
38 
43 class exception: public std::exception
44 {
45  public:
51  exception(const char* msg, void* model = NULL):
52  std::exception(),
53  msg(msg),
54  model(model)
55  {}
58  std::exception(src),
59  msg(src.msg),
60  model(src.model)
61  {}
63  const char* what() const throw()
64  {
65  return msg.c_str();
66  }
68  void* who() const { return model; }
70  ~exception() throw(){}
71  private:
72  std::string msg;
73  void* model;
74 };
75 
81  public exception
82 {
83  public:
88  method_not_supported_exception(const char* method, void* model):
89  exception((std::string("Unsupported method: ")+std::string(method)).c_str(),
90  model)
91  {
92  }
93 };
94 
100  public exception
101 {
102  public:
104  exception("Lookahead cannot proceed")
105  {
106  }
107 };
108 
109 } // end of namespace
110 
111 #endif
112 
~exception()
Destructor.
Definition: adevs_exception.h:70
void * who() const
Get a pointer to the model that created the error.
Definition: adevs_exception.h:68
exception(const adevs::exception &src)
Copy constructor.
Definition: adevs_exception.h:57
Definition: adevs_exception.h:43
method_not_supported_exception(const char *method, void *model)
Definition: adevs_exception.h:88
Definition: adevs_exception.h:80
const char * what() const
Get the error message.
Definition: adevs_exception.h:63
Definition: adevs_exception.h:99
exception(const char *msg, void *model=NULL)
Definition: adevs_exception.h:51