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 #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE)) 16 using namespace std; 17 #else 18 #define std 19 #endif 20 21 extern "C" { 22 typedef BDataIO *(*PFN_init_transport)(BMessage *); 23 typedef void (*PFN_exit_transport)(void); 24 } 25 26 class TransportException { 27 private: 28 string fWhat; 29 public: 30 TransportException(const string &what_arg) : fWhat(what_arg) {} 31 const char *what() const { return fWhat.c_str(); } 32 }; 33 34 class Transport { 35 public: 36 Transport(const PrinterData *printer_data); 37 ~Transport(); 38 void write(const void *buffer, size_t size) throw(TransportException); 39 bool check_abort() const; 40 bool is_print_to_file_canceled() const; 41 const string &last_error() const; 42 43 protected: 44 void set_last_error(const char *e); 45 Transport(const Transport &); 46 Transport &operator = (const Transport &); 47 48 private: 49 image_id fImage; 50 PFN_init_transport fInitTransport; 51 PFN_exit_transport fExitTransport; 52 BDataIO *fDataStream; 53 bool fAbort; 54 string fLastErrorString; 55 }; 56 57 #endif // __TRANSPORT_H 58