VTK
vtkInformationKey.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInformationKey.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 =========================================================================*/
28 #ifndef vtkInformationKey_h
29 #define vtkInformationKey_h
30 
31 #include "vtkCommonCoreModule.h" // For export macro
32 #include "vtkObjectBase.h"
33 #include "vtkObject.h" // Need vtkTypeMacro
34 
35 class vtkInformation;
36 
38 {
39 public:
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
44  virtual void Register(vtkObjectBase*);
45 
47  virtual void UnRegister(vtkObjectBase*);
48 
51  const char* GetName();
52 
55  const char* GetLocation();
56 
58 
63  vtkInformationKey(const char* name, const char* location);
66 
70  virtual void ShallowCopy(vtkInformation* from, vtkInformation* to)=0;
71 
73 
77  virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
78  { this->ShallowCopy(from, to); }
80 
82  virtual int Has(vtkInformation* info);
83 
85  virtual void Remove(vtkInformation* info);
86 
88  virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
89 
91 
92  void Print(vtkInformation* info);
93  virtual void Print(ostream& os, vtkInformation* info);
95 
97 
103  virtual bool NeedToExecute(vtkInformation* vtkNotUsed(pipelineInfo),
104  vtkInformation* vtkNotUsed(dobjInfo)) {return false;}
106 
108 
118  virtual void StoreMetaData(vtkInformation* vtkNotUsed(request),
119  vtkInformation* vtkNotUsed(pipelineInfo),
120  vtkInformation* vtkNotUsed(dobjInfo)) {}
122 
124 
130  virtual void CopyDefaultInformation(vtkInformation* vtkNotUsed(request),
131  vtkInformation* vtkNotUsed(fromInfo),
132  vtkInformation* vtkNotUsed(toInfo)) {}
134 
135 protected:
136  char* Name;
137  char* Location;
138 
139 #define vtkInformationKeySetStringMacro(name) \
140 virtual void Set##name (const char* _arg) \
141  { \
142  if ( this->name == NULL && _arg == NULL) { return;} \
143  if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
144  delete [] this->name; \
145  if (_arg) \
146  { \
147  size_t n = strlen(_arg) + 1; \
148  char *cp1 = new char[n]; \
149  const char *cp2 = (_arg); \
150  this->name = cp1; \
151  do { *cp1++ = *cp2++; } while ( --n ); \
152  } \
153  else \
154  { \
155  this->name = NULL; \
156  } \
157  }
158 
161 
162  // Set/Get the value associated with this key instance in the given
163  // information object.
164  void SetAsObjectBase(vtkInformation* info, vtkObjectBase* value);
165  const vtkObjectBase* GetAsObjectBase(vtkInformation* info) const;
166  vtkObjectBase* GetAsObjectBase(vtkInformation* info);
167 
168  // Report the object associated with this key instance in the given
169  // information object to the collector.
170  void ReportAsObjectBase(vtkInformation* info,
171  vtkGarbageCollector* collector);
172 
173  // Helper for debug leaks support.
174  void ConstructClass(const char*);
175 
176 private:
177  vtkInformationKey(const vtkInformationKey&); // Not implemented.
178  void operator=(const vtkInformationKey&); // Not implemented.
179 };
180 
181 // Macros to define an information key instance in a C++ source file.
182 // The corresponding method declaration must appear in the class
183 // definition in the header file.
184 #define vtkInformationKeyMacro(CLASS, NAME, type) \
185  static vtkInformation##type##Key* CLASS##_##NAME = \
186  new vtkInformation##type##Key(#NAME, #CLASS); \
187  vtkInformation##type##Key* CLASS::NAME() \
188  { \
189  return CLASS##_##NAME; \
190  }
191 #define vtkInformationKeySubclassMacro(CLASS, NAME, type, super) \
192  static vtkInformation##type##Key* CLASS##_##NAME = \
193  new vtkInformation##type##Key(#NAME, #CLASS); \
194  vtkInformation##super##Key* CLASS::NAME() \
195  { \
196  return CLASS##_##NAME; \
197  }
198 #define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required) \
199  static vtkInformation##type##Key* CLASS##_##NAME = \
200  new vtkInformation##type##Key(#NAME, #CLASS, required); \
201  vtkInformation##type##Key* CLASS::NAME() \
202  { \
203  return CLASS##_##NAME; \
204  }
205 
206 
207 #endif
virtual void Register(vtkObjectBase *o)
virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
Store vtkAlgorithm input/output information.
#define VTKCOMMONCORE_EXPORT
virtual void PrintSelf(ostream &os, vtkIndent indent)
#define vtkInformationKeySetStringMacro(name)
virtual bool NeedToExecute(vtkInformation *vtkNotUsed(pipelineInfo), vtkInformation *vtkNotUsed(dobjInfo))
Detect and break reference loops.
Superclass for vtkInformation keys.
virtual void UnRegister(vtkObjectBase *o)
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void StoreMetaData(vtkInformation *vtkNotUsed(request), vtkInformation *vtkNotUsed(pipelineInfo), vtkInformation *vtkNotUsed(dobjInfo))
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
virtual void CopyDefaultInformation(vtkInformation *vtkNotUsed(request), vtkInformation *vtkNotUsed(fromInfo), vtkInformation *vtkNotUsed(toInfo))
void operator=(const vtkObjectBase &)
void Print(ostream &os)