From 445114208c455732fba8393b634aa2653702ff46 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Sun, 31 Aug 2003 17:20:07 +0000 Subject: [PATCH] Header file for the new communication class: BSession - it will replace PortLink git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4422 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/Session.h | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 headers/private/app/Session.h diff --git a/headers/private/app/Session.h b/headers/private/app/Session.h new file mode 100644 index 0000000000..3e42065e33 --- /dev/null +++ b/headers/private/app/Session.h @@ -0,0 +1,79 @@ +#ifndef _SESSION_H +#define _SESSION_H + +#include +#include +#include +#include +#include + +#define AS_SESSION_MSG 'assm' + +class BSession { + +public: + BSession(port_id receivePort, port_id sendPort, bool isPortLink = false); + BSession(int32, char *); + BSession( const BSession &ses ); +virtual ~BSession(); + void SetSendPort( port_id port ); + void SetRecvPort( port_id port ); + + char* ReadString(); + status_t ReadBool( bool *b ); + status_t ReadInt8( int8 *i ); + status_t ReadInt16( int16 *i ); + status_t ReadInt32( int32 *i ); + status_t ReadInt64( int64 *i ); + status_t ReadFloat( float *f ); + status_t ReadFloatFromInt( float *f ); + status_t ReadDouble( double *d ); + status_t ReadDoubleFromInt( double *d ); + status_t ReadPoint( BPoint *point ); + status_t ReadPointFromInts( BPoint *point ); + status_t ReadRectCR( clipping_rect *rect ); + status_t ReadRect( BRect *rect ); + status_t ReadRectFromInts( BRect *rect ); + status_t ReadData( void* data, int32 size ); + + status_t WriteString( const char* string ); + status_t WriteBool( const bool& b ); + status_t WriteInt8( const int8& i ); + status_t WriteUInt8( const uint8& i ); + status_t WriteInt16( const int16& i ); + status_t WriteUInt16( const uint16& i ); + status_t WriteInt32( const int32& i ); + status_t WriteUInt32( const uint32& i ); + status_t WriteInt64( const int64& i ); + status_t WriteUInt64( const uint64& i ); + status_t WriteFloat(const float& f ); + status_t WriteFloatAsInt( const float& f ); + status_t WriteDouble( const double& d ); + status_t WriteDoubleAsInt( const double& d ); + status_t WritePoint(const BPoint& point); + status_t WritePointAsInt(const BPoint& point); + status_t WriteRect(const clipping_rect& rect); + status_t WriteRect(const BRect& rect); + status_t WriteRectAsInt(const BRect& rect); + status_t WriteData(const void* data, int32 size); + + status_t Sync(); + void Close(); +private: +friend class PortLink; + + port_id fSendPort; + port_id fReceivePort; + + char *fSendBuffer; + int32 fSendPosition; + int32 fSendCode; + + char *fReceiveBuffer; + int32 fReceiveSize; + int32 fReceivePosition; +}; + +//extern _IMPEXP_BE _BSession_ *main_session; + +#endif