VTK
dox/Common/Core/vtkInformationInternals.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkInformationInternals.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00023 #ifndef __vtkInformationInternals_h
00024 #define __vtkInformationInternals_h
00025 
00026 #include "vtkInformationKey.h"
00027 #include "vtkObjectBase.h"
00028 
00029 #define VTK_INFORMATION_USE_HASH_MAP
00030 #ifdef VTK_INFORMATION_USE_HASH_MAP
00031 # include <vtksys/hash_map.hxx>
00032 #else
00033 # include <vtksys/stl/map>
00034 #endif
00035 
00036 //----------------------------------------------------------------------------
00037 class vtkInformationInternals
00038 {
00039 public:
00040   typedef vtkInformationKey* KeyType;
00041   typedef vtkObjectBase* DataType;
00042 #ifdef VTK_INFORMATION_USE_HASH_MAP
00043   struct HashFun
00044   {
00045     size_t operator()(KeyType key) const
00046       {
00047       return static_cast<size_t>(key - KeyType(0));
00048       }
00049   };
00050   typedef vtksys::hash_map<KeyType, DataType, HashFun> MapType;
00051 #else
00052   typedef vtksys_stl::map<KeyType, DataType> MapType;
00053 #endif
00054   MapType Map;
00055 
00056 #ifdef VTK_INFORMATION_USE_HASH_MAP
00057   vtkInformationInternals(): Map(33) {}
00058 #endif
00059 
00060   ~vtkInformationInternals()
00061     {
00062     for(MapType::iterator i = this->Map.begin(); i != this->Map.end(); ++i)
00063       {
00064       if(vtkObjectBase* value = i->second)
00065         {
00066         value->UnRegister(0);
00067         }
00068       }
00069     }
00070 };
00071 
00072 #undef VTK_INFORMATION_USE_HASH_MAP
00073 
00074 #endif
00075 // VTK-HeaderTest-Exclude: vtkInformationInternals.h