World Ocean Simulation System (WOSS) library
woss::WossCreatorContainer< Data > Class Template Reference

Class that stores WossCreator parameters. More...

#include <woss-creator-container.h>

Inheritance diagram for woss::WossCreatorContainer< Data >:
Inheritance graph
Collaboration diagram for woss::WossCreatorContainer< Data >:
Collaboration graph

Public Member Functions

 WossCreatorContainer ()=default
 ~WossCreatorContainer ()=default
bool isEmpty () const
int size () const
bool insert (const Data &data, const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
bool insert (const Data &data, const CoordZ &tx, const CoordZ &rx)
Data get (const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx) const
Data get (const CoordZ &tx, const CoordZ &rx) const
Data & accessAllLocations ()
void erase (const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
void erase (const CoordZ &tx, const CoordZ &rx)
void replace (const Data &data, const std::shared_ptr< Location > &tx, const std::shared_ptr< Location > &rx)
void replace (const Data &data, const CoordZ &tx, const CoordZ &rx)
void clear ()
void setDebug (bool flag)
bool isUsingDebug () const

Static Public Attributes

static std::shared_ptr< LocationALL_LOCATIONS
static const CoordZ ALL_COORDZ

Protected Types

using InnerContainer = std::map< std::shared_ptr<Location>, Data >
using ICIter = typename InnerContainer::iterator
using ICRIter = typename InnerContainer::reverse_iterator
using ICCIter = typename InnerContainer::const_iterator
using ICCRIter = typename InnerContainer::const_reverse_iterator
using DataContainer = std::map< std::shared_ptr<Location>, InnerContainer >
using DCIter = typename DataContainer::iterator
using DCCIter = typename DataContainer::const_iterator
using DCRIter = typename DataContainer::reverse_iterator
using DCRCIter = typename DataContainer::const_reverse_iterator

Protected Member Functions

DCIter find (const CoordZ &coordinates)
ICIter find (const CoordZ &coordinates, const DCIter &iter)
std::shared_ptr< LocationcreateLocation (const CoordZ &coordinates)

Protected Attributes

DataContainer data_container
bool debug = false

Detailed Description

template<typename Data>
class woss::WossCreatorContainer< Data >

Class that stores WossCreator parameters.

WossCreatorContainer provides interface for storing and retrieving custom WossCreator data, indexed by transmitter and receiver std::shared_ptr<woss::Location>

Member Typedef Documentation

◆ DataContainer

template<typename Data>
using woss::WossCreatorContainer< Data >::DataContainer = std::map< std::shared_ptr<Location>, InnerContainer >
protected

The outer container. It associates a transmitter Location pointer to a InnerContainer object

◆ DCCIter

template<typename Data>
using woss::WossCreatorContainer< Data >::DCCIter = typename DataContainer::const_iterator
protected

◆ DCIter

template<typename Data>
using woss::WossCreatorContainer< Data >::DCIter = typename DataContainer::iterator
protected

◆ DCRCIter

template<typename Data>
using woss::WossCreatorContainer< Data >::DCRCIter = typename DataContainer::const_reverse_iterator
protected

◆ DCRIter

template<typename Data>
using woss::WossCreatorContainer< Data >::DCRIter = typename DataContainer::reverse_iterator
protected

◆ ICCIter

template<typename Data>
using woss::WossCreatorContainer< Data >::ICCIter = typename InnerContainer::const_iterator
protected

◆ ICCRIter

template<typename Data>
using woss::WossCreatorContainer< Data >::ICCRIter = typename InnerContainer::const_reverse_iterator
protected

◆ ICIter

template<typename Data>
using woss::WossCreatorContainer< Data >::ICIter = typename InnerContainer::iterator
protected

◆ ICRIter

template<typename Data>
using woss::WossCreatorContainer< Data >::ICRIter = typename InnerContainer::reverse_iterator
protected

◆ InnerContainer

template<typename Data>
using woss::WossCreatorContainer< Data >::InnerContainer = std::map< std::shared_ptr<Location>, Data >
protected

The innermost container. It associates a receiver Location pointer to the Data object

Constructor & Destructor Documentation

◆ WossCreatorContainer()

template<typename Data>
woss::WossCreatorContainer< Data >::WossCreatorContainer ( )
default

Referenced by get().

◆ ~WossCreatorContainer()

template<typename Data>
woss::WossCreatorContainer< Data >::~WossCreatorContainer ( )
default

Member Function Documentation

◆ accessAllLocations()

template<typename Data>
Data & woss::WossCreatorContainer< Data >::accessAllLocations ( )
inline

Returns a reference to the Data object associated to transmitter and receiver Location equal to ALL_LOCATIONS. If no keys were present, the Data object is default constructed and a reference to it is returned

Returns
a reference to a Data object

References ALL_LOCATIONS, and data_container.

◆ clear()

template<typename Data>
void woss::WossCreatorContainer< Data >::clear ( )
inline

Clears the container

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

◆ createLocation()

template<typename Data>
std::shared_ptr< Location > woss::WossCreatorContainer< Data >::createLocation ( const CoordZ & coordinates)
inlineprotected

Creates a Location for a given CoordZ

Parameters
coordinatesa const reference to a valid receiver CoordZ
Returns
a std::shared_ptr to a heap-allocated Location pointer

References ALL_COORDZ, createLocation(), and woss::Singleton< DefHandler >::instance().

Referenced by createLocation(), insert(), and replace().

Here is the call graph for this function:

◆ erase() [1/2]

template<typename Data>
void woss::WossCreatorContainer< Data >::erase ( const CoordZ & tx,
const CoordZ & rx )
inline

Erases an object into the container

Parameters
txconst reference to a valid transmitter CoordZ
rxconst reference to a valid receiver CoordZ

References ALL_COORDZ, ALL_LOCATIONS, and data_container.

◆ erase() [2/2]

template<typename Data>
void woss::WossCreatorContainer< Data >::erase ( const std::shared_ptr< Location > & tx,
const std::shared_ptr< Location > & rx )
inline

Erases an object into the container

Parameters
txconst reference to a std::shared_ptr to a valid transmitter Location
rxconst reference to a std::shared_ptr to a valid receiver Location

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

◆ find() [1/2]

template<typename Data>
WossCreatorContainer< Data >::DCIter woss::WossCreatorContainer< Data >::find ( const CoordZ & coordinates)
protected

Returns an DataContainer iterators that points to the given transmitter coordinates. An iterator to the end of the DataContainer is returned if no coordinates are found

Parameters
coordinatesa const reference to a valid transmitter CoordZ
Returns
a DataContainer::iterator

References ALL_COORDZ, ALL_LOCATIONS, data_container, and debug.

Referenced by get(), insert(), and replace().

◆ find() [2/2]

template<typename Data>
WossCreatorContainer< Data >::ICIter woss::WossCreatorContainer< Data >::find ( const CoordZ & coordinates,
const DCIter & iter )
protected

Returns an InnerContainer iterators for the DataContainter iterator that points to the given receiver coordinates. An iterator to the relative end of the InnerContainer is returned if no coordinates are found

Parameters
coordinatesa const reference to a valid receiver CoordZ
Returns
a DataContainer::iterator

References ALL_COORDZ, ALL_LOCATIONS, and debug.

◆ get() [1/2]

template<typename Data>
Data woss::WossCreatorContainer< Data >::get ( const CoordZ & tx,
const CoordZ & rx ) const
inline

Returns an object into the container. If the keys are NOT found, a default constructed object is returned

Parameters
txconst reference to a valid transmitter CoordZ
rxconst reference to a valid receiver CoordZ
Returns
a copy of the original object

References ALL_COORDZ, data_container, debug, and WossCreatorContainer().

Here is the call graph for this function:

◆ get() [2/2]

template<typename Data>
Data woss::WossCreatorContainer< Data >::get ( const std::shared_ptr< Location > & tx,
const std::shared_ptr< Location > & rx ) const
inline

Returns an object into the container. If the keys are NOT found, a default constructed object is returned

Parameters
txconst reference to a std::shared_ptr to a valid transmitter Location
rxconst reference to a std::shared_ptr to a valid receiver Location
Returns
a copy of the original object

References ALL_LOCATIONS, data_container, debug, and find().

Referenced by WossUnitTest::testWossCreatorContainer().

Here is the call graph for this function:

◆ insert() [1/2]

template<typename Data>
bool woss::WossCreatorContainer< Data >::insert ( const Data & data,
const CoordZ & tx,
const CoordZ & rx )
inline

Inserts an object into the container. If the keys are already present, the object is NOT inserted

Parameters
dataconst reference to a Data object to be inserted
txconst reference to a valid transmitter CoordZ
rxconst reference to a valid receiver CoordZ
Returns
true if it's empty, false otherwise

References createLocation(), data_container, and find().

Here is the call graph for this function:

◆ insert() [2/2]

template<typename Data>
bool woss::WossCreatorContainer< Data >::insert ( const Data & data,
const std::shared_ptr< Location > & tx,
const std::shared_ptr< Location > & rx )
inline

Inserts an object into the container. If the keys are already present, the object is NOT inserted

Parameters
dataconst reference to a Data object to be inserted
txconst reference to a std::shared_ptr to a valid transmitter Location
rxconst reference to a std::shared_ptr to a valid receiver Location
Returns
true if it's empty, false otherwise

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

◆ isEmpty()

template<typename Data>
bool woss::WossCreatorContainer< Data >::isEmpty ( ) const
inline

Checks if the container is empty

Returns
true if it's empty, false otherwise

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

◆ isUsingDebug()

template<typename Data>
bool woss::WossCreatorContainer< Data >::isUsingDebug ( ) const
inline

Retuns the debug flag

Returns
true if is using the debug flag, false otherwise

◆ replace() [1/2]

template<typename Data>
void woss::WossCreatorContainer< Data >::replace ( const Data & data,
const CoordZ & tx,
const CoordZ & rx )
inline

Replaces an object into the container. If the key are not present, the object is still inserted

Parameters
dataconst reference to a Data object to be inserted
txconst reference to a valid transmitter CoordZ
rxconst reference to a valid receiver CoordZ
Returns
true if it's empty, false otherwise

References createLocation(), data_container, and find().

Here is the call graph for this function:

◆ replace() [2/2]

template<typename Data>
void woss::WossCreatorContainer< Data >::replace ( const Data & data,
const std::shared_ptr< Location > & tx,
const std::shared_ptr< Location > & rx )
inline

Replaces an object into the container. If the key are not present, the object is still inserted

Parameters
dataconst reference to a Data object to be inserted
txconst reference to a std::shared_ptr to a valid transmitter Location
rxconst reference to a std::shared_ptr to a valid receiver Location
Returns
true if it's empty, false otherwise

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

◆ setDebug()

template<typename Data>
void woss::WossCreatorContainer< Data >::setDebug ( bool flag)
inline

Sets or unsets the debug flag

Parameters
flagboolean flag

Referenced by WossUnitTest::testWossCreatorContainer().

◆ size()

template<typename Data>
int woss::WossCreatorContainer< Data >::size ( ) const
inline

Returns the size of the container

Returns
container's size

References data_container.

Referenced by WossUnitTest::testWossCreatorContainer().

Member Data Documentation

◆ ALL_COORDZ

template<typename Data>
const CoordZ woss::WossCreatorContainer< Data >::ALL_COORDZ
static

Pointer that represents the index for all possible coordinates

Referenced by createLocation(), erase(), find(), find(), get(), and WossUnitTest::testWossCreatorContainer().

◆ ALL_LOCATIONS

template<typename Data>
std::shared_ptr<Location> woss::WossCreatorContainer< Data >::ALL_LOCATIONS
static

Pointer that represents the index for all possible Locations

Referenced by accessAllLocations(), erase(), find(), find(), get(), and WossUnitTest::testWossCreatorContainer().

◆ data_container

template<typename Data>
DataContainer woss::WossCreatorContainer< Data >::data_container
protected

◆ debug

template<typename Data>
bool woss::WossCreatorContainer< Data >::debug = false
protected

Debug flag

Referenced by find(), find(), get(), and get().


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