Kea  2.1.7-git
isc::dhcp::PacketQueueMgr< PacketQueueTypePtr > Class Template Reference

Packet Queue Managers (PQM). More...

#include <packet_queue_mgr.h>

Public Types

typedef std::function< PacketQueueTypePtr(data::ConstElementPtr)> Factory
 Defines the type of the packet queue factory function. More...
 

Public Member Functions

 PacketQueueMgr ()
 Constructor. More...
 
void createPacketQueue (data::ConstElementPtr parameters)
 Create an instance of a packet queue. More...
 
void destroyPacketQueue ()
 Destroys the current packet queue. More...
 
PacketQueueTypePtr getPacketQueue () const
 Returns underlying packet queue. More...
 
bool registerPacketQueueFactory (const std::string &queue_type, Factory factory)
 Registers new queue factory function for a given queue type. More...
 
bool unregisterPacketQueueFactory (const std::string &queue_type)
 Unregisters the queue factory function for a given type. More...
 

Protected Attributes

std::map< std::string, Factoryfactories_
 A map holding registered backend factory functions. More...
 
PacketQueueTypePtr packet_queue_
 the current queue_ ? More...
 

Detailed Description

template<typename PacketQueueTypePtr>
class isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >

Packet Queue Managers (PQM).

Base class to manage the registry of packet queue implementations and the creation of and access to the current packet queue.

Template Parameters
PacktQueueTypePtrBase type of packet queues managed by the manager (e.g. PacketQueue4Ptr, PacketQueue6Ptr).

Definition at line 39 of file packet_queue_mgr.h.

Member Typedef Documentation

◆ Factory

template<typename PacketQueueTypePtr>
typedef std::function<PacketQueueTypePtr(data::ConstElementPtr)> isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::Factory

Defines the type of the packet queue factory function.

Factory function returns a pointer to the instance of the packet queue created.

Definition at line 45 of file packet_queue_mgr.h.

Constructor & Destructor Documentation

◆ PacketQueueMgr()

template<typename PacketQueueTypePtr>
isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::PacketQueueMgr ( )
inline

Constructor.

Definition at line 48 of file packet_queue_mgr.h.

Member Function Documentation

◆ createPacketQueue()

template<typename PacketQueueTypePtr>
void isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::createPacketQueue ( data::ConstElementPtr  parameters)
inline

Create an instance of a packet queue.

Replace the current packet queue with a new one based on the given configuration parameters. The set of parameters must contain at least "queue-type". This value is used to locate the registered queue factory to invoke to create the new queue.

The factory is passed the parameters verbatim for its use in creating the new queue. Factories are expected to throw exceptions on creation failure. Note the existing queue is not altered or replaced unless the new queue is successfully created.

Exceptions
InvalidQueueParameterif parameters is not map that contains "queue-type", InvalidQueueType if the queue type requested is not supported.
Unexpectedif the backend factory function returned NULL.

Definition at line 133 of file packet_queue_mgr.h.

◆ destroyPacketQueue()

template<typename PacketQueueTypePtr>
void isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::destroyPacketQueue ( )
inline

Destroys the current packet queue.

Any queued packets will be discarded.

Definition at line 174 of file packet_queue_mgr.h.

◆ getPacketQueue()

template<typename PacketQueueTypePtr>
PacketQueueTypePtr isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::getPacketQueue ( ) const
inline

Returns underlying packet queue.

Definition at line 168 of file packet_queue_mgr.h.

◆ registerPacketQueueFactory()

template<typename PacketQueueTypePtr>
bool isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::registerPacketQueueFactory ( const std::string &  queue_type,
Factory  factory 
)
inline

Registers new queue factory function for a given queue type.

The typical usage of this function is to make the PQM aware of a packet queue implementation. This implementation may exist in a hooks library. In such a case, this function should be called from the load function in this library. When the queue impl is registered, the server will use it when required by the configuration, i.e. a user specifies it in "queue-control:queue-type"

If the given queue type has already been registered, perhaps by another hooks library, the PQM will refuse to register another of the same type.

Parameters
queue_typeQueue type, e.g. "kea-ring4"
factoryPointer to the queue factory function.
Returns
true if the queue type has been successfully registered, false if the type already exists.

Definition at line 70 of file packet_queue_mgr.h.

◆ unregisterPacketQueueFactory()

template<typename PacketQueueTypePtr>
bool isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::unregisterPacketQueueFactory ( const std::string &  queue_type)
inline

Unregisters the queue factory function for a given type.

This function is used to remove the factory function for a given type. Typically, it would be called when unloading the hook library which loaded the type, and thus called by the library's unload function. In addition to removing the factory, it will also destroy the current queue if it is of the same queue-type as the factory being removed. This avoids the nastiness that occurs when objecs are left in existence after their library is unloaded.

Parameters
queue_typequeue type, e.g. "kea-ring4".
Returns
false if no factory for the given type was unregistered, true if the factory was removed.

Definition at line 96 of file packet_queue_mgr.h.

Member Data Documentation

◆ factories_

template<typename PacketQueueTypePtr>
std::map<std::string, Factory> isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::factories_
protected

A map holding registered backend factory functions.

Definition at line 180 of file packet_queue_mgr.h.

◆ packet_queue_

template<typename PacketQueueTypePtr>
PacketQueueTypePtr isc::dhcp::PacketQueueMgr< PacketQueueTypePtr >::packet_queue_
protected

the current queue_ ?

Definition at line 183 of file packet_queue_mgr.h.


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