VTK
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 #define VTK_INFORMATION_USE_HASH_MAP
31 #ifdef VTK_INFORMATION_USE_HASH_MAP
32 # include <unordered_map>
33 #else
34 # include <map>
35 #endif
36 
37 //----------------------------------------------------------------------------
39 {
40 public:
43 #ifdef VTK_INFORMATION_USE_HASH_MAP
44  struct HashFun
45  {
46  size_t operator()(KeyType key) const
47  {
48  return static_cast<size_t>(key - KeyType(nullptr));
49  }
50  };
51  typedef std::unordered_map<KeyType, DataType, HashFun> MapType;
52 #else
53  typedef std::map<KeyType, DataType> MapType;
54 #endif
55  MapType Map;
56 
57 #ifdef VTK_INFORMATION_USE_HASH_MAP
59 #endif
60 
62  {
63  for(MapType::iterator i = this->Map.begin(); i != this->Map.end(); ++i)
64  {
65  if(vtkObjectBase* value = i->second)
66  {
67  value->UnRegister(nullptr);
68  }
69  }
70  }
71 };
72 
73 #undef VTK_INFORMATION_USE_HASH_MAP
74 
75 #endif
76 // VTK-HeaderTest-Exclude: vtkInformationInternals.h
internal structure for vtkInformation
std::unordered_map< KeyType, DataType, HashFun > MapType
Superclass for vtkInformation keys.
size_t operator()(KeyType key) const
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65