Visual Computing Library
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_CONCEPTS_MESH_COMPONENTS_COMPONENT_H
24#define VCL_CONCEPTS_MESH_COMPONENTS_COMPONENT_H
25
26#include <vclib/types.h>
27
28namespace vcl::comp {
29
43template<typename T>
44concept ComponentConcept = requires {
45 { RemoveRef<T>::COMPONENT_ID } -> std::same_as<const uint&>;
46};
47
56template<typename T>
58 ComponentConcept<T> && RemoveRef<T>::IS_VERTICAL == true && requires {
59 typename RemoveRef<T>::DataValueType;
60 { RemoveRef<T>::IS_VERTICAL } -> std::same_as<const bool&>;
61 };
62
71template<typename T>
73 IsVerticalComponent<T> && RemoveRef<T>::IS_OPTIONAL == true && requires {
74 { RemoveRef<T>::IS_OPTIONAL } -> std::same_as<const bool&>;
75 };
76
90template<typename T>
91concept HasInitMemberFunction = ComponentConcept<T> && requires (T&& obj) {
92 { obj.init() } -> std::same_as<void>;
93};
94
103template<typename T>
105 ComponentConcept<T> && requires (T&& obj) {
106 { obj.isAvailable() } -> std::same_as<bool>;
107 };
108
123template<typename T>
125 ComponentConcept<T> && RemoveRef<T>::TIED_TO_VERTEX_NUMBER;
126
151template<typename T, typename R>
154 std::is_base_of<ReferencesComponentTriggerer<RemoveRef<R>>, RemoveRef<T>>::
155 value;
156
165template<typename T, typename R>
168
180template<typename T, typename R>
181concept HasPointersOfType = HasReferencesOfType<T, R> && requires (T&& obj) {
182 obj.template pointers<RemoveRef<R>>();
183};
184
193template<typename T, typename R>
196
208template<typename T, typename R>
209concept HasIndicesOfType = HasReferencesOfType<T, R> && requires (T&& obj) {
210 obj.template indices<RemoveRef<R>>();
211};
212
221template<typename T, typename R>
224
225// ======== Has Component Concepts ======== //
226// Concepts that needs to be called on a type T that has the "Components" type
227// defined as a TypeWrapper of components. The type T is generally a Mesh or a
228// MeshElement.
229
245template<typename T, uint COMP_ID>
246concept HasComponentOfType = detail::
247 ComponentOfTypePred<COMP_ID, typename RemoveRef<T>::Components>::value;
248
265template<typename T, uint COMP_ID>
269 ComponentOfType<COMP_ID, typename RemoveRef<T>::Components>>;
270
287template<typename T, uint COMP_ID>
291 ComponentOfType<COMP_ID, typename RemoveRef<T>::Components>>;
292
293} // namespace vcl::comp
294
295#endif // VCL_CONCEPTS_MESH_COMPONENTS_COMPONENT_H
The ComponentConcept is evaluated to true whenever the type T is a valid component,...
Definition component.h:44
The HasComponentOfType concept checks whether a type T (that may be a Mesh or a MeshElement) has a co...
Definition component.h:246
The HasIndicesOfType concept checks whether a component T stores indices of a type (element) R.
Definition component.h:209
Evaluates to true if the type T is a component that has a init() member function, that must be called...
Definition component.h:91
Evaluates to true if the type T is a component that has a isAvailable() member function,...
Definition component.h:104
The HasOptionalComponentOfType concept checks whether a type T (that should be a MeshElement) has an ...
Definition component.h:288
See vcl::comp::HasIndicesOfType and vcl::comp::IsOptionalComponent.
Definition component.h:222
See vcl::comp::HasPointersOfType and vcl::comp::IsOptionalComponent.
Definition component.h:194
See vcl::comp::HasReferencesOfType and vcl::comp::IsOptionalComponent.
Definition component.h:166
The HasPointersOfType concept checks whether a component T stores pointers of a type (element) R.
Definition component.h:181
The HasReferencesOfType concept checks whether a component T stores references (pointers or indices) ...
Definition component.h:152
The HasVerticalComponentOfType concept checks whether a type T (that should be a MeshElement) has a v...
Definition component.h:266
Evaluates to true if the type T is a component that is stored vertically in its element container,...
Definition component.h:72
Evaluates to true if the type T is tied to the number of vertices in the face.
Definition component.h:124
Evaluates to true if the type T is a component that is stored vertically in its element container.
Definition component.h:57