ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | Friends | List of all members
anna::diameter::codec::EngineManager Class Reference

#include <EngineManager.hpp>

Inheritance diagram for anna::diameter::codec::EngineManager:
Inheritance graph
[legend]
Collaboration diagram for anna::diameter::codec::EngineManager:
Collaboration graph
[legend]

Public Member Functions

virtual ~EngineManager ()
 
appid_codec_engines_it begin () const
 
appid_codec_engines_it end () const
 
int size () const
 
void registerCodecEngine (const ApplicationId &appid, Engine *engine)
 
EnginegetCodecEngine (const ApplicationId &appid) const
 
EnginegetMonoStackCodecEngine () const
 
void selectFromApplicationId (bool enable)
 
bool selectFromApplicationId (void)
 
virtual anna::xml::NodeasXML (anna::xml::Node *parent) const
 

Friends

class anna::Singleton< EngineManager >
 

Additional Inherited Members

- Static Public Member Functions inherited from anna::Singleton< T >
static T & instantiate ()
 
static void release ()
 

Detailed Description

Helper class to centralize application codec engines and ease the automatic codec engine selection from codec resources (mainly Message class, but also Avp).

This is useful if you enable the auto selection from messages application id, avoiding to pre-initialize such codec messages with a specific engine before interpreting the data sources or building. At multithread application, it is recommended to specialize the message codec for each stack without using this engine manager.

Constructor & Destructor Documentation

◆ ~EngineManager()

virtual anna::diameter::codec::EngineManager::~EngineManager ( )
inlinevirtual
58 {;}

Member Function Documentation

◆ asXML()

virtual anna::xml::Node* anna::diameter::codec::EngineManager::asXML ( anna::xml::Node parent) const
virtual

Class XML representation.

Parameters
parentXML node over which we will put instance information.
Returns
XML documentcon with class content.

◆ begin()

appid_codec_engines_it anna::diameter::codec::EngineManager::begin ( ) const
inline

First element iterator

63 { return a_appid_codec_engines.begin(); }

◆ end()

appid_codec_engines_it anna::diameter::codec::EngineManager::end ( ) const
inline

Last element iterator

68 { return a_appid_codec_engines.end(); }

◆ getCodecEngine()

Engine* anna::diameter::codec::EngineManager::getCodecEngine ( const ApplicationId appid) const

Get the associated codec engine for a provided Application-Id.

Parameters
appidApplication-Id
Returns
Found codec engine, NULL if not found

◆ getMonoStackCodecEngine()

Engine* anna::diameter::codec::EngineManager::getMonoStackCodecEngine ( ) const
inline

If only one codec engine is registered (mono-stack application), it will be returned (NULL in other case). This is because mono-stack applications could merge compatible stacks into one unique dictionary, using a global value for stack id with no relation regarding application-id concept.

Returns
Unique codec engine, NULL if not unique (empty manager or more than one)
101  {
102  return ((size() != 1) ? NULL : begin()->second);
103  }
int size() const
Definition: EngineManager.hpp:73
appid_codec_engines_it begin() const
Definition: EngineManager.hpp:63

◆ registerCodecEngine()

void anna::diameter::codec::EngineManager::registerCodecEngine ( const ApplicationId appid,
Engine engine 
)

Registers a new codec engine (externally allocated) associated to an application id. If the application id exists, the new engine pointer will replace the existing one.

Parameters
appidApplication-Id
engineAssociated codec engine

◆ selectFromApplicationId() [1/2]

void anna::diameter::codec::EngineManager::selectFromApplicationId ( bool  enable)
inline

The user could select the appropriate codec engine depending on the context, but some applications could consider interesting automatic codec engine selection from managed messages (decoded from any source, or built from scratch). Then, this engine manager will be used registering all the supported stacks with their corresponding codec engines, and automatic selection will be done during decoding of any supported source of data (hexadecimal buffers, xml documents) or build operations.

If the user pre-initializes the codec engine for a #Message or #Avp element, this selection is ignored even if enabled: the codec engine only can be established one time, for security reasons.

Parameters
enableActivates/deactivates the codec engine selection from the Application-Id value. True by default and applicable when this manager store is not empty.
118 { a_autoSelectFromApplicationId = enable; }

◆ selectFromApplicationId() [2/2]

bool anna::diameter::codec::EngineManager::selectFromApplicationId ( void  )
inline

Gets the currently configured behaviour regarding codec engine selection.

Returns
True if selection is done with the Application-Id (default behaviour). False to disable (the manager could be used for some other things which could be also interesting).
126 { return a_autoSelectFromApplicationId; }

◆ size()

int anna::diameter::codec::EngineManager::size ( ) const
inline

Number of registered engines

73 { return a_appid_codec_engines.size(); }

Friends And Related Function Documentation

◆ anna::Singleton< EngineManager >

friend class anna::Singleton< EngineManager >
friend

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