Net.h 2.86 KB
Newer Older
Hiba Ouni's avatar
parser    
Hiba Ouni committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* -*- C++ -*- */
#ifndef NET_H
#define NET_H
#include <string>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <ext/hash_map>
#include <cstring>
#include "RdPMonteur.h"
typedef set<int> Set;
class Node{
public:
  Node(){};
  ~Node(){};
  vector< pair<int,int> > pre, post, inhibitor, preAuto, postAuto;
  vector<int> reset;
  void addPre(int,int);
  void addPost(int,int);
  void addInhibitor(int,int);
  void addPreAuto(int,int);
  void addPostAuto(int,int);
  void addReset(int);
};

class Place:public Node{
public:
  string name;
  int marking, capacity;
  Place(const string &p,int m=0, int c=0):name(p),marking(m),capacity(c){};
  ~Place(){};
  bool isLossQueue() const {return marking==-2;}
  bool isQueue() const {return marking<=-1;}
  bool hasCapacity() const {return capacity!=0;}
};

class Transition:public Node{
public:
  string name;
  Transition(const string &t):name(t){};
  ~Transition(){};
};
/*-----------------------------------------------------------------*/
struct ltstr
{
	bool operator()(const char* s1, const char* s2) const
	{
		return std::strcmp(s1,s2)<0;
	}
};
typedef set<const char*,ltstr> Set_mot;
typedef vector<Place> PLACES;
typedef vector<Transition> TRANSITIONS;
class net: public RdPMonteur {
private:
 /*Initialisation des attributs*/
  bool Set_Observables(const char* file) ;
  bool Set_Interface_Trans(const char* file) ;
  bool Set_Formula_Trans(const char* file) ;
  bool Set_ObsNonObservables(Set_mot obs) ;
  void Set_Non_Observables();
public:
  /* Attributs */
  vector<class Place> places;
  vector<class Transition> transitions;
  map<string,int> placeName;
  map<string,int> transitionName;
  Set Observable;
  Set NonObservable;
  Set InterfaceTrans;
  Set Formula_Trans;


  /* Constructors */
  net(){};
  ~net(){};
  net(const char *file,const char*Obs="", const char* Int="");
  /* Monteur */
  bool addPlace(const string &place,int marking=0, int capacity=0);
  bool addQueue(const string &place,int capacity=0);
  bool addLossQueue(const string &place,int capacity=0);
  bool addTrans(const string &transition);
  bool addPre(const string &place,const string &transition,int valuation=1);
  bool addPost(const string &place,const string &transition,int valuation=1);
  bool addPreQueue(const string &place,const string &transition,int valuation=1);
  bool addPostQueue(const string &place,const string &transition,int valuation=1);
  bool addInhibitor(const string &place,const string &transition,int valuation=1);
  bool addPreAuto(const string &place,const string &transition,const string &valuation);
  bool addPostAuto(const string &place,const string &transition,const string &valuation);
  bool addReset(const string &place,const string &transition);
  /* Visualisation */
  int nbPlace() const {return places.size();};
  int nbTransition() const {return transitions.size();};
};

ostream& operator<<(ostream &,const net &);
#endif