Visual Computing Library  devel
Loading...
Searching...
No Matches
component.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_MESH_COMPONENTS_CONCEPTS_COMPONENT_H
24#define VCL_MESH_COMPONENTS_CONCEPTS_COMPONENT_H
25
26#include <vclib/mesh/components/base/base.h>
27
28#include <vclib/base.h>
29
30namespace vcl::comp {
31
45template<typename T>
46concept ComponentConcept = requires {
47 { RemoveRef<T>::COMPONENT_ID } -> std::same_as<const uint&>;
48};
49
58template<typename T>
60 ComponentConcept<T> && RemoveRef<T>::IS_VERTICAL == true && requires {
61 typename RemoveRef<T>::DataValueType;
62 { RemoveRef<T>::IS_VERTICAL } -> std::same_as<const bool&>;
63 };
64
73template<typename T>
75 IsVerticalComponent<T> && RemoveRef<T>::IS_OPTIONAL == true && requires {
76 { RemoveRef<T>::IS_OPTIONAL } -> std::same_as<const bool&>;
77 };
78
92template<typename T>
93concept HasInitMemberFunction = ComponentConcept<T> && requires (T&& obj) {
94 { obj.init() } -> std::same_as<void>;
95};
96
105template<typename T>
107 ComponentConcept<T> && requires (T&& obj) {
108 { obj.isAvailable() } -> std::same_as<bool>;
109 };
110
125template<typename T>
127 ComponentConcept<T> && RemoveRef<T>::TIED_TO_VERTEX_NUMBER;
128
153template<typename T, typename R>
156 std::is_base_of<ReferencesComponentTriggerer<RemoveRef<R>>, RemoveRef<T>>::
157 value;
158
167template<typename T, typename R>
170
182template<typename T, typename R>
183concept HasPointersOfType = HasReferencesOfType<T, R> && requires (T&& obj) {
184 obj.template pointers<RemoveRef<R>>();
185};
186
195template<typename T, typename R>
198
210template<typename T, typename R>
211concept HasIndicesOfType = HasReferencesOfType<T, R> && requires (T&& obj) {
212 obj.template indices<RemoveRef<R>>();
213};
214
223template<typename T, typename R>
226
227// ======== Has Component Concepts ======== //
228// Concepts that needs to be called on a type T that has the "Components" type
229// defined as a TypeWrapper of components. The type T is generally a Mesh or a
230// MeshElement.
231
247template<typename T, uint COMP_ID>
248concept HasComponentOfType = detail::
249 ComponentOfTypePred<COMP_ID, typename RemoveRef<T>::Components>::value;
250
267template<typename T, uint COMP_ID>
271 ComponentOfType<COMP_ID, typename RemoveRef<T>::Components>>;
272
289template<typename T, uint COMP_ID>
293 ComponentOfType<COMP_ID, typename RemoveRef<T>::Components>>;
294
295} // namespace vcl::comp
296
297#endif // VCL_MESH_COMPONENTS_CONCEPTS_COMPONENT_H
The ComponentConcept is evaluated to true whenever the type T is a valid component,...
Definition component.h:46
The HasComponentOfType concept checks whether a type T (that may be a Mesh or a MeshElement) has a co...
Definition component.h:248
The HasIndicesOfType concept checks whether a component T stores indices of a type (element) R.
Definition component.h:211
Evaluates to true if the type T is a component that has a init() member function, that must be called...
Definition component.h:93
Evaluates to true if the type T is a component that has a isAvailable() member function,...
Definition component.h:106
The HasOptionalComponentOfType concept checks whether a type T (that should be a MeshElement) has an ...
Definition component.h:290
See vcl::comp::HasIndicesOfType and vcl::comp::IsOptionalComponent.
Definition component.h:224
See vcl::comp::HasPointersOfType and vcl::comp::IsOptionalComponent.
Definition component.h:196
See vcl::comp::HasReferencesOfType and vcl::comp::IsOptionalComponent.
Definition component.h:168
The HasPointersOfType concept checks whether a component T stores pointers of a type (element) R.
Definition component.h:183
The HasReferencesOfType concept checks whether a component T stores references (pointers or indices) ...
Definition component.h:154
The HasVerticalComponentOfType concept checks whether a type T (that should be a MeshElement) has a v...
Definition component.h:268
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:74
Evaluates to true if the type T is tied to the number of vertices in the face.
Definition component.h:126
Evaluates to true if the type T is a component that is stored vertically in its element container.
Definition component.h:59