VTK  9.6.20260321
vtkStdFunctionArray.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3// Funded by CEA, DAM, DIF, F-91297 Arpajon, France
19
20#ifndef vtkStdFunctionArray_h
21#define vtkStdFunctionArray_h
22
23#include "vtkCommonCoreModule.h" // for export macro
24#include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
25#include "vtkImplicitArray.h"
26
27#include <functional>
28
29VTK_ABI_NAMESPACE_BEGIN
30template <class ValueTypeT>
31class VTK_DEPRECATED_IN_9_7_0("No longer needed") VTKCOMMONCORE_EXPORT vtkStdFunctionArray
32#ifndef __VTK_WRAP__
33 : public vtkImplicitArray<std::function<ValueTypeT(int)>,
34 /* vtkArrayTypes::VTK_STD_FUNCTION_ARRAY */ 15>
35{
36 using ImplicitArrayType = vtkImplicitArray<std::function<ValueTypeT(int)>,
37 /* vtkArrayTypes::VTK_STD_FUNCTION_ARRAY */ 15>;
38#else // Fake the superclass for the wrappers.
39 : public vtkDataArray
40{
41 using ImplicitArrayType = vtkDataArray;
42#endif
43public:
46#ifndef __VTK_WRAP__
47 using typename Superclass::ArrayTypeTag;
48 using typename Superclass::DataTypeTag;
49 using typename Superclass::ValueType;
50#else
51 using ValueType = ValueTypeT;
52#endif
53
55
56 // This macro expands to the set of method declarations that
57 // make up the interface of vtkImplicitArray, which is ignored
58 // by the wrappers.
59#if defined(__VTK_WRAP__) || defined(__WRAP_GCCXML__)
61#endif
62
67 {
68 return static_cast<vtkStdFunctionArray<ValueType>*>(Superclass::FastDownCast(source));
69 }
70
74 void ConstructBackend(std::function<ValueType(int)> func);
75
76protected:
78 ~vtkStdFunctionArray() override = default;
79
80private:
82 void operator=(const vtkStdFunctionArray&) = delete;
83};
84
85// Declare vtkArrayDownCast implementations for StdFunction arrays:
87
88VTK_ABI_NAMESPACE_END
89
90// This macro is used by the subclasses to create dummy
91// declarations for these functions such that the wrapper
92// can see them. The wrappers ignore vtkStdFunctionArray.
93#define vtkCreateStdFunctionWrappedArrayInterface(T) \
94 vtkCreateImplicitWrappedArrayInterface(T); \
95 void ConstructBackend(std::function<T(int)> func);
96
97#endif // vtkStdFunctionArray_h
98
99// This portion must be OUTSIDE the include blockers. This is used to tell
100// libraries other than vtkCommonCore that instantiations of
101// vtkStdFunctionArray can be found externally. This prevents each library
102// from instantiating these on their own.
103#ifdef VTK_STD_FUNCTION_ARRAY_INSTANTIATING
104#define VTK_STD_FUNCTION_ARRAY_INSTANTIATE(T) \
105 namespace vtkDataArrayPrivate \
106 { \
107 VTK_ABI_NAMESPACE_BEGIN \
108 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkStdFunctionArray<T>, double); \
109 VTK_ABI_NAMESPACE_END \
110 } \
111 VTK_ABI_NAMESPACE_BEGIN \
112 template class VTKCOMMONCORE_EXPORT vtkStdFunctionArray<T>; \
113 VTK_ABI_NAMESPACE_END
114// We only provide these specializations for the 64-bit integer types, since
115// other types can reuse the double-precision mechanism in
116// vtkDataArray::GetRange without losing precision.
117#define VTK_STD_FUNCTION_ARRAY_INSTANTIATE_VALUERANGE(T) \
118 namespace vtkDataArrayPrivate \
119 { \
120 VTK_ABI_NAMESPACE_BEGIN \
121 VTK_INSTANTIATE_VALUERANGE_ARRAYTYPE(vtkStdFunctionArray<T>, T); \
122 VTK_ABI_NAMESPACE_END \
123 }
124#elif defined(VTK_USE_EXTERN_TEMPLATE)
125#ifndef VTK_STD_FUNCTION_ARRAY_EXTERN
126#define VTK_STD_FUNCTION_ARRAY_EXTERN
127#ifdef _MSC_VER
128#pragma warning(push)
129// The following is needed when the vtkStdFunctionArray is declared
130// dllexport and is used from another class in vtkCommonCore
131#pragma warning(disable : 4910) // extern and dllexport incompatible
132#endif
133VTK_ABI_NAMESPACE_BEGIN
134vtkExternTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkStdFunctionArray);
135VTK_ABI_NAMESPACE_END
136
137namespace vtkDataArrayPrivate
138{
139VTK_ABI_NAMESPACE_BEGIN
140
141// These are instantiated in vtkGenericDataArrayValueRange${i}.cxx
146// These are instantiated by vtkStdFunctionArrayInstantiate_double.cxx.inc, e.t.c.
160
161VTK_ABI_NAMESPACE_END
162} // namespace vtkDataArrayPrivate
163
164#ifdef _MSC_VER
165#pragma warning(pop)
166#endif
167#endif // VTK_STD_FUNCTION_ARRAY_EXTERN
168
169// The following clause is only for MSVC
170#elif defined(_MSC_VER) && !defined(VTK_BUILD_SHARED_LIBS)
171#pragma warning(push)
172
173// C4091: 'extern ' : ignored on left of 'int' when no variable is declared
174#pragma warning(disable : 4091)
175
176// Compiler-specific extension warning.
177#pragma warning(disable : 4231)
178
179// We need to disable warning 4910 and do an extern dllexport
180// anyway. When deriving new arrays from an
181// instantiation of this template the compiler does an explicit
182// instantiation of the base class. From outside the vtkCommon
183// library we block this using an extern dllimport instantiation.
184// For classes inside vtkCommon we should be able to just do an
185// extern instantiation, but VS 2008 complains about missing
186// definitions. We cannot do an extern dllimport inside vtkCommon
187// since the symbols are local to the dll. An extern dllexport
188// seems to be the only way to convince VS 2008 to do the right
189// thing, so we just disable the warning.
190#pragma warning(disable : 4910) // extern and dllexport incompatible
191
192// Use an "extern explicit instantiation" to give the class a DLL
193// interface. This is a compiler-specific extension.
194VTK_ABI_NAMESPACE_BEGIN
195vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkStdFunctionArray);
196VTK_ABI_NAMESPACE_END
197
198#pragma warning(pop)
199
200#endif
201
202// VTK-HeaderTest-Exclude: vtkStdFunctionArray.h
Abstract superclass for all arrays.
std::integral_constant< int, VTK_OPAQUE > DataTypeTag
std::integral_constant< int, vtkArrayTypes::VTK_ABSTRACT_ARRAY > ArrayTypeTag
A utility array for wrapping std::function in implicit arrays.
vtkStdFunctionArray< ValueTypeT > SelfType
~vtkStdFunctionArray() override=default
static vtkStdFunctionArray * New()
void ConstructBackend(std::function< ValueType(int)> func)
Set the std::function to be used as backend.
vtkImplicitArrayTypeMacro(SelfType, ImplicitArrayType)
vtkStdFunctionArray()=default
static vtkStdFunctionArray< ValueType > * FastDownCast(vtkAbstractArray *source)
A faster alternative to SafeDownCast for downcasting vtkAbstractArrays.
#define vtkArrayDownCast_TemplateFastCastMacro(ArrayT)
Same as vtkArrayDownCast_FastCastMacro, but treats ArrayT as a single-parameter template (the paramet...
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_DEPRECATED_IN_9_7_0(reason)
#define VTK_DECLARE_VALUERANGE_ARRAYTYPE(ArrayType, ValueType)
#define vtkCreateImplicitWrappedArrayInterface(T)
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
Definition vtkType.h:458
#define vtkInstantiateTemplateMacro(decl)
A macro to instantiate a template over all numerical types.
Definition vtkType.h:411