VTK  9.7.1
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
14 #ifndef vtkArrayIteratorTemplate_h
15 #define vtkArrayIteratorTemplate_h
16 
17 #include "vtkArrayIterator.h"
18 #include "vtkCommonCoreModule.h" // For export macro
19 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
20 
21 #include "vtkCompiler.h" // for VTK_USE_EXTERN_TEMPLATE
22 #include "vtkStdString.h" // For template instantiation
23 #include "vtkVariant.h" // For template instantiation
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 template <class T>
28  : public vtkArrayIterator
29 {
30 public:
32  vtkTemplateTypeMacro(vtkArrayIteratorTemplate<T>, vtkArrayIterator);
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
42  void Initialize(vtkAbstractArray* array) override;
43 
47  vtkAbstractArray* GetArray() { return this->Array; }
48 
52  T* GetTuple(vtkIdType id);
53 
57  T& GetValue(vtkIdType id) { return this->Pointer[id]; }
58 
64  void SetValue(vtkIdType id, T value) { this->Pointer[id] = value; }
65 
69  vtkIdType GetNumberOfTuples() const;
70 
74  vtkIdType GetNumberOfValues() const;
75 
79  int GetNumberOfComponents() const;
80 
84  int GetDataType() const override;
85 
89  int GetDataTypeSize() const;
90 
94  typedef T ValueType;
95 
96 protected:
98  ~vtkArrayIteratorTemplate() override;
99 
101 
102 private:
104  void operator=(const vtkArrayIteratorTemplate&) = delete;
105 
106  void SetArray(vtkAbstractArray*);
107  vtkAbstractArray* Array;
108 };
109 
110 #ifdef VTK_USE_EXTERN_TEMPLATE
111 #ifndef vtkArrayIteratorTemplateInstantiate_cxx
112 #ifdef _MSC_VER
113 #pragma warning(push)
114 // The following is needed when the vtkArrayIteratorTemplate is declared
115 // dllexport and is used from another class in vtkCommonCore
116 #pragma warning(disable : 4910) // extern and dllexport incompatible
117 #endif
118 vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate);
119 extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate<vtkStdString>;
120 extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate<vtkVariant>;
121 #ifdef _MSC_VER
122 #pragma warning(pop)
123 #endif
124 #endif
125 #endif // VTK_USE_EXTERN_TEMPLATE
126 
127 VTK_ABI_NAMESPACE_END
128 #endif
129 
130 // VTK-HeaderTest-Exclude: vtkArrayIteratorTemplate.h
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
T ValueType
This is the data type for the value.
Abstract superclass for all arrays.
vtkAbstractArray * GetArray()
Get the array.
int vtkIdType
Definition: vtkType.h:363
virtual int GetDataType() const =0
Get the data type from the underlying array.
Implementation template for a array iterator.
vtkInstantiateTemplateMacro(extern template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate)
virtual void Initialize(vtkAbstractArray *array)=0
Set the array this iterator will iterate over.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetValue(vtkIdType id, T value)
Sets the value at the index.
T & GetValue(vtkIdType id)
Must be called only after Initialize.
Abstract superclass to iterate over elements in an vtkAbstractArray.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define VTK_DEPRECATED_IN_9_7_0(reason)