VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/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 
00097 
00103   virtual bool NeedToExecute(vtkInformation* vtkNotUsed(pipelineInfo),
00104                              vtkInformation* vtkNotUsed(dobjInfo)) {return false;}
00106 
00108 
00118   virtual void StoreMetaData(vtkInformation* vtkNotUsed(request),
00119                              vtkInformation* vtkNotUsed(pipelineInfo),
00120                              vtkInformation* vtkNotUsed(dobjInfo)) {}
00122 
00124 
00130   virtual void CopyDefaultInformation(vtkInformation* vtkNotUsed(request),
00131                                       vtkInformation* vtkNotUsed(fromInfo),
00132                                       vtkInformation* vtkNotUsed(toInfo)) {}
00134 
00135 protected:
00136   char* Name;
00137   char* Location;
00138 
00139 #define vtkInformationKeySetStringMacro(name) \
00140 virtual void Set##name (const char* _arg) \
00141   { \
00142   if ( this->name == NULL && _arg == NULL) { return;} \
00143   if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
00144   delete [] this->name; \
00145   if (_arg) \
00146     { \
00147     size_t n = strlen(_arg) + 1; \
00148     char *cp1 =  new char[n]; \
00149     const char *cp2 = (_arg); \
00150     this->name = cp1; \
00151     do { *cp1++ = *cp2++; } while ( --n ); \
00152     } \
00153    else \
00154     { \
00155     this->name = NULL; \
00156     } \
00157   }
00158 
00159   vtkInformationKeySetStringMacro(Name);
00160   vtkInformationKeySetStringMacro(Location);
00161 
00162   // Set/Get the value associated with this key instance in the given
00163   // information object.
00164   void SetAsObjectBase(vtkInformation* info, vtkObjectBase* value);
00165   const vtkObjectBase* GetAsObjectBase(vtkInformation* info) const;
00166   vtkObjectBase* GetAsObjectBase(vtkInformation* info);
00167 
00168   // Report the object associated with this key instance in the given
00169   // information object to the collector.
00170   void ReportAsObjectBase(vtkInformation* info,
00171                           vtkGarbageCollector* collector);
00172 
00173   // Helper for debug leaks support.
00174   void ConstructClass(const char*);
00175 
00176 private:
00177   vtkInformationKey(const vtkInformationKey&);  // Not implemented.
00178   void operator=(const vtkInformationKey&);  // Not implemented.
00179 };
00180 
00181 // Macros to define an information key instance in a C++ source file.
00182 // The corresponding method declaration must appear in the class
00183 // definition in the header file.
00184 #define vtkInformationKeyMacro(CLASS, NAME, type)             \
00185   static vtkInformation##type##Key* CLASS##_##NAME =          \
00186     new vtkInformation##type##Key(#NAME, #CLASS);             \
00187   vtkInformation##type##Key* CLASS::NAME()                    \
00188   {                                                           \
00189     return CLASS##_##NAME;                                    \
00190   }
00191 #define vtkInformationKeySubclassMacro(CLASS, NAME, type, super)    \
00192   static vtkInformation##type##Key* CLASS##_##NAME =          \
00193     new vtkInformation##type##Key(#NAME, #CLASS);             \
00194   vtkInformation##super##Key* CLASS::NAME()                    \
00195   {                                                           \
00196     return CLASS##_##NAME;                                    \
00197   }
00198 #define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required)   \
00199   static vtkInformation##type##Key* CLASS##_##NAME =                    \
00200     new vtkInformation##type##Key(#NAME, #CLASS, required);             \
00201   vtkInformation##type##Key* CLASS::NAME()                              \
00202   {                                                                     \
00203     return CLASS##_##NAME;                                              \
00204   }
00205 
00206 
00207 #endif