1 // This file is part of the brlaser printer driver.
2 //
3 // Copyright 2013 Peter De Wachter
4 //
5 // brlaser is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // brlaser is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with brlaser.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef JOB_H
19 #define JOB_H
20 
21 #include <stdint.h>
22 #include <stdio.h>
23 #include <string>
24 #include <vector>
25 
26 struct page_params {
27   int num_copies;
28   int resolution;
29   bool duplex;
30   bool economode;
31   std::string sourcetray;
32   std::string mediatype;
33   std::string papersize;
34 
35   bool operator==(const page_params &o) const {
36     return num_copies == o.num_copies
37       && resolution == o.resolution
38       && duplex == o.duplex
39       && economode == o.economode
40       && sourcetray == o.sourcetray
41       && mediatype == o.mediatype
42       && papersize == o.papersize;
43   }
44 };
45 
46 class job {
47  public:
48   typedef bool (*nextline_fn)(std::vector<uint8_t> &buf);
49 
50   explicit job(FILE *out, const std::string &job_name);
51   ~job();
52 
53   void encode_page(const page_params &params,
54                    int lines,
55                    int linesize,
56                    nextline_fn nextline);
57 
58  private:
59   void begin_job();
60   void end_job();
61   void write_page_header();
62 
63   FILE *out_;
64   std::string job_name_;
65   page_params page_params_;
66 };
67 
68 #endif  // JOB_H
69