bpp-seq3  3.0.0
bpp::MappedNamedContainer< T > Class Template Reference

MappedNamedContainer class. More...

#include <Bpp/Seq/Container/MappedNamedContainer.h>

+ Inheritance diagram for bpp::MappedNamedContainer< T >:
+ Collaboration diagram for bpp::MappedNamedContainer< T >:

Public Member Functions

 MappedNamedContainer ()
 
 MappedNamedContainer (const std::map< std::string, std::shared_ptr< T >> &ms)
 
 MappedNamedContainer (const MappedNamedContainer &msc)
 
virtual ~MappedNamedContainer ()
 
MappedNamedContaineroperator= (const MappedNamedContainer &msc)
 
const std::shared_ptr< T > getObject (const std::string &name) const override
 Retrieve an object from the container. More...
 
std::shared_ptr< T > getObject (const std::string &name) override
 
const T & object (const std::string &name) const override
 
T & object (const std::string &name) override
 
bool hasObject (const std::string &name) const override
 Check if a object with a given name is present in the container. More...
 
void addObject (std::shared_ptr< T > newObject, const std::string &name, bool checkName=false)
 Set an object. More...
 
void deleteObject (const std::string &name) override
 Remove an object. More...
 
std::shared_ptr< T > removeObject (const std::string &name) override
 Remove and returns an object. More...
 
virtual std::vector< std::string > getObjectNames () const override
 
void changeName (const std::string &okey, const std::string &nkey)
 change the key of an object. More...
 
size_t getSize () const override
 Get the number of objects in the container. More...
 
void clear () override
 Delete all objects in the container. More...
 
bool isAvailableName (std::string objectName) const
 
void addObject_ (std::shared_ptr< T > newObject, const std::string &name, bool checkName=false) const
 
virtual void nullify ()
 Nullify all elements. More...
 
The clonable interface
MappedNamedContainerclone () const override
 

Private Attributes

std::map< std::string, std::shared_ptr< T > > mObjects_
 

Detailed Description

template<class T>
class bpp::MappedNamedContainer< T >

MappedNamedContainer class.

Objects are stored using a key std::string, in a map object.

Definition at line 24 of file MappedNamedContainer.h.

Constructor & Destructor Documentation

◆ MappedNamedContainer() [1/3]

template<class T >
bpp::MappedNamedContainer< T >::MappedNamedContainer ( )
inline

Definition at line 31 of file MappedNamedContainer.h.

Referenced by bpp::MappedNamedContainer< T >::clone().

◆ MappedNamedContainer() [2/3]

template<class T >
bpp::MappedNamedContainer< T >::MappedNamedContainer ( const std::map< std::string, std::shared_ptr< T >> &  ms)
inline

Definition at line 35 of file MappedNamedContainer.h.

◆ MappedNamedContainer() [3/3]

template<class T >
bpp::MappedNamedContainer< T >::MappedNamedContainer ( const MappedNamedContainer< T > &  msc)
inline

Definition at line 39 of file MappedNamedContainer.h.

◆ ~MappedNamedContainer()

template<class T >
virtual bpp::MappedNamedContainer< T >::~MappedNamedContainer ( )
inlinevirtual

Definition at line 43 of file MappedNamedContainer.h.

Member Function Documentation

◆ addObject()

template<class T >
void bpp::MappedNamedContainer< T >::addObject ( std::shared_ptr< T >  newObject,
const std::string &  name,
bool  checkName = false 
)
inline

Set an object.

Parameters
nameThe key of the object.
newObjectThe new object that will be associated to the key.
checkNameTell is the object name must be checked.

Definition at line 110 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::hasObject(), and bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::addObject(), bpp::VectorMappedContainer< T >::appendObject(), and bpp::VectorMappedContainer< T >::insertObject().

◆ addObject_()

template<class T >
void bpp::MappedNamedContainer< T >::addObject_ ( std::shared_ptr< T >  newObject,
const std::string &  name,
bool  checkName = false 
) const
inline

◆ changeName()

template<class T >
void bpp::MappedNamedContainer< T >::changeName ( const std::string &  okey,
const std::string &  nkey 
)
inline

change the key of an object.

Parameters
okeyThe present key of the object.
nkeyThe next key of the object.

Definition at line 168 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::hasObject(), and bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::setObjectName(), and bpp::VectorMappedContainer< T >::setObjectNames().

◆ clear()

template<class T >
void bpp::MappedNamedContainer< T >::clear ( )
inlineoverridevirtual

◆ clone()

◆ deleteObject()

template<class T >
void bpp::MappedNamedContainer< T >::deleteObject ( const std::string &  name)
inlineoverridevirtual

◆ getObject() [1/2]

template<class T >
const std::shared_ptr<T> bpp::MappedNamedContainer< T >::getObject ( const std::string &  name) const
inlineoverridevirtual

Retrieve an object from the container.

Parameters
nameThe name of the object.
Returns
A reference toward the Object with corresponding name.

Implements bpp::NamedContainerInterface< T >.

Definition at line 61 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::MappedNamedContainer< T >::isAvailableName(), bpp::TemplateVectorSequenceContainer< SequenceType >::sequence(), and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::sequence().

◆ getObject() [2/2]

template<class T >
std::shared_ptr<T> bpp::MappedNamedContainer< T >::getObject ( const std::string &  name)
inlineoverridevirtual

◆ getObjectNames()

template<class T >
virtual std::vector<std::string> bpp::MappedNamedContainer< T >::getObjectNames ( ) const
inlineoverridevirtual

◆ getSize()

template<class T >
size_t bpp::MappedNamedContainer< T >::getSize ( ) const
inlineoverridevirtual

Get the number of objects in the container.

Returns
The number of objects in the container.

Implements bpp::NamedContainerInterface< T >.

Reimplemented in bpp::VectorMappedContainer< T >, bpp::VectorMappedContainer< bpp::Sequence >, and bpp::VectorMappedContainer< SequenceType >.

Definition at line 184 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::getNumberOfObjects().

◆ hasObject()

◆ isAvailableName()

template<class T >
bool bpp::MappedNamedContainer< T >::isAvailableName ( std::string  objectName) const
inline
Returns
whether the name is in the map keys and the mapped object is nullptr or empty.

Definition at line 195 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::getObject(), and bpp::MappedNamedContainer< T >::hasObject().

Referenced by bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::sequence().

◆ nullify()

template<class T >
virtual void bpp::MappedNamedContainer< T >::nullify ( )
inlinevirtual

◆ object() [1/2]

template<class T >
const T& bpp::MappedNamedContainer< T >::object ( const std::string &  name) const
inlineoverridevirtual

◆ object() [2/2]

template<class T >
T& bpp::MappedNamedContainer< T >::object ( const std::string &  name)
inlineoverridevirtual

◆ operator=()

template<class T >
MappedNamedContainer& bpp::MappedNamedContainer< T >::operator= ( const MappedNamedContainer< T > &  msc)
inline

◆ removeObject()

template<class T >
std::shared_ptr<T> bpp::MappedNamedContainer< T >::removeObject ( const std::string &  name)
inlineoverridevirtual

Remove and returns an object.

Parameters
nameThe key of the object.
Returns
The object previously associated to the given key.

Implements bpp::NamedContainerInterface< T >.

Reimplemented in bpp::VectorMappedContainer< T >, bpp::VectorMappedContainer< bpp::Sequence >, and bpp::VectorMappedContainer< SequenceType >.

Definition at line 137 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::hasObject(), and bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::removeObject().

Member Data Documentation

◆ mObjects_


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