43 using NameIdMap = std::map<std::string, std::size_t>;
60 std::unique_ptr<NameIdMap> elem_name_map =
nullptr)
67 OGS_FATAL(
"Constructor TemplateVec: vector of data elements is a nullptr.");
81 for (std::size_t k(0); k <
size(); k++)
83 delete (*_data_vec)[k];
160 element_name = it->first;
180 for (std::size_t k(0); k <
_data_vec->size(); k++)
192 virtual void push_back (T* data_element, std::string
const*
const name =
nullptr)
200 std::map<std::string, std::size_t>::const_iterator it(
207 "Name '{:s}' exists already. The object will be inserted "
231 NameIdMap::const_iterator
235 [
id](
NameIdPair const& elem) { return elem.second == id; });
void WARN(char const *fmt, Args const &... args)
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
std::unique_ptr< NameIdMap > _name_id_map
std::map< std::string, std::size_t > NameIdMap
void setNameOfElementByID(std::size_t id, std::string const &element_name)
Return the name of an element based on its ID.
std::pair< std::string, std::size_t > NameIdPair
const std::vector< T * > * getVector() const
NameIdMap::const_iterator getNameIDMapBegin() const
Returns the begin of the name id mapping structure.
virtual void push_back(T *data_element, std::string const *const name=nullptr)
Adds a new element to the vector.
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
virtual void setNameForElement(std::size_t id, std::string const &name)
Sets the given name for the element of the given ID.
NameIdMap::const_iterator findFirstElementByID(std::size_t const &id) const
std::string getName() const
TemplateVec(const TemplateVec &)
bool getElementIDByName(const std::string &name, std::size_t &id) const
TemplateVec & operator=(const TemplateVec &rhs)
void setName(const std::string &n)
bool getNameOfElement(const T *data, std::string &name) const
TemplateVec(std::string name, std::unique_ptr< std::vector< T * >> data_vec, std::unique_ptr< NameIdMap > elem_name_map=nullptr)
std::unique_ptr< std::vector< T * > > _data_vec
const T * getElementByName(const std::string &name) const
Returns an element with the given name.
NameIdMap::const_iterator getNameIDMapEnd() const
Returns the end of the name id mapping structure.