VTK  9.3.20240424
vtkInformationInternals.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
12#ifndef vtkInformationInternals_h
13#define vtkInformationInternals_h
14
15#include "vtkInformationKey.h"
16#include "vtkObjectBase.h"
17
18#include <cstdint>
19#define VTK_INFORMATION_USE_HASH_MAP
20#ifdef VTK_INFORMATION_USE_HASH_MAP
21#include <unordered_map>
22#else
23#include <map>
24#endif
25
26//----------------------------------------------------------------------------
27VTK_ABI_NAMESPACE_BEGIN
29{
30public:
33#ifdef VTK_INFORMATION_USE_HASH_MAP
34 struct HashFun
35 {
36 size_t operator()(KeyType key) const
37 {
38 return reinterpret_cast<uintptr_t>(key) / sizeof(vtkInformationKey);
39 }
40 };
41 typedef std::unordered_map<KeyType, DataType, HashFun> MapType;
42#else
43 typedef std::map<KeyType, DataType> MapType;
44#endif
46
47#ifdef VTK_INFORMATION_USE_HASH_MAP
49 : Map(33)
50 {
51 }
52#endif
53
55 {
56 for (MapType::iterator i = this->Map.begin(); i != this->Map.end(); ++i)
57 {
58 if (vtkObjectBase* value = i->second)
59 {
60 value->UnRegister(nullptr);
61 }
62 }
63 }
64
65#ifdef VTK_INFORMATION_USE_HASH_MAP
66private:
68#endif
69};
70
71#undef VTK_INFORMATION_USE_HASH_MAP
72
73VTK_ABI_NAMESPACE_END
74#endif
75// VTK-HeaderTest-Exclude: vtkInformationInternals.h
internal structure for vtkInformation
std::unordered_map< KeyType, DataType, HashFun > MapType
Superclass for vtkInformation keys.
abstract base class for most VTK objects