World Ocean Simulation System (WOSS) library
woss::TransducerHandler Class Reference

Transducer creator and handler class. More...

#include <transducer-handler.h>

Collaboration diagram for woss::TransducerHandler:
Collaboration graph

Public Member Functions

 TransducerHandler ()
 
 TransducerHandler (const TransducerHandler &copy)=default
 
 TransducerHandler (TransducerHandler &&tmp)=default
 
 TransducerHandler (TransducerMap &transduc_map)
 
virtual ~TransducerHandler ()=default
 
bool insertValue (const std::string &name, const Transducer &transducer)
 
TransducerHandlerreplaceValue (const std::string &name, const Transducer &transducer)
 
std::unique_ptr< TransducergetValue (const std::string &name) const
 
TransducerHandlereraseValue (const std::string &name)
 
int size () const
 
bool empty () const
 
TransducerHandlerclear ()
 
TMCIter begin () const
 
TMCIter end () const
 
virtual bool importValueAscii (const std::string &type_name, const std::string &file_name)
 
virtual bool importValueBinary (const std::string &type_name, const std::string &file_name)
 
virtual bool writeValueAscii (const std::string &type_name, const std::string &file_name)
 
virtual bool writeValueBinary (const std::string &type_name, const std::string &file_name)
 
TransducerHandleroperator= (const TransducerHandler &copy)=default
 
TransducerHandleroperator= (TransducerHandler &&copy)=default
 
TransducerHandlersetDebug (bool flag)
 
bool getDebug () const
 

Protected Types

using TransducerMap = std::unordered_map< std::string, std::unique_ptr< Transducer > >
 
using TMIter = TransducerMap::iterator
 
using TMCIter = TransducerMap::const_iterator
 

Protected Member Functions

void initializeNotValid ()
 

Protected Attributes

bool debug
 
TransducerMap transducer_map
 

Static Protected Attributes

static const std::string TRANSDUCER_NOT_VALID = "TRANSDUCER_NOT_VALID"
 

Detailed Description

Transducer creator and handler class.

woss::TransducerHandler class imports and saves woss::Transducer. It provides access to them via string name.

Member Typedef Documentation

◆ TMCIter

using woss::TransducerHandler::TMCIter = TransducerMap::const_iterator
protected

◆ TMIter

using woss::TransducerHandler::TMIter = TransducerMap::iterator
protected

◆ TransducerMap

using woss::TransducerHandler::TransducerMap = std::unordered_map< std::string, std::unique_ptr<Transducer> >
protected

Map that links a string to a pointer to a woss::Transducer

Constructor & Destructor Documentation

◆ TransducerHandler() [1/4]

TransducerHandler::TransducerHandler ( )

TransducerHandler default constructor

◆ TransducerHandler() [2/4]

woss::TransducerHandler::TransducerHandler ( const TransducerHandler copy)
default

◆ TransducerHandler() [3/4]

woss::TransducerHandler::TransducerHandler ( TransducerHandler &&  tmp)
default

◆ TransducerHandler() [4/4]

TransducerHandler::TransducerHandler ( TransducerMap transduc_map)

TransducerHandler constructor.

Parameters
transduc_mapTransducerMap to be inserted

References transducer_map.

◆ ~TransducerHandler()

virtual woss::TransducerHandler::~TransducerHandler ( )
virtualdefault

Member Function Documentation

◆ begin()

TransducerHandler::TMCIter woss::TransducerHandler::begin ( ) const
inline

Returns a const iterator to the beginning of the tranducer map

Returns
const iterator

References transducer_map.

◆ clear()

TransducerHandler & TransducerHandler::clear ( )

Deletes all pointers and clears the map

Returns
reference to *this

References clear(), and transducer_map.

Referenced by clear().

Here is the call graph for this function:

◆ empty()

bool woss::TransducerHandler::empty ( ) const
inline

Checks if the instance has any stored values

Returns
true if condition applies, false otherwise

References transducer_map.

◆ end()

TransducerHandler::TMCIter woss::TransducerHandler::end ( ) const
inline

Returns a const iterator to the end of the tranducer map

Returns
const iterator

References transducer_map.

◆ eraseValue()

TransducerHandler & TransducerHandler::eraseValue ( const std::string &  name)

Erases and deletes the pointer to a woss::Transducer for given string

Parameters
nameconst reference to string
Returns
reference to *this

References transducer_map.

◆ getDebug()

bool woss::TransducerHandler::getDebug ( ) const
inline

References debug.

◆ getValue()

std::unique_ptr< Transducer > TransducerHandler::getValue ( const std::string &  name) const

Returns a std::unique_ptr to a woss::Transducer for the input string.

Parameters
nameconst reference to string
Returns
a std::unique_ptr to a heap allocated woss::Transducer that is invalid if the given key is not found.

References initializeNotValid(), transducer_map, and TRANSDUCER_NOT_VALID.

Here is the call graph for this function:

◆ importValueAscii()

bool TransducerHandler::importValueAscii ( const std::string &  type_name,
const std::string &  file_name 
)
virtual

Imports a woss::Transducer from the given file and with given string key

Parameters
type_nametransducer type name
file_namefile path
Returns
true if method was successful, false otherwise

References woss::Singleton< T >::instance(), and transducer_map.

Here is the call graph for this function:

◆ importValueBinary()

bool TransducerHandler::importValueBinary ( const std::string &  type_name,
const std::string &  file_name 
)
virtual

Imports a woss::Transducer from the given binary file and with given string key

Parameters
type_nametransducer type name
file_namefile path
Returns
true if method was successful, false otherwise

References woss::Singleton< T >::instance(), and transducer_map.

Here is the call graph for this function:

◆ initializeNotValid()

void TransducerHandler::initializeNotValid ( )
protected

References woss::Singleton< T >::instance(), transducer_map, and TRANSDUCER_NOT_VALID.

Referenced by getValue().

Here is the call graph for this function:

◆ insertValue()

bool TransducerHandler::insertValue ( const std::string &  name,
const Transducer transducer 
)

Inserts and doesn't replace if another pointer to a woss::Transducer is found for given key; in this case the given pointer is deleted.

Parameters
nametype name
transducerconstant pointer to a woss::Transducer
Returns
true if inserted, false otherwise

References woss::Transducer::clone(), and transducer_map.

Here is the call graph for this function:

◆ operator=() [1/2]

TransducerHandler & woss::TransducerHandler::operator= ( const TransducerHandler copy)
default

◆ operator=() [2/2]

TransducerHandler & woss::TransducerHandler::operator= ( TransducerHandler &&  copy)
default

◆ replaceValue()

TransducerHandler & TransducerHandler::replaceValue ( const std::string &  name,
const Transducer transducer 
)

Replaces a pointer to a woss::Transducer for given key. The old value is deleted

Parameters
nametype name
transducerconstant pointer to a woss::Transducer
Returns
true if inserted, false otherwise

References woss::Transducer::clone(), and transducer_map.

Here is the call graph for this function:

◆ setDebug()

TransducerHandler & woss::TransducerHandler::setDebug ( bool  flag)
inline

Sets debug flag for all instances

Parameters
flagdebug bool

References debug.

◆ size()

int woss::TransducerHandler::size ( ) const
inline

Returns the number of pointers stored

Returns
number of pointers stored

References transducer_map.

◆ writeValueAscii()

bool TransducerHandler::writeValueAscii ( const std::string &  type_name,
const std::string &  file_name 
)
virtual

Writes a woss::Transducer to the given file

Parameters
type_nametransducer type name
file_namefile path
Returns
true if method was successful, false otherwise

References transducer_map.

◆ writeValueBinary()

bool TransducerHandler::writeValueBinary ( const std::string &  type_name,
const std::string &  file_name 
)
virtual

Writes a woss::Transducer to the given binary file

Parameters
type_nametransducer type name
file_namefile path
Returns
true if method was successful, false otherwise

References transducer_map.

Member Data Documentation

◆ debug

bool woss::TransducerHandler::debug
protected

debug flag

Referenced by getDebug(), and setDebug().

◆ transducer_map

◆ TRANSDUCER_NOT_VALID

const std::string TransducerHandler::TRANSDUCER_NOT_VALID = "TRANSDUCER_NOT_VALID"
staticprotected

string key that represents an invalid woss::Transducer

Referenced by getValue(), and initializeNotValid().


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