]> www.fi.muni.cz Git - evince.git/blob - dvi/dvilib/dl-dvi-program.hh
afe5fdbfc0737842ae8fe3c7e3f0720613da87f1
[evince.git] / dvi / dvilib / dl-dvi-program.hh
1 #ifndef DL_DVI_PROGRAM_HH__
2 #define DL_DVI_PROGRAM_HH__
3
4 using namespace std;
5
6 #include <string>
7 #include <vector>
8
9 #include <iostream>
10
11 #include "dl-refcounted.hh"
12 #include "dl-dvi-runtime.hh"
13
14 namespace DviLib
15 {
16     class DviCommand : public RefCounted
17     {
18     public:
19         virtual void execute (DviRuntime& runtime) = 0;
20         virtual ~DviCommand() {};
21     };
22     
23     class AbstractDviProgram : public RefCounted
24     {
25     public:
26         virtual void execute (DviRuntime &runtime) = 0;
27         virtual ~AbstractDviProgram (void) {};
28     };
29     
30     class DviProgram : public AbstractDviProgram
31     {
32     public:
33         vector <DviCommand *> commands;
34         void add_command (DviCommand *cmd);
35         virtual void execute (DviRuntime& runtime);
36         virtual ~DviProgram (void);
37     };
38     
39     class DviCharCommand : public DviCommand
40     {
41     private:
42         uint c;
43         
44     public:
45         DviCharCommand (uint c_arg)
46         {
47             c = c_arg;
48         }
49         uint get_c (void) const { return c; }
50     };
51     
52     class DviPutCharCommand : public DviCharCommand
53     {
54     public:
55         DviPutCharCommand (uint ch) : DviCharCommand (ch) {};
56         virtual void execute (DviRuntime& runtime) 
57         {
58             runtime.put_char (get_c());
59         }
60     };
61     
62     class DviSetCharCommand : public DviCharCommand
63     {
64     public:
65         DviSetCharCommand (uint ch) : DviCharCommand (ch) {};
66         virtual void execute (DviRuntime& runtime) 
67         {
68             runtime.set_char (get_c());
69         }
70     };
71     
72     class DviRuleCommand : public DviCommand
73     {
74     private:
75         int h, w;
76         
77     public:
78         DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg) 
79         {
80             std::cout << "rule cmd " << h << " " << w << std::endl;
81         }
82         int get_h (void) const { return h; }
83         int get_w (void) const { return w; }
84     };
85     
86     class DviPutRuleCommand : public DviRuleCommand
87     {
88     public:
89         DviPutRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
90         virtual void execute (DviRuntime& runtime) 
91         {
92             runtime.put_rule (get_h(), get_w());
93         }
94     };
95     
96     class DviSetRuleCommand : public DviRuleCommand
97     {
98     public:
99         DviSetRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
100         virtual void execute (DviRuntime& runtime) 
101         {
102             runtime.set_rule (get_h(), get_w());
103         }
104     };
105     
106     class DviPushCommand : public DviCommand
107     {
108     public:
109         DviPushCommand () {};
110         virtual void execute (DviRuntime& runtime) 
111         {
112             runtime.push ();
113         }
114     };
115     
116     class DviPopCommand : public DviCommand
117     {
118     public:
119         DviPopCommand () {};
120         virtual void execute (DviRuntime& runtime) 
121         {
122             runtime.pop ();
123         }
124     };
125     
126     class DviMoveCommand : public DviCommand
127     {
128     private:
129         int len;
130         
131     public:
132         DviMoveCommand (int len_arg) : len (len_arg) {};
133         int get_len (void) { return len; }
134     };
135     
136     class DviRightCommand : public DviMoveCommand
137     {
138     public:
139         DviRightCommand (int len) : DviMoveCommand (len) 
140         {
141 #if 0
142             cout << "right command " << get_len() << endl;
143 #endif
144         };
145         virtual void execute (DviRuntime& runtime) 
146         {
147             runtime.right (get_len());
148         }
149     };
150     
151     class DviWCommand : public DviMoveCommand
152     {
153     public:
154         DviWCommand (int len) : DviMoveCommand (len) {};
155         virtual void execute (DviRuntime& runtime) 
156         {
157             runtime.w (get_len());
158         }
159     };
160     
161     class DviXCommand : public DviMoveCommand
162     {
163     public:
164         DviXCommand (int len) : DviMoveCommand (len) {};
165         virtual void execute (DviRuntime& runtime) 
166         {
167             runtime.x (get_len());
168         }
169     };
170     
171     class DviDownCommand : public DviMoveCommand
172     {
173     public:
174         DviDownCommand (int len) : DviMoveCommand (len) 
175         {
176 #if 0
177             cout << "down command " << get_len() << endl;
178 #endif
179         };
180         virtual void execute (DviRuntime& runtime) 
181         {
182             runtime.down (get_len());
183         }
184     };
185     
186     class DviYCommand : public DviMoveCommand
187     {
188     public:
189         DviYCommand (int len) : DviMoveCommand (len) {};
190         virtual void execute (DviRuntime& runtime) 
191         {
192             runtime.y (get_len());
193         }
194     };
195     
196     class DviZCommand : public DviMoveCommand
197     {
198     public:
199         DviZCommand (int len) : DviMoveCommand (len) {};
200         virtual void execute (DviRuntime& runtime) 
201         {
202             runtime.z (get_len());
203         }
204     };
205     
206     class DviFontNumCommand : public DviCommand
207     {
208     private:
209         int num;
210         
211     public:
212         DviFontNumCommand (int num_arg) : num (num_arg) {}
213         virtual void execute (DviRuntime& runtime)
214         {
215             runtime.font_num (num);
216         }
217     };
218     
219     class DviSpecialCommand : public DviCommand
220     {
221         string spc;
222     public:
223         DviSpecialCommand (string s) : spc (s) {};
224         virtual ~DviSpecialCommand () {};
225         virtual void execute (DviRuntime& runtime) 
226         {
227             runtime.special (spc);
228         }
229     };
230     
231     class DviWRepCommand : public DviCommand
232     {
233     public:
234         DviWRepCommand () {};
235         virtual void execute (DviRuntime& runtime) 
236         {
237             runtime.w_rep ();
238         }
239     };
240     
241     class DviXRepCommand : public DviCommand
242     {
243     public:
244         DviXRepCommand () {};
245         virtual void execute (DviRuntime& runtime) 
246         {
247             runtime.x_rep ();
248         }
249     };
250     
251     class DviYRepCommand : public DviCommand
252     {
253     public:
254         DviYRepCommand () {};
255         virtual void execute (DviRuntime& runtime) 
256         {
257             runtime.y_rep ();
258         }
259     };
260     
261     class DviZRepCommand : public DviCommand
262     {
263     public:
264         DviZRepCommand () {};
265         virtual void execute (DviRuntime& runtime) 
266         {
267             runtime.z_rep ();
268         }
269     };
270     
271 }
272 #endif // DL_DVI_PROGRAM_HH__