VTK  9.2.6
vtkInformationInternals.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkInformationInternals.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
24#ifndef vtkInformationInternals_h
25#define vtkInformationInternals_h
26
27#include "vtkInformationKey.h"
28#include "vtkObjectBase.h"
29
30#include <cstdint>
31#define VTK_INFORMATION_USE_HASH_MAP
32#ifdef VTK_INFORMATION_USE_HASH_MAP
33#include <unordered_map>
34#else
35#include <map>
36#endif
37
38//----------------------------------------------------------------------------
40{
41public:
44#ifdef VTK_INFORMATION_USE_HASH_MAP
45 struct HashFun
46 {
47 size_t operator()(KeyType key) const
48 {
49 return reinterpret_cast<uintptr_t>(key) / sizeof(vtkInformationKey);
50 }
51 };
52 typedef std::unordered_map<KeyType, DataType, HashFun> MapType;
53#else
54 typedef std::map<KeyType, DataType> MapType;
55#endif
57
58#ifdef VTK_INFORMATION_USE_HASH_MAP
60 : Map(33)
61 {
62 }
63#endif
64
66 {
67 for (MapType::iterator i = this->Map.begin(); i != this->Map.end(); ++i)
68 {
69 if (vtkObjectBase* value = i->second)
70 {
71 value->UnRegister(nullptr);
72 }
73 }
74 }
75
76private:
78};
79
80#undef VTK_INFORMATION_USE_HASH_MAP
81
82#endif
83// 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
Definition: vtkObjectBase.h:74
size_t operator()(KeyType key) const