VTK  9.3.20240424
vtkArrayIteratorTemplate.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
17#ifndef vtkArrayIteratorTemplate_h
18#define vtkArrayIteratorTemplate_h
19
20#include "vtkArrayIterator.h"
21#include "vtkCommonCoreModule.h" // For export macro
22
23#include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
24#include "vtkStdString.h" // For template instantiation
25#include "vtkVariant.h" // For template instantiation
26
27VTK_ABI_NAMESPACE_BEGIN
28template <class T>
29class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate : public vtkArrayIterator
30{
31public:
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
43 void Initialize(vtkAbstractArray* array) override;
44
48 vtkAbstractArray* GetArray() { return this->Array; }
49
54
58 T& GetValue(vtkIdType id) { return this->Pointer[id]; }
59
65 void SetValue(vtkIdType id, T value) { this->Pointer[id] = value; }
66
71
76
81
85 int GetDataType() const override;
86
90 int GetDataTypeSize() const;
91
95 typedef T ValueType;
96
97protected:
100
102
103private:
105 void operator=(const vtkArrayIteratorTemplate&) = delete;
106
107 void SetArray(vtkAbstractArray*);
108 vtkAbstractArray* Array;
109};
110
111#ifdef VTK_USE_EXTERN_TEMPLATE
112#ifndef vtkArrayIteratorTemplateInstantiate_cxx
113#ifdef _MSC_VER
114#pragma warning(push)
115// The following is needed when the vtkArrayIteratorTemplate is declared
116// dllexport and is used from another class in vtkCommonCore
117#pragma warning(disable : 4910) // extern and dllexport incompatible
118#endif
119vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate);
120extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate<vtkStdString>;
121extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate<vtkVariant>;
122#ifdef _MSC_VER
123#pragma warning(pop)
124#endif
125#endif
126#endif // VTK_USE_EXTERN_TEMPLATE
127
128VTK_ABI_NAMESPACE_END
129#endif
130
131// VTK-HeaderTest-Exclude: vtkArrayIteratorTemplate.h
Abstract superclass for all arrays.
Implementation template for a array iterator.
T ValueType
This is the data type for the value.
int GetNumberOfComponents() const
Must be called only after Initialize.
vtkIdType GetNumberOfTuples() const
Must be called only after Initialize.
void Initialize(vtkAbstractArray *array) override
Set the array this iterator will iterate over.
static vtkArrayIteratorTemplate< T > * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractArray * GetArray()
Get the array.
~vtkArrayIteratorTemplate() override
int GetDataType() const override
Get the data type from the underlying array.
void SetValue(vtkIdType id, T value)
Sets the value at the index.
T & GetValue(vtkIdType id)
Must be called only after Initialize.
T * GetTuple(vtkIdType id)
Must be called only after Initialize.
vtkIdType GetNumberOfValues() const
Must be called only after Initialize.
int GetDataTypeSize() const
Get the data type size from the underlying array.
vtkTemplateTypeMacro(vtkArrayIteratorTemplate< T >, vtkArrayIterator)
Abstract superclass to iterate over elements in an vtkAbstractArray.
a simple class to control print indentation
Definition vtkIndent.h:108
int vtkIdType
Definition vtkType.h:315
#define vtkInstantiateTemplateMacro(decl)
A macro to instantiate a template over all numerical types.
Definition vtkType.h:363