DiaDes  0.1
DIAgnosis of Discrete-Event System
Port.hh
Go to the documentation of this file.
1 #ifndef PORT_H_
2 #define PORT_H_
3 
4 #include <string>
5 #include <stdexcept>
6 #include <iostream>
8 
9 using namespace std;
10 
11 namespace Diades
12 {
13  namespace Sdmdl
14  {
18  class PortInvalid : public runtime_error, public domain_error {
19  public:
23  PortInvalid(const string& whatArg) : runtime_error(whatArg), domain_error(whatArg){
24  cerr << "EXCEPTION PortInvalid -> " << whatArg << endl;
25  }
26  };
27  class Port
28  {
29 
30  public:
31 
32  typedef enum{Input,Output} Type;
34  private:
35  string labl;
36  Type _type;
37  bool _obs;
38 
39  public:
40  Port():labl(),_type(),_obs(){}
41  Port(const string & label,Type type):labl(label),_type(type),_obs(false)
42  { require(PortInvalid,!label.empty(),"constructor, the label is empty"); }
43  Port(const string & label,Type type, bool observable):labl(label),_type(type),_obs(observable)
44  { require(PortInvalid,!label.empty(),"constructor, the label is empty"); }
45  virtual ~Port() { };
46  bool isObservable() const { return _obs; }
47  const string & label() const { return labl; }
48  Type type() const { return _type; }
49  friend ostream & operator << (ostream & os, const Port & port);
50  bool operator==(const Port & port) const { return this == &port; }
51  bool operator!=(const Port & port) const { return !(*this == port); }
52  };
53 
54  };
55 };
56 
57 #endif /*PORT_H_*/
Port(const string &label, Type type, bool observable)
Definition: Port.hh:43
STL namespace.
PortInvalid(const string &whatArg)
Definition: Port.hh:23
Port(const string &label, Type type)
Definition: Port.hh:41
#define require(Exception, expr, message)
Definition: Assertion.hh:90
Namespace of the Diades project.
std::ostream & operator<<(std::ostream &os, const Identifier &identifier)
Definition: Identifier.hh:501
bool isObservable() const
Definition: Port.hh:46
virtual ~Port()
Definition: Port.hh:45
const string & label() const
Definition: Port.hh:47
bool operator==(const Port &port) const
Definition: Port.hh:50
bool operator!=(const Port &port) const
Definition: Port.hh:51
Type type() const
Definition: Port.hh:48