markingImpl.hpp 6.31 KB
Newer Older
Benoit Barbot's avatar
prog  
Benoit Barbot committed
1
#ifndef _MarkingImpl_HPP
Benoît Barbot's avatar
Benoît Barbot committed
2
#define    _MarkingImpl_HPP
Benoit Barbot's avatar
prog  
Benoit Barbot committed
3 4
using namespace std;
#include <string.h>
Benoît Barbot's avatar
Benoît Barbot committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
enum patient_Color_Classe: int {
	Color_patient_p1,
	Color_patient_p2,
	Color_patient_p3,
	Color_patient_p4,
	Color_patient_p5,
	Color_patient_p6,
	Color_patient_p7,
	Color_patient_p8,
	Color_patient_p9,
	Color_patient_p10,
	Color_patient_p11,
	Color_patient_p12,
	Color_patient_p13,
	Color_patient_p14,
	Color_patient_p15,
	Color_patient_p16,
	Color_patient_p17,
	Color_patient_p18,
	Color_patient_p19,
	Color_patient_p20,
	Color_patient_Total,
	Color_patient_All
Benoît Barbot's avatar
Benoît Barbot committed
28
};
Benoît Barbot's avatar
Benoît Barbot committed
29 30 31 32
extern const char *Color_patient_names[];
struct contains_patient_Color_Classe{
	virtual void apply_perm(patient_Color_Classe,const std::vector<size_t> &index)=0;
	virtual int compare(patient_Color_Classe,int,int) const =0;
Benoît Barbot's avatar
Benoît Barbot committed
33
};
Benoît Barbot's avatar
Benoît Barbot committed
34 35
#include "marking.hpp"
#include "markingTemplate.hpp"
Benoît Barbot's avatar
Benoît Barbot committed
36

Benoît Barbot's avatar
Benoît Barbot committed
37 38 39 40 41 42
struct patient_Token{
	patient_Color_Classe c0;
	int mult;
	patient_Token(  patient_Color_Classe cv0 = (patient_Color_Classe)0, int v =1) {
		c0= cv0;
		mult = v;
Benoît Barbot's avatar
Benoît Barbot committed
43
	}
Benoît Barbot's avatar
Benoît Barbot committed
44 45 46
	patient_Token( const patient_Token& cv0, int v =1) {
		c0= cv0.c0;
		mult = v;
Benoît Barbot's avatar
fix  
Benoît Barbot committed
47
	}
Benoît Barbot's avatar
Benoît Barbot committed
48 49 50
	patient_Token operator * (size_t v){
		mult *= v;
		return *this;
Benoît Barbot's avatar
fix  
Benoît Barbot committed
51
	}
Benoît Barbot's avatar
Benoît Barbot committed
52 53
	void print(std::ostream& out) const {
		out << mult << "<" << Color_patient_names[c0] << ">";
Benoît Barbot's avatar
Benoît Barbot committed
54
	}
Benoît Barbot's avatar
Benoît Barbot committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
	void iter() {
		if( c0< (patient_Color_Classe)(Color_patient_Total - 1) ){ c0 = (patient_Color_Classe)(c0+ 1); return;};
c0 = (patient_Color_Classe)(0);
	}
	bool islast()const {
		return ( c0== (patient_Color_Classe)(Color_patient_Total -1)  );
	}
	bool operator > (const int x){
		return mult > x ;
	}
	bool operator < (const int x){
		return mult < x ;
	}
	bool operator < (const patient_Token &tok) const {
		if (c0 < tok.c0) { return true; }
		if (c0 > tok.c0) { return false; }
		return false;
	}
	bool same_color (const patient_Token &tok) const {
		if (c0 != tok.c0) { return false; }
Benoît Barbot's avatar
Benoît Barbot committed
75 76
		return true;
	}
Benoît Barbot's avatar
Benoît Barbot committed
77 78 79 80 81 82 83 84 85 86 87
};
struct patient_Domain: contains_patient_Color_Classe {
	int mult[ Color_patient_Total ];
	patient_Domain(size_t v =0) { fill( (int*)mult ,((int*)mult) + sizeof(mult)/sizeof(int), v );}
	patient_Domain(patient_Color_Classe c0) {
		fill( (int*)mult ,((int*)mult) + sizeof(mult)/sizeof(int), 0 );
		if(c0 != Color_patient_All)
			mult[c0] = 1 ;
		else{
			for( int i0= ( c0 == Color_patient_All ? 0 : c0);i0< ( c0 == Color_patient_All ? Color_patient_Total : c0+1);i0++)
				mult[i0] = 1 ;
Benoît Barbot's avatar
Benoît Barbot committed
88 89
		}
	}
Benoît Barbot's avatar
Benoît Barbot committed
90 91 92
	size_t copyVector(vector<int> &v ,size_t s)const{
		copy((int*)mult,(int*)mult + sizeof(mult)/sizeof(int), v.begin() + s );
		return s+sizeof(mult)/sizeof(int);
Benoît Barbot's avatar
Benoît Barbot committed
93
	}
Benoît Barbot's avatar
Benoît Barbot committed
94 95 96
	size_t setVector(const vector<int> &v ,size_t s){
		copy(v.begin() + s, v.begin() + s + sizeof(mult)/sizeof(int), (int*)mult );
		return s+sizeof(mult)/sizeof(int);
Benoît Barbot's avatar
Benoît Barbot committed
97
	}
Benoît Barbot's avatar
Benoît Barbot committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
	patient_Domain& operator = (const patient_Domain& x){
		copy((int*)x.mult,(int*)x.mult + sizeof(mult)/sizeof(int),(int*)mult);
		return *this;
	}
	bool operator == (const patient_Domain& x){
		return  equal((int*)mult, ((int*)mult) + sizeof(mult)/sizeof(int), (int*)x.mult);
	}
	bool operator < (const patient_Domain& x){
		return  equal((int*)mult, ((int*)mult) + sizeof(mult)/sizeof(int), (int*)x.mult,std::less<int>());
	}
	bool operator > (const patient_Domain& x){
		return  equal((int*)mult, ((int*)mult) + sizeof(mult)/sizeof(int), (int*)x.mult,std::greater<int>());
	}
	patient_Domain operator * (int v){
		for(size_t count = 0 ; count < sizeof(mult)/sizeof(int);count++) ((int*)mult)[count]*= v;
		return *this;
	}
	patient_Domain& operator += (const patient_Domain& x){
		for(size_t count = 0 ; count < sizeof(mult)/sizeof(int);count++)
			((int*)mult)[count]+= ((int*)x.mult)[count] ;
		return *this;
	}
	patient_Domain& operator += (const patient_Token& x){
		mult[ x.c0 ] += x.mult;
		return *this;
	}
	patient_Domain operator + (const patient_Token& x){
		patient_Domain d(*this);
		d+=x;
 		return d;
	}
	patient_Domain& operator -= (const patient_Token& x){
		mult[ x.c0 ] -= x.mult;
		return *this;
	}
	bool operator < (const patient_Token& x)const{
		return mult[ x.c0 ] < x.mult;
	}
	bool operator >= (const patient_Token& x)const{
		return mult[ x.c0 ] >= x.mult;
	}
	patient_Domain operator + (const patient_Domain& x)const{
		patient_Domain returnval = *this; returnval+= x;
		return returnval;
	}
	patient_Domain& operator -= (const patient_Domain& x){
		for(size_t count = 0 ; count < sizeof(mult)/sizeof(int);count++)
			((int*)mult)[count]-= ((int*)x.mult)[count] ;
		return *this;
	}
	patient_Domain operator - (const patient_Domain& x)const{
		patient_Domain returnval = *this; returnval-= x;
		return returnval;
	}
	int card (void){
	int acc=0;
		for(size_t count = 0 ; count < sizeof(mult)/sizeof(int);count++)
			acc += ((int*)mult)[count] ;
		return acc;
	}
	virtual void apply_perm(patient_Color_Classe,const std::vector<size_t> &index){
		patient_Domain temp = *this ;
		for( int i0= 0 ; i0< Color_patient_Total ;i0++)
			mult[i0] = temp.mult[ index[i0] ];
	}
	virtual int compare(patient_Color_Classe,int cci,int ccj)const{
		{
			if(mult[ cci ] > mult[ ccj ])return 1;
			if(mult[ cci ] < mult[ ccj ])return -1;
		}
		return 0;
	}
};
patient_Domain operator + (const patient_Token& t1 ,const patient_Token& t2 )

;std::ostream& operator << (std::ostream& out, const patient_Domain& x);
Benoît Barbot's avatar
fix  
Benoît Barbot committed
174 175
#ifndef ABSTRACT_BINDING_h
#define ABSTRACT_BINDING_h
176
class abstractBindingImpl {
Benoit Barbot's avatar
prog  
Benoit Barbot committed
177
public:
Benoît Barbot's avatar
Benoît Barbot committed
178
	patient_Token x = patient_Token((patient_Color_Classe) 0);
Benoît Barbot's avatar
Benoît Barbot committed
179
};
Benoît Barbot's avatar
fix  
Benoît Barbot committed
180
#endif
Benoît Barbot's avatar
Benoît Barbot committed
181
class abstractMarkingImpl {
Benoît Barbot's avatar
Benoît Barbot committed
182
public:
Benoît Barbot's avatar
Benoît Barbot committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
	patient_Domain _PL_ReadyT;
	patient_Domain _PL_Healthy;
	patient_Domain _PL_Ill;
	patient_Domain _PL_Arrival;
	patient_Domain _PL_ThreatedByDocH;
	patient_Domain _PL_ThreatedByDocL;
	patient_Domain _PL_WaitingRoom;
	int _PL_OperatingRoom;
	patient_Domain _PL_ArrivalUrgence;
	patient_Domain _PL_USurgery;
	int _PL_TraumaTeam;
	patient_Domain _PL_Ustab;
	patient_Domain _PL_WSurgery;
	patient_Domain _PL_WBloodEx;
	patient_Domain _PL_WXRayEx;
	int _PL_CountDoctor;
	patient_Domain _PL_MonitoredRoom;
	int _PL_Doctor;
	patient_Domain _PL_PatientRecovered;
	patient_Domain _PL_UBloodEx;
	int _PL_ResB;
	patient_Domain _PL_Waiting;
	int _PL_ResX;
	patient_Domain _PL_UXRayEx;
	patient_Domain _PL_FXRay;
	patient_Domain _PL_FBloodEx;
	patient_Domain x;
Benoît Barbot's avatar
Benoît Barbot committed
210 211
};

Benoît Barbot's avatar
prog  
Benoît Barbot committed
212
class abstractBindingIteratorImpl {
Benoît Barbot's avatar
Benoît Barbot committed
213
public:
Benoît Barbot's avatar
prog  
Benoît Barbot committed
214 215 216 217 218
	const static bool isValid =false;
	void reset(size_t,const abstractMarkingImpl& m){};
	void next(size_t& t,const abstractMarkingImpl& m){};
	size_t getIndex(){return 0;};
	abstractBinding getBinding(){return abstractBinding();};
Benoît Barbot's avatar
Benoît Barbot committed
219 220
};
#endif