1 #ifndef DL_DVI_PROGRAM_HH__
2 #define DL_DVI_PROGRAM_HH__
11 #include "dl-refcounted.hh"
12 #include "dl-dvi-runtime.hh"
16 class DviCommand : public RefCounted
19 virtual void execute (DviRuntime& runtime) = 0;
20 virtual ~DviCommand() {};
23 class AbstractDviProgram : public RefCounted
26 virtual void execute (DviRuntime &runtime) = 0;
27 virtual ~AbstractDviProgram (void) {};
30 class DviProgram : public AbstractDviProgram
33 vector <DviCommand *> commands;
34 void add_command (DviCommand *cmd);
35 virtual void execute (DviRuntime& runtime);
36 virtual ~DviProgram (void);
39 class DviCharCommand : public DviCommand
45 DviCharCommand (uint c_arg)
49 uint get_c (void) const { return c; }
52 class DviPutCharCommand : public DviCharCommand
55 DviPutCharCommand (uint ch) : DviCharCommand (ch) {};
56 virtual void execute (DviRuntime& runtime)
58 runtime.put_char (get_c());
62 class DviSetCharCommand : public DviCharCommand
65 DviSetCharCommand (uint ch) : DviCharCommand (ch) {};
66 virtual void execute (DviRuntime& runtime)
68 runtime.set_char (get_c());
72 class DviRuleCommand : public DviCommand
78 DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg)
80 std::cout << "rule cmd " << h << " " << w << std::endl;
82 int get_h (void) const { return h; }
83 int get_w (void) const { return w; }
86 class DviPutRuleCommand : public DviRuleCommand
89 DviPutRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
90 virtual void execute (DviRuntime& runtime)
92 runtime.put_rule (get_h(), get_w());
96 class DviSetRuleCommand : public DviRuleCommand
99 DviSetRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
100 virtual void execute (DviRuntime& runtime)
102 runtime.set_rule (get_h(), get_w());
106 class DviPushCommand : public DviCommand
109 DviPushCommand () {};
110 virtual void execute (DviRuntime& runtime)
116 class DviPopCommand : public DviCommand
120 virtual void execute (DviRuntime& runtime)
126 class DviMoveCommand : public DviCommand
132 DviMoveCommand (int len_arg) : len (len_arg) {};
133 int get_len (void) { return len; }
136 class DviRightCommand : public DviMoveCommand
139 DviRightCommand (int len) : DviMoveCommand (len)
142 cout << "right command " << get_len() << endl;
145 virtual void execute (DviRuntime& runtime)
147 runtime.right (get_len());
151 class DviWCommand : public DviMoveCommand
154 DviWCommand (int len) : DviMoveCommand (len) {};
155 virtual void execute (DviRuntime& runtime)
157 runtime.w (get_len());
161 class DviXCommand : public DviMoveCommand
164 DviXCommand (int len) : DviMoveCommand (len) {};
165 virtual void execute (DviRuntime& runtime)
167 runtime.x (get_len());
171 class DviDownCommand : public DviMoveCommand
174 DviDownCommand (int len) : DviMoveCommand (len)
177 cout << "down command " << get_len() << endl;
180 virtual void execute (DviRuntime& runtime)
182 runtime.down (get_len());
186 class DviYCommand : public DviMoveCommand
189 DviYCommand (int len) : DviMoveCommand (len) {};
190 virtual void execute (DviRuntime& runtime)
192 runtime.y (get_len());
196 class DviZCommand : public DviMoveCommand
199 DviZCommand (int len) : DviMoveCommand (len) {};
200 virtual void execute (DviRuntime& runtime)
202 runtime.z (get_len());
206 class DviFontNumCommand : public DviCommand
212 DviFontNumCommand (int num_arg) : num (num_arg) {}
213 virtual void execute (DviRuntime& runtime)
215 runtime.font_num (num);
219 class DviSpecialCommand : public DviCommand
223 DviSpecialCommand (string s) : spc (s) {};
224 virtual ~DviSpecialCommand () {};
225 virtual void execute (DviRuntime& runtime)
227 runtime.special (spc);
231 class DviWRepCommand : public DviCommand
234 DviWRepCommand () {};
235 virtual void execute (DviRuntime& runtime)
241 class DviXRepCommand : public DviCommand
244 DviXRepCommand () {};
245 virtual void execute (DviRuntime& runtime)
251 class DviYRepCommand : public DviCommand
254 DviYRepCommand () {};
255 virtual void execute (DviRuntime& runtime)
261 class DviZRepCommand : public DviCommand
264 DviZRepCommand () {};
265 virtual void execute (DviRuntime& runtime)
272 #endif // DL_DVI_PROGRAM_HH__