2008-07-23 00:30:14 +04:00
|
|
|
/*
|
|
|
|
* Transport.h
|
|
|
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TRANSPORT_H
|
|
|
|
#define __TRANSPORT_H
|
|
|
|
|
|
|
|
#include <image.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class BDataIO;
|
|
|
|
class PrinterData;
|
|
|
|
|
2010-10-25 15:44:09 +04:00
|
|
|
|
2008-07-23 00:30:14 +04:00
|
|
|
using namespace std;
|
2010-10-25 15:44:09 +04:00
|
|
|
|
2008-07-23 00:30:14 +04:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
typedef BDataIO *(*PFN_init_transport)(BMessage *);
|
|
|
|
typedef void (*PFN_exit_transport)(void);
|
|
|
|
}
|
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
|
2008-07-23 00:30:14 +04:00
|
|
|
class TransportException {
|
2010-12-08 23:07:22 +03:00
|
|
|
public:
|
|
|
|
TransportException(const string &what_arg);
|
|
|
|
const char* What() const;
|
|
|
|
|
2008-07-23 00:30:14 +04:00
|
|
|
private:
|
|
|
|
string fWhat;
|
|
|
|
};
|
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
|
2008-07-23 00:30:14 +04:00
|
|
|
class Transport {
|
|
|
|
public:
|
2010-12-08 23:07:22 +03:00
|
|
|
Transport(const PrinterData* printerData);
|
|
|
|
~Transport();
|
|
|
|
|
|
|
|
void Write(const void *buffer, size_t size)
|
|
|
|
throw (TransportException);
|
|
|
|
bool CheckAbort() const;
|
|
|
|
bool IsPrintToFileCanceled() const;
|
|
|
|
const string& LastError() const;
|
2008-07-23 00:30:14 +04:00
|
|
|
|
|
|
|
protected:
|
2010-12-08 23:07:22 +03:00
|
|
|
Transport(const Transport& transport);
|
|
|
|
Transport &operator=(const Transport& transport);
|
|
|
|
|
|
|
|
void SetLastError(const char* message);
|
2008-07-23 00:30:14 +04:00
|
|
|
|
|
|
|
private:
|
2010-12-08 23:07:22 +03:00
|
|
|
image_id fImage;
|
|
|
|
PFN_init_transport fInitTransport;
|
|
|
|
PFN_exit_transport fExitTransport;
|
|
|
|
BDataIO* fDataStream;
|
|
|
|
bool fAbort;
|
|
|
|
string fLastErrorString;
|
2008-07-23 00:30:14 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __TRANSPORT_H
|