#include <icy/packetfactory.h>Priority-ordered factory that creates typed packets from raw buffers using registered strategies.
| Return | Name | Description |
|---|---|---|
PacketFactory | Defaulted constructor. | |
void | registerPacketType inline | Registers a [PacketCreationStrategy](icy-PacketCreationStrategy.html#packetcreationstrategy)<PacketT> at the given priority. Any previously registered strategy for PacketT is replaced. |
void | unregisterPacketType inline | Removes the [PacketCreationStrategy](icy-PacketCreationStrategy.html#packetcreationstrategy)<PacketT> from the factory, if present. |
void | registerStrategy inline | Registers an arbitrary [IPacketCreationStrategy](icy-IPacketCreationStrategy.html#ipacketcreationstrategy) subclass at the given priority. Any previously registered instance of the same type is replaced. |
void | unregisterStrategy inline | Removes the StrategyT instance from the factory, if present. |
PacketCreationStrategyList & | types inline | #### Returns |
const PacketCreationStrategyList & | types const inline | #### Returns |
bool | onPacketCreated virtual inline | Called after a packet is successfully created by a strategy. Override to apply filtering; return false to reject the packet (it will be deleted). |
IPacket * | createPacket virtual inline | Iterates registered strategies in priority order and returns the first successfully created packet. |
PacketFactory() = defaultDefaulted constructor.
inline
template<class PacketT> inline void registerPacketType(int priority)Registers a [PacketCreationStrategy](icy-PacketCreationStrategy.html#packetcreationstrategy)<PacketT> at the given priority. Any previously registered strategy for PacketT is replaced.
PacketT Packet type to register; must default-constructible with a read() method.priority Dispatch priority (0–100; higher runs first).inline
template<class PacketT> inline void unregisterPacketType()Removes the [PacketCreationStrategy](icy-PacketCreationStrategy.html#packetcreationstrategy)<PacketT> from the factory, if present.
PacketT Packet type whose strategy should be removed.inline
template<class StrategyT> inline void registerStrategy(int priority)Registers an arbitrary [IPacketCreationStrategy](icy-IPacketCreationStrategy.html#ipacketcreationstrategy) subclass at the given priority. Any previously registered instance of the same type is replaced.
StrategyT Strategy type to instantiate; must accept a priority int in its constructor.priority Dispatch priority (0–100; higher runs first).inline
template<class StrategyT> inline void unregisterStrategy()Removes the StrategyT instance from the factory, if present.
StrategyT Strategy type to remove.inline
inline PacketCreationStrategyList & types()Mutable reference to the ordered list of registered strategies.
const inline
inline const PacketCreationStrategyList & types() constConst reference to the ordered list of registered strategies.
virtual inline
virtual inline bool onPacketCreated(IPacket * packet)Called after a packet is successfully created by a strategy. Override to apply filtering; return false to reject the packet (it will be deleted).
packet Newly created packet.True to accept the packet, false to discard it and try the next strategy.
virtual inline
virtual inline IPacket * createPacket(const ConstBuffer & buffer, size_t & nread)Iterates registered strategies in priority order and returns the first successfully created packet.
buffer Raw input data.
nread Set to the number of bytes consumed on success.
Newly allocated packet, or nullptr if no strategy matched.
std::logic_error if no packet types have been registered.| Return | Name | Description |
|---|---|---|
PacketCreationStrategyList | _types |
PacketCreationStrategyList _types| Return | Name | Description |
|---|---|---|
void | sortTypes inline |
inline
inline void sortTypes()