DiaDes  0.1
DIAgnosis of Discrete-Event System
Event.hh
Go to the documentation of this file.
1 #ifndef EVENT_H_
2 #define EVENT_H_
3 
4 #include<string>
5 #include<stdexcept>
6 #include<iostream>
8 #include<diades/sdmdl/Port.hh>
9 
10 namespace Diades
11 {
12 
13  namespace Sdmdl
14  {
15 
16 
20  class EventInvalid : public runtime_error, public domain_error {
21  public:
25  EventInvalid(const string& whatArg) : runtime_error(whatArg), domain_error(whatArg){
26  cerr << "EXCEPTION EventInvalid -> " << whatArg << endl;
27  }
28  };
29 
30 
31  class Event
32  {
33 
34 
35  private:
36 
37  string msg;
38  const Port * prt;
39 
40  public:
41  Event():msg(),prt(0) {};
42  virtual ~Event() {};
43  const string & message() const;
44  const Port & port() const;
45  void setMessage(const string & label);
46  void setPort(const Port & p);
47  string label() const { return port().label() + "." + message(); }
48  bool isObservable() const { return port().isObservable(); }
49  Port::Type type() const {
50  require(EventInvalid, prt!=0, "type: the event has no port (not initialised)");
51  return prt->type();
52  }
53  friend ostream & operator << (ostream & os, const Event & evt);
54  };
55 
56  };
57 };
58 #endif /*EVENT_H_*/
const Port * prt
Definition: Event.hh:38
bool isObservable() const
Definition: Event.hh:48
EventInvalid(const string &whatArg)
Definition: Event.hh:25
Port::Type type() const
Definition: Event.hh:49
ostream & operator<<(ostream &os, const StateNode< T > &stateNode)
#define require(Exception, expr, message)
Definition: Assertion.hh:90
Namespace of the Diades project.
virtual ~Event()
Definition: Event.hh:42
bool isObservable() const
Definition: Port.hh:46
const string & label() const
Definition: Port.hh:47
string label() const
Definition: Event.hh:47
Type type() const
Definition: Port.hh:48