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 bool CheckAbort() const; 43 bool IsPrintToFileCanceled() const; 44 const string& LastError() const; 45 46 protected: 47 Transport(const Transport& transport); 48 Transport &operator=(const Transport& transport); 49 50 void SetLastError(const char* message); 51 52 private: 53 image_id fImage; 54 PFN_init_transport fInitTransport; 55 PFN_exit_transport fExitTransport; 56 BDataIO* fDataStream; 57 bool fAbort; 58 string fLastErrorString; 59 }; 60 61 #endif // __TRANSPORT_H 62