Files
haiku-beta6/src/kits/app/PortLink.cpp
T

109 lines
2.7 KiB
C++
Raw Normal View History

//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, Haiku, Inc.
//
// 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: PortLink.cpp
// Author: Pahtz <[email protected]>
// Description: Class for low-overhead port-based messaging
//
//------------------------------------------------------------------------------
#include <stdlib.h>
#include <string.h>
#include <new>
2003-10-03 22:23:17 +00:00
#include <ServerProtocol.h>
#include <PortLink.h>
BPortLink::BPortLink(port_id send, port_id receive) :
fReader(new LinkMsgReader(receive)), fSender(new LinkMsgSender(send))
{
}
BPortLink::~BPortLink()
{
delete fReader;
delete fSender;
}
status_t BPortLink::StartMessage(int32 code)
{
return fSender->StartMessage(code);
}
2003-10-03 22:23:17 +00:00
status_t BPortLink::EndMessage()
2002-07-09 12:24:59 +00:00
{
return fSender->EndMessage();
2002-07-09 12:24:59 +00:00
}
2003-10-03 22:23:17 +00:00
void BPortLink::CancelMessage()
2003-10-03 23:28:46 +00:00
{
fSender->CancelMessage();
2003-10-03 23:28:46 +00:00
}
status_t BPortLink::Attach(const void *data, ssize_t size)
2003-10-03 22:23:17 +00:00
{
return fSender->Attach(data,size);
2002-07-09 12:24:59 +00:00
}
2003-10-03 22:23:17 +00:00
void BPortLink::SetSendPort( port_id port )
2003-10-03 22:23:17 +00:00
{
fSender->SetPort(port);
2002-07-09 12:24:59 +00:00
}
2003-10-03 22:23:17 +00:00
port_id BPortLink::GetSendPort()
2003-10-03 22:23:17 +00:00
{
return fSender->GetPort();
2002-07-09 12:24:59 +00:00
}
2003-10-03 22:23:17 +00:00
void BPortLink::SetReplyPort( port_id port )
2003-10-03 22:23:17 +00:00
{
fReader->SetPort(port);
}
port_id BPortLink::GetReplyPort()
{
return fReader->GetPort();
}
status_t BPortLink::Flush(bigtime_t timeout)
{
return fSender->Flush(timeout);
2002-07-09 12:24:59 +00:00
}
status_t BPortLink::GetNextReply(int32 *code, bigtime_t timeout)
2003-06-23 13:18:39 +00:00
{
return fReader->GetNextMessage(code,timeout);
}
status_t BPortLink::Read(void *data, ssize_t size)
{
return fReader->Read(data,size);
}
status_t BPortLink::ReadString(char **string)
{
return fReader->ReadString(string);
}
2003-10-03 22:23:17 +00:00
status_t BPortLink::AttachString(const char *string)
{
return fSender->AttachString(string);
}