winss
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
winss::PipeInstance Class Reference

The pipe instance which is shared between client and server. More...

#include <pipe_instance.hpp>

Inheritance diagram for winss::PipeInstance:
Inheritance graph
[legend]

Public Member Functions

 PipeInstance ()
 Creates a new pipe instance. More...
 
 PipeInstance (const PipeInstance &)=delete
 No copy. More...
 
 PipeInstance (PipeInstance &&instance)
 Create a new pipe instance from another. More...
 
virtual bool IsPendingIO () const
 Gets if there is pending IO operations. More...
 
virtual bool IsConnected () const
 Gets if the instance is connected. More...
 
virtual bool IsClosing () const
 Gets if the instance is closing. More...
 
virtual winss::HandleWrapper GetHandle () const
 Gets the event handle for the instance. More...
 
virtual bool SetConnected ()
 Sets the instance to connected state. More...
 
virtual OverlappedResult GetOverlappedResult ()
 Gets the last overlapped result of the instance. More...
 
virtual bool CreateNamedPipe (const winss::PipeName &pipe_name)
 Creates the Windows named pipe server. More...
 
virtual bool CreateFile (const winss::PipeName &pipe_name)
 Creates a Windows named pipe client. More...
 
virtual void Closing ()
 Marks the pipe instance as closing and triggers the event. More...
 
virtual void DisconnectNamedPipe ()
 DIsconnect the client from the pipe server. More...
 
virtual bool Close ()
 Close the pipe connection. More...
 
PipeInstanceoperator= (const PipeInstance &)=delete
 No copy. More...
 
PipeInstanceoperator= (PipeInstance &&instance)
 Move a pipe instance to this instance. More...
 
virtual ~PipeInstance ()
 Default destructor. More...
 

Static Public Attributes

static const DWORD kBufferSize = 4096
 The pipe buffer. More...
 
static const DWORD kTimeout = 5000
 The pipe timeout. More...
 

Protected Member Functions

bool CheckError ()
 Checks if error is a real error or pending IO operation. More...
 

Protected Attributes

OVERLAPPED overlapped
 The overlapped structure. More...
 
HANDLE handle = nullptr
 The event handle. More...
 
bool connected = false
 Flags if the instance is connected. More...
 
bool pending_io = false
 Flagged if IO event is pending. More...
 
bool close = false
 Flagged if instance is closing. More...
 
std::vector< char > buffer
 The instance byte buffer. More...
 
DWORD bytes = 0
 The bytes read or written. More...
 

Detailed Description

The pipe instance which is shared between client and server.

Constructor & Destructor Documentation

winss::PipeInstance::PipeInstance ( )

Creates a new pipe instance.

References buffer, kBufferSize, overlapped, and WINDOWS.

winss::PipeInstance::PipeInstance ( const PipeInstance )
delete

No copy.

winss::PipeInstance::PipeInstance ( winss::PipeInstance &&  instance)

Create a new pipe instance from another.

Parameters
instanceThe pipe instance to move from.

References buffer, bytes, close, connected, handle, kBufferSize, overlapped, and pending_io.

winss::PipeInstance::~PipeInstance ( )
virtual

Default destructor.

References Close().

Member Function Documentation

bool winss::PipeInstance::CheckError ( )
protected

Checks if error is a real error or pending IO operation.

Returns
False if the IO event is not pending otherwise true.

References close, handle, overlapped, pending_io, and WINDOWS.

Referenced by winss::OutboundPipeInstance::Read(), winss::InboundPipeInstance::Read(), and winss::OutboundPipeInstance::Write().

bool winss::PipeInstance::Close ( )
virtual

Close the pipe connection.

Returns
True if the close changed the state otherwise false.

References buffer, bytes, close, connected, handle, overlapped, pending_io, and WINDOWS.

Referenced by ~PipeInstance().

void winss::PipeInstance::Closing ( )
virtual

Marks the pipe instance as closing and triggers the event.

The client should close the pipe in the event handler.

References close, handle, overlapped, and WINDOWS.

bool winss::PipeInstance::CreateFile ( const winss::PipeName pipe_name)
virtual

Creates a Windows named pipe client.

Parameters
pipe_nameThe name of the pipe.
Returns
True if pipe client was created otherwise false.

References winss::PipeName::Get(), handle, and WINDOWS.

bool winss::PipeInstance::CreateNamedPipe ( const winss::PipeName pipe_name)
virtual

Creates the Windows named pipe server.

Parameters
pipe_nameThe name of the pipe.
Returns
True if the pipe server was created otherwise false.

References winss::PipeName::Get(), handle, kBufferSize, kTimeout, overlapped, pending_io, and WINDOWS.

void winss::PipeInstance::DisconnectNamedPipe ( )
virtual

DIsconnect the client from the pipe server.

References connected, handle, and WINDOWS.

winss::HandleWrapper winss::PipeInstance::GetHandle ( ) const
virtual

Gets the event handle for the instance.

Returns
The handle wrapper of the event.
See also
HandleWrapper

References overlapped.

winss::OverlappedResult winss::PipeInstance::GetOverlappedResult ( )
virtual

Gets the last overlapped result of the instance.

Returns
An overlapped result for the last IO operation.

References bytes, close, winss::CONTINUE, handle, overlapped, pending_io, winss::REMOVE, winss::SKIP, and WINDOWS.

bool winss::PipeInstance::IsClosing ( ) const
virtual

Gets if the instance is closing.

Returns
True if the instance is closing otherwise false.

References close.

bool winss::PipeInstance::IsConnected ( ) const
virtual

Gets if the instance is connected.

Returns
True if connected otherwise false.

References connected.

bool winss::PipeInstance::IsPendingIO ( ) const
virtual

Gets if there is pending IO operations.

Returns
True if pending IO otherwise false.

References pending_io.

PipeInstance& winss::PipeInstance::operator= ( const PipeInstance )
delete
winss::PipeInstance & winss::PipeInstance::operator= ( winss::PipeInstance &&  instance)

Move a pipe instance to this instance.

Parameters
instanceThe pipe instance to move from.
Returns
This pipe instance.

References buffer, bytes, close, connected, handle, overlapped, and pending_io.

bool winss::PipeInstance::SetConnected ( )
virtual

Sets the instance to connected state.

Returns
True if the connected state was updated otherwise false.

References connected, and handle.

Member Data Documentation

std::vector<char> winss::PipeInstance::buffer
protected
DWORD winss::PipeInstance::bytes = 0
protected
bool winss::PipeInstance::close = false
protected
bool winss::PipeInstance::connected = false
protected
HANDLE winss::PipeInstance::handle = nullptr
protected
const DWORD winss::PipeInstance::kBufferSize = 4096
static
const DWORD winss::PipeInstance::kTimeout = 5000
static

The pipe timeout.

Referenced by CreateNamedPipe().

OVERLAPPED winss::PipeInstance::overlapped
protected
bool winss::PipeInstance::pending_io = false
protected

The documentation for this class was generated from the following files: