mavtables  0.2.1
MAVLink router and firewall.
Public Member Functions | List of all members
ConnectionFactory< C, AP, PQ > Class Template Reference

#include <ConnectionFactory.hpp>

Inheritance diagram for ConnectionFactory< C, AP, PQ >:
Inheritance graph
Collaboration diagram for ConnectionFactory< C, AP, PQ >:
Collaboration graph

Public Member Functions

 ConnectionFactory (std::shared_ptr< Filter > filter, bool mirror=false)
 
TEST_VIRTUAL ~ConnectionFactory ()=default
 
TEST_VIRTUAL std::unique_ptr< C > get (std::string name="unknown")
 
TEST_VIRTUAL bool wait_for_packet (const std::chrono::nanoseconds &timeout)
 

Detailed Description

template<class C = Connection, class AP = AddressPool<>, class PQ = PacketQueue>
class ConnectionFactory< C, AP, PQ >

A factory for making related connections that use a common semaphore.

Definition at line 36 of file ConnectionFactory.hpp.

Constructor & Destructor Documentation

◆ ConnectionFactory()

template<class C , class AP , class PQ >
ConnectionFactory< C, AP, PQ >::ConnectionFactory ( std::shared_ptr< Filter filter,
bool  mirror = false 
)

Construct a connection factory.

Template Parameters
CThe Connection class (or derived class) to use.
APThe AddressPool class (or derived class) to use.
PQThe PacketQueue class (or derived class) to use, must accept a callback function in it's constructor.
Parameters
filterThe packet filter to use for determining whether and with what priority to add a packet to the queue for transmission. This will be given to each constructed Connection. Cannot be nullptr.
mirrorSet to true if all Connection's made by this factory are to be mirror connections. A mirror connection is one that will receive all packets, regardless of destination address. The default is false.
Exceptions
std::invalid_argumentif the given filter pointer is null.

Definition at line 67 of file ConnectionFactory.hpp.

◆ ~ConnectionFactory()

template<class C = Connection, class AP = AddressPool<>, class PQ = PacketQueue>
TEST_VIRTUAL ConnectionFactory< C, AP, PQ >::~ConnectionFactory ( )
default

Member Function Documentation

◆ get()

template<class C , class AP , class PQ >
std::unique_ptr< C > ConnectionFactory< C, AP, PQ >::get ( std::string  name = "unknown")

Construct and return a new connection.

This connection will share a common semaphore with all other connections made by this factory instance.

Parameters
nameThe name of the new connection.
Returns
The new connection.

Definition at line 87 of file ConnectionFactory.hpp.

◆ wait_for_packet()

template<class C , class AP , class PQ >
bool ConnectionFactory< C, AP, PQ >::wait_for_packet ( const std::chrono::nanoseconds &  timeout)

Wait for a packet to be available on any connection made by this factory.

Parameters
timeoutHow long to block waiting for a packet. Set to 0s for non blocking.
Return values
trueThere is a packet on at lest one of the connections created by this factory instance.
falseThe wait timed out, there is no packet available on any of the connections created by this factory instance.

Definition at line 109 of file ConnectionFactory.hpp.


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