xref: /haiku/headers/libs/print/libprint/Transport.h (revision bb83316a5811a550c4f850d07fa8e328e7ac0a94)
1 /*
2  * Transport.h
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  */
5 
6 #ifndef __TRANSPORT_H
7 #define __TRANSPORT_H
8 
9 #include <image.h>
10 #include <string>
11 
12 class BDataIO;
13 class PrinterData;
14 
15 
16 using namespace std;
17 
18 
19 extern "C" {
20 	typedef BDataIO *(*PFN_init_transport)(BMessage *);
21 	typedef void (*PFN_exit_transport)(void);
22 }
23 
24 
25 class TransportException {
26 public:
27 					TransportException(const string &what_arg);
28 	const char*		What() const;
29 
30 private:
31 	string fWhat;
32 };
33 
34 
35 class Transport {
36 public:
37 					Transport(const PrinterData* printerData);
38 					~Transport();
39 
40 	void			Write(const void *buffer, size_t size)
41 						/* throw (TransportException) */;
42 	void			Read(void *buffer, size_t size)
43 						/* throw (TransportException) */;
44 	bool			CheckAbort() const;
45 	bool			IsPrintToFileCanceled() const;
46 	const string&	LastError() const;
47 
48 protected:
49 					Transport(const Transport& transport);
50 					Transport &operator=(const Transport& transport);
51 
52 	void			SetLastError(const char* message);
53 
54 private:
55 	image_id			fImage;
56 	PFN_init_transport	fInitTransport;
57 	PFN_exit_transport	fExitTransport;
58 	BDataIO*			fDataStream;
59 	bool				fAbort;
60 	string				fLastErrorString;
61 };
62 
63 #endif	// __TRANSPORT_H
64