VTK
dox/Common/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 "vtkObjectBase.h"
00032 #include "vtkObject.h" // Need vtkTypeMacro
00033 
00034 class vtkInformation;
00035 
00036 class VTK_COMMON_EXPORT vtkInformationKey : public vtkObjectBase
00037 {
00038 public:
00039   vtkTypeMacro(vtkInformationKey,vtkObjectBase);
00040   void PrintSelf(ostream& os, vtkIndent indent);
00041 
00043   virtual void Register(vtkObjectBase*);
00044 
00046   virtual void UnRegister(vtkObjectBase*);
00047 
00050   const char* GetName();
00051 
00054   const char* GetLocation();
00055 
00057 
00062   vtkInformationKey(const char* name, const char* location);
00063   ~vtkInformationKey();
00065 
00069   virtual void ShallowCopy(vtkInformation* from, vtkInformation* to)=0;
00070 
00072 
00076   virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
00077     { this->ShallowCopy(from, to); }
00079 
00081   virtual int Has(vtkInformation* info);
00082 
00084   virtual void Remove(vtkInformation* info);
00085 
00087   virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
00088 
00090 
00091   void Print(vtkInformation* info);
00092   virtual void Print(ostream& os, vtkInformation* info);
00094 
00095 protected:
00096   const char* Name;
00097   const char* Location;
00098 
00099   // Set/Get the value associated with this key instance in the given
00100   // information object.
00101   void SetAsObjectBase(vtkInformation* info, vtkObjectBase* value);
00102   vtkObjectBase* GetAsObjectBase(vtkInformation* info);
00103 
00104   // Report the object associated with this key instance in the given
00105   // information object to the collector.
00106   void ReportAsObjectBase(vtkInformation* info,
00107                           vtkGarbageCollector* collector);
00108 
00109   // Helper for debug leaks support.
00110   void ConstructClass(const char*);
00111 
00112 private:
00113   vtkInformationKey(const vtkInformationKey&);  // Not implemented.
00114   void operator=(const vtkInformationKey&);  // Not implemented.
00115 };
00116 
00117 // Macros to define an information key instance in a C++ source file.
00118 // The corresponding method declaration must appear in the class
00119 // definition in the header file.
00120 #define vtkInformationKeyMacro(CLASS, NAME, type)             \
00121  vtkInformation##type##Key* CLASS::NAME()                     \
00122    {                                                          \
00123    static vtkInformation##type##Key* CLASS##_##NAME =         \
00124         new vtkInformation##type##Key(#NAME, #CLASS);         \
00125    return CLASS##_##NAME;                                     \
00126    }
00127 #define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required)   \
00128  vtkInformation##type##Key* CLASS::NAME()                               \
00129    {                                                                    \
00130    static vtkInformation##type##Key* CLASS##_##NAME =                   \
00131      new vtkInformation##type##Key(#NAME, #CLASS, required);            \
00132    return CLASS##_##NAME;                                               \
00133    }
00134 
00135 #endif