VTK
dox/Common/Core/vtkInformationKey.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkInformationKey.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 =========================================================================*/
00028 #ifndef __vtkInformationKey_h
00029 #define __vtkInformationKey_h
00030 
00031 #include "vtkCommonCoreModule.h" // For export macro
00032 #include "vtkObjectBase.h"
00033 #include "vtkObject.h" // Need vtkTypeMacro
00034 
00035 class vtkInformation;
00036 
00037 class VTKCOMMONCORE_EXPORT vtkInformationKey : public vtkObjectBase
00038 {
00039 public:
00040   vtkTypeMacro(vtkInformationKey,vtkObjectBase);
00041   void PrintSelf(ostream& os, vtkIndent indent);
00042 
00044   virtual void Register(vtkObjectBase*);
00045 
00047   virtual void UnRegister(vtkObjectBase*);
00048 
00051   const char* GetName();
00052 
00055   const char* GetLocation();
00056 
00058 
00063   vtkInformationKey(const char* name, const char* location);
00064   ~vtkInformationKey();
00066 
00070   virtual void ShallowCopy(vtkInformation* from, vtkInformation* to)=0;
00071 
00073 
00077   virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
00078     { this->ShallowCopy(from, to); }
00080 
00082   virtual int Has(vtkInformation* info);
00083 
00085   virtual void Remove(vtkInformation* info);
00086 
00088   virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
00089 
00091 
00092   void Print(vtkInformation* info);
00093   virtual void Print(ostream& os, vtkInformation* info);
00095 
00096 protected:
00097   const char* Name;
00098   const char* Location;
00099 
00100   // Set/Get the value associated with this key instance in the given
00101   // information object.
00102   void SetAsObjectBase(vtkInformation* info, vtkObjectBase* value);
00103   const vtkObjectBase* GetAsObjectBase(vtkInformation* info) const;
00104   vtkObjectBase* GetAsObjectBase(vtkInformation* info);
00105 
00106   // Report the object associated with this key instance in the given
00107   // information object to the collector.
00108   void ReportAsObjectBase(vtkInformation* info,
00109                           vtkGarbageCollector* collector);
00110 
00111   // Helper for debug leaks support.
00112   void ConstructClass(const char*);
00113 
00114 private:
00115   vtkInformationKey(const vtkInformationKey&);  // Not implemented.
00116   void operator=(const vtkInformationKey&);  // Not implemented.
00117 };
00118 
00119 // Macros to define an information key instance in a C++ source file.
00120 // The corresponding method declaration must appear in the class
00121 // definition in the header file.
00122 #define vtkInformationKeyMacro(CLASS, NAME, type)             \
00123  vtkInformation##type##Key* CLASS::NAME()                     \
00124    {                                                          \
00125    static vtkInformation##type##Key* CLASS##_##NAME =         \
00126         new vtkInformation##type##Key(#NAME, #CLASS);         \
00127    return CLASS##_##NAME;                                     \
00128    }
00129 #define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required)   \
00130  vtkInformation##type##Key* CLASS::NAME()                               \
00131    {                                                                    \
00132    static vtkInformation##type##Key* CLASS##_##NAME =                   \
00133      new vtkInformation##type##Key(#NAME, #CLASS, required);            \
00134    return CLASS##_##NAME;                                               \
00135    }
00136 
00137 #endif