Transport.h revision 1407e6d7
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
12class BDataIO;
13class PrinterData;
14
15
16using namespace std;
17
18
19extern "C" {
20	typedef BDataIO *(*PFN_init_transport)(BMessage *);
21	typedef void (*PFN_exit_transport)(void);
22}
23
24
25class TransportException {
26public:
27					TransportException(const string &what_arg);
28	const char*		What() const;
29
30private:
31	string fWhat;
32};
33
34
35class Transport {
36public:
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
48protected:
49					Transport(const Transport& transport);
50					Transport &operator=(const Transport& transport);
51
52	void			SetLastError(const char* message);
53
54private:
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