Removed unused files like PortMessage.cpp/h and Session.cpp/h.

Renamed LinkMsgReceiver.h and LinkMsgSender.h to LinkReceiver.h and LinkSender.h like
the classes they contain.
Split up PortLink.cpp/h into ServerLink.cpp/h and PortLink.cpp/h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14635 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-02 12:55:20 +00:00
parent 06be24a748
commit 1156138b2f
16 changed files with 315 additions and 1366 deletions
@@ -6,8 +6,8 @@
* DarkWyrm <bpmagic@columbus.rr.com>
* Pahtz <pahtz@yahoo.com.au>
*/
#ifndef _LINKMSGREADER_H
#define _LINKMSGREADER_H
#ifndef _LINK_RECEIVER_H
#define _LINK_RECEIVER_H
#include <OS.h>
@@ -42,11 +42,8 @@ class LinkReceiver {
port_id fReceivePort;
char *fRecvBuffer;
int32 fRecvPosition; //current read position
int32 fRecvStart; //start of current message
int32 fRecvBufferSize;
int32 fDataSize; //size of data in recv buffer
@@ -57,4 +54,4 @@ class LinkReceiver {
} // namespace BPrivate
#endif // _LINKMSGREADER_H
#endif // _LINK_RECEIVER_H
@@ -7,8 +7,8 @@
* Pahtz <pahtz@yahoo.com.au>
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef LINKMSGSENDER_H
#define LINKMSGSENDER_H
#ifndef _LINK_SENDER_H
#define _LINK_SENDER_H
#include <OS.h>
@@ -30,9 +30,6 @@ class LinkSender {
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT, bool needsReply = false);
// see BPrivate::BAppServerLink which inherits from BPortLink
//status_t FlushWithReply(int32 *code);
status_t Attach(const void *data, size_t size);
status_t AttachString(const char *string, int32 length = -1);
template <class Type> status_t Attach(const Type& data)
@@ -60,4 +57,4 @@ class LinkSender {
} // namespace BPrivate
#endif /* LINKMSGSENDER_H */
#endif /* _LINK_SENDER_H */
+5 -172
View File
@@ -1,79 +1,19 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Pahtz <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef _SERVER_LINK_H
#define _SERVER_LINK_H
#ifndef _PORT_LINK_H
#define _PORT_LINK_H
#include <OS.h>
#include <LinkMsgReader.h>
#include <LinkMsgSender.h>
#include <ServerLink.h>
/*
* Error checking rules: (for if you don't want to check every return code)
* - Calling EndMessage() is optional, implied by Flush() or StartMessage().
* - If you are sending just one message you only need to test Flush() == B_OK
* - If you are buffering multiple messages without calling Flush() you must
* check EndMessage() == B_OK, or the last Attach() for each message.
* Check Flush() at the end.
* - If you are reading, check the last Read() or ReadString() you perform.
*/
namespace BPrivate {
class ServerLink {
public:
ServerLink();
virtual ~ServerLink();
// send methods
void SetSenderPort(port_id port);
port_id SenderPort();
status_t StartMessage(int32 code, size_t minSize = 0);
void CancelMessage();
status_t EndMessage();
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT, bool needsReply = false);
status_t Attach(const void *data, ssize_t size);
status_t AttachString(const char *string, int32 length = -1);
status_t AttachRegion(const BRegion &region);
status_t AttachShape(BShape &shape);
template <class Type> status_t Attach(const Type& data);
// receive methods
void SetReceiverPort(port_id port);
port_id ReceiverPort();
status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT);
bool NeedsReply() const;
status_t Read(void *data, ssize_t size);
status_t ReadString(char *buffer, size_t bufferSize);
status_t ReadString(char **string);
status_t ReadRegion(BRegion *region);
status_t ReadShape(BShape *shape);
template <class Type> status_t Read(Type *data);
// convenience methods
status_t FlushWithReply(int32 &code);
LinkSender &Sender() { return *fSender; }
LinkReceiver &Receiver() { return *fReceiver; }
protected:
LinkSender *fSender;
LinkReceiver *fReceiver;
};
class PortLink : public ServerLink {
public:
PortLink(port_id sender = -1, port_id receiver = -1);
@@ -82,113 +22,6 @@ class PortLink : public ServerLink {
void SetTo(port_id sender, port_id receiver);
};
// sender inline functions
inline void
ServerLink::SetSenderPort(port_id port)
{
fSender->SetPort(port);
}
inline port_id
ServerLink::SenderPort()
{
return fSender->Port();
}
inline status_t
ServerLink::StartMessage(int32 code, size_t minSize)
{
return fSender->StartMessage(code, minSize);
}
inline status_t
ServerLink::EndMessage()
{
return fSender->EndMessage();
}
inline void
ServerLink::CancelMessage()
{
fSender->CancelMessage();
}
inline status_t
ServerLink::Flush(bigtime_t timeout, bool needsReply)
{
return fSender->Flush(timeout, needsReply);
}
inline status_t
ServerLink::Attach(const void *data, ssize_t size)
{
return fSender->Attach(data, size);
}
inline status_t
ServerLink::AttachString(const char *string, int32 length)
{
return fSender->AttachString(string, length);
}
template<class Type> status_t
ServerLink::Attach(const Type &data)
{
return Attach(&data, sizeof(Type));
}
// #pragma mark - receiver inline functions
inline void
ServerLink::SetReceiverPort(port_id port)
{
fReceiver->SetPort(port);
}
inline port_id
ServerLink::ReceiverPort()
{
return fReceiver->Port();
}
inline status_t
ServerLink::GetNextMessage(int32 &code, bigtime_t timeout)
{
return fReceiver->GetNextMessage(code, timeout);
}
inline bool
ServerLink::NeedsReply() const
{
return fReceiver->NeedsReply();
}
inline status_t
ServerLink::Read(void *data, ssize_t size)
{
return fReceiver->Read(data, size);
}
inline status_t
ServerLink::ReadString(char *buffer, size_t bufferSize)
{
return fReceiver->ReadString(buffer, bufferSize);
}
inline status_t
ServerLink::ReadString(char **string)
{
return fReceiver->ReadString(string);
}
template <class Type> status_t
ServerLink::Read(Type *data)
{
return Read(data, sizeof(Type));
}
} // namespace BPrivate
#endif /* _SERVER_LINK_H */
#endif /* _PORT_LINK_H */
-82
View File
@@ -1,82 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: PortMessage.h
// Author: DarkWyrm <[email protected]>
// Description: Package class for port messaging-based data
//
//------------------------------------------------------------------------------
#ifndef PORTMESSAGE_H_
#define PORTMESSAGE_H_
#include <OS.h>
#include <ServerProtocol.h>
class PortMessage
{
public:
PortMessage(const int32 &code, const void *buffer, const ssize_t &buffersize,
const bool &copy);
PortMessage(void);
~PortMessage(void);
status_t ReadFromPort(const port_id &port, const bigtime_t &timeout=B_INFINITE_TIMEOUT);
status_t WriteToPort(const port_id &port);
void SetCode(const int32 &code);
void SetProtocol(int32 protocol) { _protocol=protocol; }
void SetBuffer(const void *buffer, const ssize_t &size, const bool &copy=false);
int32 Code(void) { return _code; }
void *Buffer(void) { return _buffer; }
ssize_t BufferSize(void) { return _buffersize; }
int32 Protocol(void) const { return _protocol; }
status_t Read(void *data, ssize_t size);
status_t ReadString(char **string);
template <class Type> status_t Read(Type *data)
{
int32 size = sizeof(Type);
if(!data)
return B_BAD_VALUE;
if( !_buffer ||
(_buffersize < size) ||
(_index+size > _buffer+_buffersize) )
return B_NO_MEMORY;
*data=*((Type*)_index);
_index+=size;
return B_OK;
}
void Rewind(void);
private:
int32 _code;
uint8 *_buffer;
ssize_t _buffersize;
uint8 *_index;
int32 _protocol;
};
#endif
+186
View File
@@ -0,0 +1,186 @@
/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Pahtz <[email protected]>
* Axel Dörfler, [email protected]
*/
#ifndef _SERVER_LINK_H
#define _SERVER_LINK_H
#include <OS.h>
#include <LinkReceiver.h>
#include <LinkSender.h>
/*
* Error checking rules: (for if you don't want to check every return code)
* - Calling EndMessage() is optional, implied by Flush() or StartMessage().
* - If you are sending just one message you only need to test Flush() == B_OK
* - If you are buffering multiple messages without calling Flush() you must
* check EndMessage() == B_OK, or the last Attach() for each message.
* Check Flush() at the end.
* - If you are reading, check the last Read() or ReadString() you perform.
*/
namespace BPrivate {
class ServerLink {
public:
ServerLink();
virtual ~ServerLink();
// send methods
void SetSenderPort(port_id port);
port_id SenderPort();
status_t StartMessage(int32 code, size_t minSize = 0);
void CancelMessage();
status_t EndMessage();
status_t Flush(bigtime_t timeout = B_INFINITE_TIMEOUT, bool needsReply = false);
status_t Attach(const void *data, ssize_t size);
status_t AttachString(const char *string, int32 length = -1);
status_t AttachRegion(const BRegion &region);
status_t AttachShape(BShape &shape);
template <class Type> status_t Attach(const Type& data);
// receive methods
void SetReceiverPort(port_id port);
port_id ReceiverPort();
status_t GetNextMessage(int32 &code, bigtime_t timeout = B_INFINITE_TIMEOUT);
bool NeedsReply() const;
status_t Read(void *data, ssize_t size);
status_t ReadString(char *buffer, size_t bufferSize);
status_t ReadString(char **string);
status_t ReadRegion(BRegion *region);
status_t ReadShape(BShape *shape);
template <class Type> status_t Read(Type *data);
// convenience methods
status_t FlushWithReply(int32 &code);
LinkSender &Sender() { return *fSender; }
LinkReceiver &Receiver() { return *fReceiver; }
protected:
LinkSender *fSender;
LinkReceiver *fReceiver;
};
// sender inline functions
inline void
ServerLink::SetSenderPort(port_id port)
{
fSender->SetPort(port);
}
inline port_id
ServerLink::SenderPort()
{
return fSender->Port();
}
inline status_t
ServerLink::StartMessage(int32 code, size_t minSize)
{
return fSender->StartMessage(code, minSize);
}
inline status_t
ServerLink::EndMessage()
{
return fSender->EndMessage();
}
inline void
ServerLink::CancelMessage()
{
fSender->CancelMessage();
}
inline status_t
ServerLink::Flush(bigtime_t timeout, bool needsReply)
{
return fSender->Flush(timeout, needsReply);
}
inline status_t
ServerLink::Attach(const void *data, ssize_t size)
{
return fSender->Attach(data, size);
}
inline status_t
ServerLink::AttachString(const char *string, int32 length)
{
return fSender->AttachString(string, length);
}
template<class Type> status_t
ServerLink::Attach(const Type &data)
{
return Attach(&data, sizeof(Type));
}
// #pragma mark - receiver inline functions
inline void
ServerLink::SetReceiverPort(port_id port)
{
fReceiver->SetPort(port);
}
inline port_id
ServerLink::ReceiverPort()
{
return fReceiver->Port();
}
inline status_t
ServerLink::GetNextMessage(int32 &code, bigtime_t timeout)
{
return fReceiver->GetNextMessage(code, timeout);
}
inline bool
ServerLink::NeedsReply() const
{
return fReceiver->NeedsReply();
}
inline status_t
ServerLink::Read(void *data, ssize_t size)
{
return fReceiver->Read(data, size);
}
inline status_t
ServerLink::ReadString(char *buffer, size_t bufferSize)
{
return fReceiver->ReadString(buffer, bufferSize);
}
inline status_t
ServerLink::ReadString(char **string)
{
return fReceiver->ReadString(string);
}
template <class Type> status_t
ServerLink::Read(Type *data)
{
return Read(data, sizeof(Type));
}
} // namespace BPrivate
#endif /* _SERVER_LINK_H */
-112
View File
@@ -1,112 +0,0 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Session.h
// Author: Adi Oanca <[email protected]>
// Description: Stream-based messaging class
//
//------------------------------------------------------------------------------
#ifndef _SESSION_H
#define _SESSION_H
#include <BeBuild.h>
#include <OS.h>
#include <Region.h>
#include <Rect.h>
#include <Point.h>
#include <ServerProtocol.h>
#define SESSION_BUFFER_SIZE 1024
class BSession
{
public:
BSession(port_id receivePort, port_id sendPort);
BSession(int32, char *);
BSession( const BSession &ses );
virtual ~BSession(void);
void SetSendPort( port_id port );
void SetRecvPort( port_id port );
port_id GetSendPort(void) const { return fSendPort; }
port_id GetRecvPort(void) const { return fReceivePort; }
char *ReadString();
void ReadBool( bool *b );
void ReadInt8( int8 *i );
void ReadUInt8( uint8 *i );
void ReadInt16( int16 *i );
void ReadUInt16( uint16 *i );
void ReadInt32( int32 *i );
void ReadUInt32( uint32 *i );
void ReadInt64( int64 *i );
void ReadUInt64( uint64 *i );
void ReadFloat( float *f );
void ReadFloatFromInt32( float *f );
void ReadDouble( double *d );
void ReadDoubleFromInt64( double *d );
void ReadPoint( BPoint *point );
void ReadPointFromInts( BPoint *point );
void ReadRectCR( clipping_rect *rect );
void ReadRect( BRect *rect );
void ReadRectFromInts( BRect *rect );
void ReadData( void* data, int32 size );
void WriteString( const char* string );
void WriteBool( const bool& b );
void WriteInt8( const int8& i );
void WriteUInt8( const uint8& i );
void WriteInt16( const int16& i );
void WriteUInt16( const uint16& i );
void WriteInt32( const int32& i );
void WriteUInt32( const uint32& i );
void WriteInt64( const int64& i );
void WriteUInt64( const uint64& i );
void WriteFloat(const float& f );
void WriteFloatAsInt32( const float& f );
void WriteDouble( const double& d );
void WriteDoubleAsInt64( const double& d );
void WritePoint(const BPoint& point);
void WritePointAsInt32s(const BPoint& point);
void WriteRect(const clipping_rect& rect);
void WriteRect(const BRect& rect);
void WriteRectAsInt32s(const BRect& rect);
void WriteData(const void* data, int32 size);
void Sync();
// Deprecated. Do not use.
void CopyToSendBuffer(void* buffer, int32 count);
private:
port_id fSendPort;
port_id fReceivePort;
char *fSendBuffer;
int32 fSendPosition;
int32 fRecvCode;
char *fReceiveBuffer;
int32 fReceiveSize;
int32 fReceivePosition;
};
#endif