#include <icy/packet.h>Subclassed by:
FlagPacket,RawPacket,Message,Message
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.
| Return | Name | Description |
|---|---|---|
std::any | opaque | Optional 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 > | info | Optional extra information about the packet. |
Bitwise | flags | Provides basic information about the packet. |
std::any opaqueOptional 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.
Bitwise flagsProvides basic information about the packet.
| Return | Name | Description |
|---|---|---|
IPacket inline | #### Parameters | |
IPacket inline | Copy constructor; clones the info object if present. | |
IPacket & | operator= inline | Copy assignment; clones the info object if present. |
std::unique_ptr< IPacket > | clone const | Returns a heap-allocated deep copy of this packet. |
ssize_t | read | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
void | write const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
size_t | size virtual const inline | The size of the packet in bytes. |
bool | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
char * | data virtual const inline | The packet data pointer for buffered packets. |
const void * | constData virtual const inline | The const packet data pointer for buffered packets. |
const char * | className const | Returns the class name of this packet type for logging and diagnostics. |
void | print virtual const inline | Prints a human-readable representation to the given stream. |
inline
inline IPacket(std::unique_ptr< IPacketInfo > info, unsigned flags)info Optional packet info; ownership transferred.
flags Initial bitwise flags.
inline
inline IPacket(const IPacket & r)Copy constructor; clones the info object if present.
r Source packet.inline
inline IPacket & operator=(const IPacket & r)Copy assignment; clones the info object if present.
r Source packet.Reference to this packet.
const
std::unique_ptr< IPacket > clone() constReturns a heap-allocated deep copy of this packet.
Owning pointer to the cloned packet.
ssize_t read(const ConstBuffer &)Read/parse to the packet from the given input buffer. The number of bytes read is returned.
const
void write(Buffer &) constCopy/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...
virtual const inline
virtual inline size_t size() constThe 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().
virtual const inline
virtual inline bool hasData() constReturns true if the packet has a non-null data pointer.
virtual const inline
virtual inline char * data() constThe packet data pointer for buffered packets.
virtual const inline
virtual inline const void * constData() constThe const packet data pointer for buffered packets.
const
const char * className() constReturns the class name of this packet type for logging and diagnostics.
virtual const inline
virtual inline void print(std::ostream & os) constPrints a human-readable representation to the given stream.
os Output stream.