23#ifndef VCL_MESH_COMPONENTS_BASE_COMPONENT_H
24#define VCL_MESH_COMPONENTS_BASE_COMPONENT_H
28#include "../concepts/component.h"
29#include "../detail/component_data.h"
117 typename DerivedComponent,
120 typename ParentElemType,
123 typename... ReferencedTypes>
124class Component :
public ReferencesComponentTriggerer<ReferencedTypes>...
131 using DataValueType = DataType;
137 static const bool IS_VERTICAL =
138 !std::is_same_v<ParentElemType, void> && VERT;
143 static const uint COMPONENT_ID = COMP_ID;
149 static const bool IS_OPTIONAL = VERT && OPT;
152 detail::ComponentData<DataValueType, IS_VERTICAL> mData;
166 bool isAvailable()
const
168 return mData.template isComponentAvailable<ParentElemType>(
169 static_cast<const DerivedComponent*
>(
this));
173 DataValueType& data()
175 return mData.template get<ParentElemType>(
176 static_cast<DerivedComponent*
>(
this));
179 const DataValueType& data()
const
181 return mData.template get<ParentElemType>(
182 static_cast<const DerivedComponent*
>(
this));
185 ParentElemType* parentElement()
188 !std::is_same_v<ParentElemType, void>,
189 "The component should know its parent element type to get access "
190 "to its pointer. You should define the component by passing the "
191 "element type as template parameter. E.G., for a Face element:\n"
192 "vcl::face::TriangleVertexPtrs<Vertex<Scalar>, Face<Scalar>>\n"
195 return static_cast<ParentElemType*
>(
this);
198 const ParentElemType* parentElement()
const
201 !std::is_same_v<ParentElemType, void>,
202 "The component should know its parent element type to get access "
203 "to its pointer. You should define the component by passing the "
204 "element type as template parameter. E.G., for a Face element:\n"
205 "vcl::face::TriangleVertexPtrs<Vertex<Scalar>, Face<Scalar>>\n"
208 return static_cast<const ParentElemType*
>(
this);
224template<u
int COMPONENT_ID,
typename T>
225bool isComponentAvailableOn(
const T& obj)
227 if constexpr (HasOptionalComponentOfType<T, COMPONENT_ID>) {
228 using ComponentType =
229 ComponentOfType<COMPONENT_ID, typename T::Components>;
230 const ComponentType& c =
static_cast<const ComponentType&
>(obj);
231 return c.isAvailable();
234 return HasComponentOfType<T, COMPONENT_ID>;
244struct IsComponentPred
246 static const bool value = ComponentConcept<T>;
250struct IsVerticalComponentPred
252 static const bool value = IsVerticalComponent<T>;