23#ifndef VCL_MESH_COMPONENTS_CUSTOM_COMPONENTS_H
24#define VCL_MESH_COMPONENTS_CUSTOM_COMPONENTS_H
27#include "detail/custom_components_data.h"
29#include <vclib/base.h>
91template<
typename ParentElemType =
void>
94 static const bool IS_VERTICAL = !std::is_same_v<ParentElemType, void>;
96 detail::CustomComponentsData<ParentElemType, IS_VERTICAL> mData;
123 return mData.componentExists(
144 template<
typename CompType>
168 return mData.componentType(
180 template<
typename CompType>
210 template<
typename CompType>
240 template<
typename CompType>
247 template<
typename CompType>
248 void addCustomComponent(
255 void deleteCustomComponent(
const std::string&
compName)
256 requires (!IS_VERTICAL)
258 return mData.deleteCustomComponent(
compName);
261 template<
typename CompType>
262 void serializeCustomComponentsOfType(std::ostream& os)
const
263 requires (!IS_VERTICAL)
265 std::vector<std::string> compNames =
266 customComponentNamesOfType<CompType>();
267 vcl::serialize(os, compNames);
268 for (
const auto& name : compNames) {
269 const CompType& c = customComponent<CompType>(name);
270 vcl::serialize(os, c);
274 template<
typename CompType>
275 void deserializeCustomComponentsOfType(std::istream& is)
276 requires (!IS_VERTICAL)
278 std::vector<std::string> compNames;
279 vcl::deserialize(is, compNames);
280 for (
const auto& name : compNames) {
282 vcl::deserialize(is, c);
283 addCustomComponent<CompType>(name, c);
288 template<
typename Element>
289 void importFrom(
const Element& e,
bool =
true);
291 void serialize(std::ostream& os)
const
296 void deserialize(std::istream& is)
317 IsDerivedFromSpecializationOfV<T, CustomComponents>;
321template<
typename ParentElemType>
322template<
typename Element>
323void CustomComponents<ParentElemType>::importFrom(
const Element& e,
bool)
328 mData = e.CustomComponents::mData;
A class representing a box in N-dimensional space.
Definition box.h:46
The CustomComponents Component is a container of additional components associated to an Element (e....
Definition custom_components.h:93
std::type_index customComponentType(const std::string &compName) const
Returns the std::type_index of the custom component of the given name.
Definition custom_components.h:166
bool isCustomComponentOfType(const std::string &compName) const
Returns true if the custom component of the given name is of the type given as template argument,...
Definition custom_components.h:145
std::vector< std::string > customComponentNamesOfType() const
Returns a std::vector of std::strings containing the names of the custom components of the type given...
Definition custom_components.h:181
static const uint COMPONENT_ID
The ID of component.
Definition custom_components.h:102
CustomComponents()=default
Initilizes an empty container of custom components.
const CompType & customComponent(const std::string &compName) const
Returns the const reference to the custom component of the given name having the type given as templa...
Definition custom_components.h:211
CompType & customComponent(const std::string &compName)
Returns the reference to the custom component of the given name having the type given as template arg...
Definition custom_components.h:241
bool hasCustomComponent(const std::string &compName) const
Returns true if the element has a custom component with the given name, false otherwise....
Definition custom_components.h:121
A concept that checks whether a type T (that should be an Element or a Mesh) has the CustomComponents...
Definition custom_components.h:316