ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | Protected Member Functions | List of all members
anna::comm::ReceiverFactory Class Referenceabstract

#include <ReceiverFactory.hpp>

Inheritance diagram for anna::comm::ReceiverFactory:
Inheritance graph
[legend]
Collaboration diagram for anna::comm::ReceiverFactory:
Collaboration graph
[legend]

Public Member Functions

const std::string & getName () const
 
Receivercreate () noexcept(false)
 
void release (Receiver *receiver)
 
std::string asString () const
 
xml::NodeasXML (xml::Node *parent) const
 
- Public Member Functions inherited from anna::Mutex
 Mutex (const Mode::_v mode=Mode::Recursive)
 
virtual ~Mutex ()
 
virtual void lock () noexcept(false)
 
virtual void unlock ()
 
bool trylock () noexcept(false)
 
 operator const pthread_mutex_t * () const
 

Protected Member Functions

 ReceiverFactory (const char *name)
 
virtual Receiverdo_create ()=0
 
virtual void do_release (Receiver *receiver)=0
 
- Protected Member Functions inherited from anna::Safe
 Safe ()
 

Detailed Description

Interface for receivers factories.

Is recommended (performance issues) to use Recycler<T> as in the following example:

class MyReceiver;
class MyReceiverFactory : public ReceiverFactory {
public:
MyReceiverFactory () : ReceiverFactory ("MyReceiverFactory") {;}
private:
Receiver* do_create () { return a_receivers.create (); }
void do_release (Receiver* receiver) { a_receivers.release (static_cast <MyReceiver*> (receiver)); }
};

In most of cases, is recommended to use an comm::ReceiverFactoryImpl instance with the receiver type used in our application.

See also
Receiver
ReceiverFactoryImpl

Constructor & Destructor Documentation

◆ ReceiverFactory()

anna::comm::ReceiverFactory::ReceiverFactory ( const char *  name)
protected

Constructor.

Parameters
nameLogical name for this receivers factory.

Member Function Documentation

◆ asString()

std::string anna::comm::ReceiverFactory::asString ( void  ) const
inline

Returns a string with relevant information for this instance.

Returns
string with relevant information for this instance.
82  {
83  std::string msg("anna::comm::ReceiverFactory { Name: ");
84  msg += a_name;
85  return msg += " }";
86  }

◆ asXML()

xml::Node* anna::comm::ReceiverFactory::asXML ( xml::Node parent) const

Returns a XML document with relevant information for this instance.

Parameters
parentXML node from which created data will depend on.
Returns
a XML document with relevant information for this instance.

◆ create()

Receiver* anna::comm::ReceiverFactory::create ( )
noexcept

Creates a receiver instance for this factory. Reuse resources when needed.

Returns
The new receiver instance.
Warning
All the receivers obtained shall be released by mean release.

◆ do_create()

virtual Receiver* anna::comm::ReceiverFactory::do_create ( )
protectedpure virtual

Creates the receiver instance if no other reusable instance is found. This method is called from a critical section activated for this instance.

Returns
The new receiver instance.
Warning
All the receivers obtained shall be released by mean release.

◆ do_release()

virtual void anna::comm::ReceiverFactory::do_release ( Receiver receiver)
protectedpure virtual

Release the receiver provided. This method is called from a critical section activated for this instance.

Parameters
Thereceiver instance to be released.

◆ getName()

const std::string& anna::comm::ReceiverFactory::getName ( ) const
inline

Returns the logical name for this receiver factory.

Returns
logical name for this receiver factory.
59 { return a_name; }

◆ release()

void anna::comm::ReceiverFactory::release ( Receiver receiver)

Release the receiver instance provided.

Returns
The receiver instance to be released.
Warning
The parameter should have been obtained by mean create.

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