5 #ifndef BPP_SEQ_CONTAINER_VECTORMAPPEDCONTAINER_H
6 #define BPP_SEQ_CONTAINER_VECTORMAPPEDCONTAINER_H
110 throw Exception(
"VectorMappedContainer::getObjectPosition : Not found object with name " + name);
140 if (names.size() !=
vNames_.size())
141 throw BadSizeException(
"VectorMappedContainer::setObjectNames: bad number of new names",
vNames_.size(), names.size());
145 for (
size_t i = 0; i < names.size(); i++)
161 void addObject(std::shared_ptr<T> newObject,
size_t objectIndex,
const std::string& name,
bool check =
false)
override
171 void insertObject(std::shared_ptr<T> newObject,
size_t objectIndex,
const std::string& name)
override
175 vNames_.insert(
vNames_.begin() +
static_cast<std::ptrdiff_t
>(objectIndex), name);
178 if (it.second >= objectIndex)
185 virtual void appendObject(std::shared_ptr<T> newObject,
const std::string& name,
bool checkNames =
true)
200 if (it.second > objectIndex)
203 vNames_.erase(
vNames_.begin() +
static_cast<std::ptrdiff_t
>(objectIndex));
215 if (it.second > objectIndex)
218 vNames_.erase(
vNames_.begin() +
static_cast<std::ptrdiff_t
>(objectIndex));
232 void addObject_(std::shared_ptr<T> newObject,
size_t objectIndex,
const std::string& name,
bool check =
false)
const
236 const_cast<std::vector<std::string>&
>(
vNames_)[objectIndex] = name;
237 const_cast<std::map<std::string, size_t>&
>(
mNames_)[name] = objectIndex;
MappedNamedContainer class.
void addObject(std::shared_ptr< T > newObject, const std::string &name, bool checkName=false)
Set an object.
void changeName(const std::string &okey, const std::string &nkey)
change the key of an object.
std::shared_ptr< T > removeObject(const std::string &name) override
Remove and returns an object.
void clear() override
Delete all objects in the container.
virtual void nullify()
Nullify all elements.
void deleteObject(const std::string &name) override
Remove an object.
size_t getSize() const override
Get the number of objects in the container.
MappedNamedContainer & operator=(const MappedNamedContainer &msc)
void addObject_(std::shared_ptr< T > newObject, const std::string &name, bool checkName=false) const
The template PositionedNamedContainer interface, that links position & name containers.
The template VectorMappedContainer class.
void addObject(std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name, bool check=false) override
void insertObject(std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name) override
VectorMappedContainer(const VectorMappedContainer &vsc)
void deleteObject(size_t objectIndex) override
Delete an object from the container.
virtual void appendObject(std::shared_ptr< T > newObject, const std::string &name, bool checkNames=true)
void clear() override
Delete all objects in the container.
void addObject_(std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name, bool check=false) const
const std::string & getObjectName(size_t objectIndex) const override
virtual ~VectorMappedContainer()
std::map< std::string, size_t > mNames_
map <string, size_t> for the positions of the names
VectorMappedContainer< T > * clone() const override
std::vector< std::string > getObjectNames() const override
void nullify() override
Nullify all elements.
std::shared_ptr< T > removeObject(const std::string &name) override
Remove and returns an object.
size_t getObjectPosition(const std::string &name) const override
Link between position & name.
void deleteObject(const std::string &name) override
Remove an object.
VectorMappedContainer< T > & operator=(const VectorMappedContainer &vsc)
void setObjectNames(const std::vector< std::string > &names)
size_t getSize() const override
Get the number of objects in the container.
size_t getNumberOfObjects() const
std::vector< std::string > vNames_
vector of the names, in same order as objects
void setObjectName(size_t pos, const std::string &name)
std::shared_ptr< T > removeObject(size_t objectIndex) override
Extract and remove a object from the container.
The template VectorPositionedContainer class.
std::shared_ptr< T > removeObject(size_t objectIndex) override
Extract and remove a object from the container.
size_t getSize() const override
the size
void deleteObject(size_t objectIndex) override
Delete an object from the container.
void appendObject(std::shared_ptr< T > object)
VectorPositionedContainer< T > & operator=(const VectorPositionedContainer< T > &vsc)
copy where shared_ptr elements are shared
void addObject(std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false)
Add an object.
void insertObject(std::shared_ptr< T > object, size_t objectIndex)
Insert an object.
void addObject_(std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false) const
virtual void nullify()
Nullify all elements.
void clear() override
Destroys the vector.
This alphabet is used to deal NumericAlphabet.