Visual Computing Library
Loading...
Searching...
No Matches
vcl::mesh::CustomComponentsVectorMap< true > Class Reference

Public Member Functions

void clear ()
 Removes all the custom component vectors stored in the mMap.
 
void reserve (uint size)
 For each custom component vector, it reserves the given size.
 
void resize (uint size)
 For each custom component vector, it resizes the vector to the given size.
 
void compact (const std::vector< uint > &newIndices)
 Compacts each custom component vector according to the given indices.
 
template<typename CompType >
void addNewComponent (const std::string &name, uint size)
 Adds a new vector of custom components having the given size, the given name and with the template argumet CompType.
 
void deleteComponent (const std::string &name)
 Deletes the custom component vector with the given name. It does nothing if the element does not exist.
 
void assertComponentExists (const std::string &compName) const
 Asserts that the compName component exists.
 
bool componentExists (const std::string &compName) const
 Returns true if the compName exists.
 
std::vector< std::string > allComponentNames () const
 Returns a vector of std::string containing all the custom components, regardless the types of the custom components.
 
template<typename CompType >
bool isComponentOfType (const std::string &compName) const
 Returns true if the type associated to the compName custom component is the same of the given template argument CompType.
 
std::type_index componentType (const std::string &compName) const
 Returns the std::type_index of the type of the CustomComponent having the input name.
 
template<typename CompType >
std::vector< std::string > allComponentNamesOfType () const
 Returns a vector of strings of all the custom components having as type the given template argument CompType.
 
template<typename CompType >
const std::vector< std::any > & componentVector (const std::string &compName) const
 Returns a const reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.
 
template<typename CompType >
std::vector< std::any > & componentVector (const std::string &compName)
 Returns a reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.
 
void importSameCustomComponentFrom (uint thisPos, uint otherPos, const std::string &compName, const CustomComponentsVectorMap< true > &other)
 

Private Member Functions

template<typename CompType >
void checkComponentType (const std::string &compName) const
 

Private Attributes

std::unordered_map< std::string, std::vector< std::any > > mMap
 
std::unordered_map< std::string, boolmNeedToInitialize
 
std::unordered_map< std::string, std::type_index > mCompType
 

Member Function Documentation

◆ addNewComponent()

template<typename CompType >
void vcl::mesh::CustomComponentsVectorMap< true >::addNewComponent ( const std::string &  name,
uint  size 
)
inline

Adds a new vector of custom components having the given size, the given name and with the template argumet CompType.

Data is initialized with the empty constructor of CompType.

Note
If a custom component with the same name already exists, it is replaced, no matter of the old type.
Template Parameters
CompTypethe type of the newly added custom component.
Parameters
[in]namethe unique name of the custom component.
[in]sizethe initial size of the custom component vector.

◆ allComponentNames()

std::vector< std::string > vcl::mesh::CustomComponentsVectorMap< true >::allComponentNames ( ) const
inline

Returns a vector of std::string containing all the custom components, regardless the types of the custom components.

Returns
a vector of std::string containing all the custom components.

◆ allComponentNamesOfType()

template<typename CompType >
std::vector< std::string > vcl::mesh::CustomComponentsVectorMap< true >::allComponentNamesOfType ( ) const
inline

Returns a vector of strings of all the custom components having as type the given template argument CompType.

Template Parameters
CompTypethe type of the custom components to return.
Returns
a vector of strings of all the custom components having as type the given template argument CompType.

◆ assertComponentExists()

void vcl::mesh::CustomComponentsVectorMap< true >::assertComponentExists ( const std::string &  compName) const
inline

Asserts that the compName component exists.

Parameters
[in]compNamethe name of the custom component to check.

◆ compact()

void vcl::mesh::CustomComponentsVectorMap< true >::compact ( const std::vector< uint > &  newIndices)
inline

Compacts each custom component vector according to the given indices.

All the indices of the newIndices vector with value UINT_NULL are considered as deleted, and the corresponding elements in the custom component vectors are removed. The remaining indices are compacted, and the custom component vectors are resized to the new size.

Parameters
[in]newIndicesa vector that tells, for each element index, the new index of the element, and UINT_NULL if the element has been deleted.

◆ componentExists()

bool vcl::mesh::CustomComponentsVectorMap< true >::componentExists ( const std::string &  compName) const
inline

Returns true if the compName exists.

Parameters
[in]compNamethe name of the custom component to check.
Returns
true if the compName exists.

◆ componentType()

std::type_index vcl::mesh::CustomComponentsVectorMap< true >::componentType ( const std::string &  compName) const
inline

Returns the std::type_index of the type of the CustomComponent having the input name.

Exceptions
std::out_of_rangeif the compName does not exist.
Parameters
[in]compNamethe name of the custom component.
Returns
the std::type_index of the type of the CustomComponent having the input name.

◆ componentVector() [1/2]

template<typename CompType >
std::vector< std::any > & vcl::mesh::CustomComponentsVectorMap< true >::componentVector ( const std::string &  compName)
inline

Returns a reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.

If the CompType does not mach with the type associated with compName, thows a vcl::BadCustomComponentTypeException.

This function will initialize all the uninitialized values of the accessed custom component.

Template Parameters
CompTypethe type of the custom component to return.
Parameters
[in]compNamethe name of the custom component to return.
Returns
a reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.

◆ componentVector() [2/2]

template<typename CompType >
const std::vector< std::any > & vcl::mesh::CustomComponentsVectorMap< true >::componentVector ( const std::string &  compName) const
inline

Returns a const reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.

If the CompType does not mach with the type associated with compName, thows a vcl::BadCustomComponentTypeException.

Template Parameters
CompTypethe type of the custom component to return.
Parameters
[in]compNamethe name of the custom component to return.
Returns
a const reference of std::vector<std::any> of the custom component with the given name and the given template argument CompType.

◆ deleteComponent()

void vcl::mesh::CustomComponentsVectorMap< true >::deleteComponent ( const std::string &  name)
inline

Deletes the custom component vector with the given name. It does nothing if the element does not exist.

Parameters
[in]namethe name of the custom component vector to delete.

◆ isComponentOfType()

template<typename CompType >
bool vcl::mesh::CustomComponentsVectorMap< true >::isComponentOfType ( const std::string &  compName) const
inline

Returns true if the type associated to the compName custom component is the same of the given template argument CompType.

Template Parameters
CompTypethe type to check.
Parameters
[in]compNamethe name of the custom component to check.
Returns
true if the type associated to the compName custom component is the same of the given template argument CompType.

◆ reserve()

void vcl::mesh::CustomComponentsVectorMap< true >::reserve ( uint  size)
inline

For each custom component vector, it reserves the given size.

Parameters
[in]sizethe size to reserve for each custom component vector.

◆ resize()

void vcl::mesh::CustomComponentsVectorMap< true >::resize ( uint  size)
inline

For each custom component vector, it resizes the vector to the given size.

Parameters
[in]sizethe size to reserve for each custom component vector.

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