Base module

IPacket

The basic packet type which is passed around the icey system.

#include <icy/packet.h>

class IPacket

Defined in src/base/include/icy/packet.h:47

The basic packet type which is passed around the icey system. IPacket can be extended for each protocol to enable polymorphic processing and callbacks using PacketStream and friends.

Friends

NameDescription
operator<< inlineStream insertion operator; delegates to print().

operator<<

inline

friend inline std::ostream & operator<<(std::ostream & stream, const IPacket & p)

Defined in src/base/include/icy/packet.h:137

Stream insertion operator; delegates to print().

Returns

Reference to the stream.

Parameters

ParameterTypeDescription
streamstd::ostream &Output stream.
pconst IPacket &Packet to print.

Public Attributes

ReturnNameDescription
std::anyopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
std::unique_ptr< IPacketInfo >infoOptional extra information about the packet.
BitwiseflagsProvides basic information about the packet.

opaque

std::any opaque

Defined in src/base/include/icy/packet.h:86

Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.


info

std::unique_ptr< IPacketInfo > info

Type: std::unique_ptr< IPacketInfo >

Defined in src/base/include/icy/packet.h:89

Optional extra information about the packet.


flags

Bitwise flags

Type: Bitwise

Defined in src/base/include/icy/packet.h:92

Provides basic information about the packet.

Public Methods

ReturnNameDescription
IPacket inline
IPacket inlineCopy constructor; clones the info object if present.
IPacket &operator= inlineCopy assignment; clones the info object if present.
std::unique_ptr< IPacket >clone virtual constReturns a heap-allocated deep copy of this packet.
~IPacket virtualDefaulted destructor.
ssize_tread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
voidwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
size_tsize virtual const inlineThe size of the packet in bytes.
boolhasData virtual const inlineReturns true if the packet has a non-null data pointer.
char *data virtual const inlineThe packet data pointer for buffered packets.
const void *constData virtual const inlineThe const packet data pointer for buffered packets.
const char *className virtual constReturns the class name of this packet type for logging and diagnostics.
voidprint virtual const inlinePrints a human-readable representation to the given stream.

IPacket

inline

inline IPacket(std::unique_ptr< IPacketInfo > info = nullptr, unsigned flags = 0)

Defined in src/base/include/icy/packet.h:52

Parameters

ParameterTypeDescription
infostd::unique_ptr< IPacketInfo >Optional packet info; ownership transferred.
flagsunsignedInitial bitwise flags.

IPacket

inline

inline IPacket(const IPacket & r)

Defined in src/base/include/icy/packet.h:60

Copy constructor; clones the info object if present.

Parameters

ParameterTypeDescription
rconst IPacket &Source packet.

operator=

inline

inline IPacket & operator=(const IPacket & r)

Defined in src/base/include/icy/packet.h:70

Copy assignment; clones the info object if present.

Returns

Reference to this packet.

Parameters

ParameterTypeDescription
rconst IPacket &Source packet.

clone

virtual const

virtual std::unique_ptr< IPacket > clone() const

Defined in src/base/include/icy/packet.h:80

Returns a heap-allocated deep copy of this packet.

Returns

Owning pointer to the cloned packet.

Reimplemented by


~IPacket

virtual

virtual ~IPacket() = default

Defined in src/base/include/icy/packet.h:82

Defaulted destructor.


read

virtual

virtual ssize_t read(const ConstBuffer &)

Defined in src/base/include/icy/packet.h:96

Read/parse to the packet from the given input buffer. The number of bytes read is returned.

Reimplemented by


write

virtual const

virtual void write(Buffer &) const

Defined in src/base/include/icy/packet.h:105

Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.

Todo: It may be preferable to use our pod types here instead of buffer input, but the current codebase requires that the buffer be dynamically resizable for some protocols...

Reimplemented by


size

virtual const inline

virtual inline size_t size() const

Defined in src/base/include/icy/packet.h:112

The size of the packet in bytes.

This is the number of bytes that will be written on a call to write(), but may not be the number of bytes that will be consumed by read().

Reimplemented by


hasData

virtual const inline

virtual inline bool hasData() const

Defined in src/base/include/icy/packet.h:115

Returns true if the packet has a non-null data pointer.

Reimplemented by


data

virtual const inline

virtual inline char * data() const

Defined in src/base/include/icy/packet.h:118

The packet data pointer for buffered packets.

Reimplemented by


constData

virtual const inline

virtual inline const void * constData() const

Defined in src/base/include/icy/packet.h:121

The const packet data pointer for buffered packets.


className

virtual const

virtual const char * className() const

Defined in src/base/include/icy/packet.h:124

Returns the class name of this packet type for logging and diagnostics.

Reimplemented by


print

virtual const inline

virtual inline void print(std::ostream & os) const

Defined in src/base/include/icy/packet.h:128

Prints a human-readable representation to the given stream.

Reimplemented by

Parameters

ParameterTypeDescription
osstd::ostream &Output stream.