1 | #include "mod2.h" |
---|
2 | #ifndef COMM_H |
---|
3 | #define COMM_H |
---|
4 | |
---|
5 | #include <sys/types.h> |
---|
6 | #include "silink.h" |
---|
7 | #include "intvec.h" |
---|
8 | #include "structs.h" |
---|
9 | //#include "febase.h" |
---|
10 | #include "structs.h" |
---|
11 | #include "kutil.h" |
---|
12 | |
---|
13 | #include <stdio.h> |
---|
14 | |
---|
15 | extern int pVariables; |
---|
16 | |
---|
17 | enum stdModus |
---|
18 | { |
---|
19 | ModEnde, // Berechnung sofort verlassen |
---|
20 | ModRead, // Nur zur besseren Lesbarkeit |
---|
21 | ModWrite, // " " " " |
---|
22 | ModRun, // Normales rechnen, Tupel versenden |
---|
23 | ModStep, // Tupel Empfangen, Rechenweg richtet sich nach Nachricht |
---|
24 | ModCalc, // Normale Rechnen Tupel nicht versenden |
---|
25 | ModCheck, // Nachrechnen |
---|
26 | ModPosition // Aktuelles Tupel wird beim Reduzieren |
---|
27 | // neu in der Liste strat->L positioniert. |
---|
28 | }; |
---|
29 | |
---|
30 | enum linkModus |
---|
31 | { |
---|
32 | lnRead, |
---|
33 | lnWrite |
---|
34 | }; |
---|
35 | |
---|
36 | |
---|
37 | enum stdMsg |
---|
38 | { |
---|
39 | // Wird gesendet wenn : |
---|
40 | MsgEnd = 2, // schreibender Prozess die Berechnung beendet hat. |
---|
41 | MsgTupelisZero = 3, // wenn aktuelles Tupel zu NULL geht |
---|
42 | MsgTupel = 4, // wenn aktuelles Tupel nicht zu NULL geht |
---|
43 | MsgTupelPosition = 5, // wenn aktuelles Tupel in strat->Ll neu positioniert wird |
---|
44 | MsgTupelHilb = 6 // wenn ein Tupel mit Hilberfunktion elimiert wurde. |
---|
45 | }; |
---|
46 | |
---|
47 | |
---|
48 | class sklinkvec; |
---|
49 | typedef class sklinkvec * linkvec; |
---|
50 | class sklinkvec |
---|
51 | { |
---|
52 | private: |
---|
53 | si_link * link; |
---|
54 | public: |
---|
55 | int nr; |
---|
56 | sklinkvec(int l=1) { |
---|
57 | nr=l; |
---|
58 | link = (si_link *)Alloc0(sizeof(sip_link)*l); |
---|
59 | } |
---|
60 | |
---|
61 | si_link& operator[](int i) { |
---|
62 | return link[i]; |
---|
63 | } |
---|
64 | }; |
---|
65 | |
---|
66 | class skintarray; |
---|
67 | typedef class skintarray * intarray; |
---|
68 | class skintarray |
---|
69 | { |
---|
70 | private: |
---|
71 | intvec * * vec; |
---|
72 | public: |
---|
73 | int nr; |
---|
74 | skintarray(int l=1) { |
---|
75 | nr=l; |
---|
76 | vec = (intvec **)Alloc0(sizeof(intvec*)*l); |
---|
77 | for(int i=0; i<l ; i++) |
---|
78 | vec[i] = NULL; |
---|
79 | } |
---|
80 | |
---|
81 | intvec*& operator[](int i) { |
---|
82 | return vec[i]; |
---|
83 | } |
---|
84 | |
---|
85 | ~skintarray() { |
---|
86 | if(vec!=NULL) |
---|
87 | { |
---|
88 | for(int i=0; i<nr; i++) |
---|
89 | { |
---|
90 | if((vec[i])!=NULL) |
---|
91 | delete (vec[i]); |
---|
92 | vec[i]=NULL; |
---|
93 | } |
---|
94 | } |
---|
95 | Free((ADDRESS)vec,sizeof(intvec*)*nr); |
---|
96 | vec=NULL; |
---|
97 | } |
---|
98 | }; |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | class skstdLink; |
---|
103 | typedef class skstdLink * stdLink; |
---|
104 | |
---|
105 | class skstdLink |
---|
106 | { |
---|
107 | public: |
---|
108 | stdModus Modus; |
---|
109 | BOOLEAN Verwaltung, |
---|
110 | Receive, |
---|
111 | TupelL, |
---|
112 | TupelWarte, |
---|
113 | SPoly, |
---|
114 | Reduzieren, |
---|
115 | TupelStore, |
---|
116 | TupelMelden, |
---|
117 | TupelTesten, |
---|
118 | TupelPosition, |
---|
119 | ResultSend; |
---|
120 | |
---|
121 | void Init(leftv ,int); |
---|
122 | void Start(kStrategy); |
---|
123 | |
---|
124 | void Store(LObject); // Speichert ein Polynom in der Liste l zur späteren Verarbeitung |
---|
125 | BOOLEAN Restore(kStrategy); // Holt das ein in l gespeicherten Polynom zur Verarbeitung heran. |
---|
126 | |
---|
127 | BOOLEAN ReceiveMsg(); |
---|
128 | void SendTupel(kStrategy); |
---|
129 | void ParseMessage(kStrategy); |
---|
130 | void TupelDifferent(kStrategy); |
---|
131 | void CheckPosition(kStrategy, int); |
---|
132 | void CheckHilb(kStrategy, int); |
---|
133 | |
---|
134 | void Kill(); |
---|
135 | |
---|
136 | BOOLEAN CheckEnd(kStrategy); |
---|
137 | void End(kStrategy); |
---|
138 | lists RestTupel(); |
---|
139 | |
---|
140 | void DispMsg(stdMsg); |
---|
141 | void DispMod(int i=-1); |
---|
142 | private: |
---|
143 | // stdModus Modus; |
---|
144 | linkModus lnModus; |
---|
145 | |
---|
146 | LSet Warteliste; |
---|
147 | int Wartelistemax, Wartelistel; |
---|
148 | int aktuell; // Index des Polynoms in l, das als nächstes verarbeitet wird. |
---|
149 | |
---|
150 | int procnum; |
---|
151 | intarray res; |
---|
152 | linkvec links; |
---|
153 | intvec * msg; |
---|
154 | |
---|
155 | void ParseMessageFinal(kStrategy, int=0); |
---|
156 | void SendMsg(kStrategy, stdMsg msg,int i =0); |
---|
157 | BOOLEAN QueryRestore(); |
---|
158 | void SetModus(stdModus,kStrategy); |
---|
159 | void KillChild(kStrategy,int=-1,BOOLEAN=TRUE); |
---|
160 | }; |
---|
161 | |
---|
162 | |
---|
163 | #endif |
---|