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 =========================================================================*/
29 #ifndef vtkInformationKey_h
30 #define vtkInformationKey_h
31 
32 #include "vtkCommonCoreModule.h" // For export macro
33 #include "vtkObjectBase.h"
34 #include "vtkObject.h" // Need vtkTypeMacro
35 
36 class vtkInformation;
37 
38 class VTKCOMMONCORE_EXPORT vtkInformationKey : public vtkObjectBase
39 {
40 public:
41  vtkBaseTypeMacro(vtkInformationKey,vtkObjectBase);
42  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
43 
47  void Register(vtkObjectBase*) VTK_OVERRIDE;
48 
52  void UnRegister(vtkObjectBase*) VTK_OVERRIDE;
53 
58  const char* GetName();
59 
64  const char* GetLocation();
65 
67 
74  vtkInformationKey(const char* name, const char* location);
75  ~vtkInformationKey() VTK_OVERRIDE;
77 
83  virtual void ShallowCopy(vtkInformation* from, vtkInformation* to)=0;
84 
91  virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
92  { this->ShallowCopy(from, to); }
93 
97  virtual int Has(vtkInformation* info);
98 
102  virtual void Remove(vtkInformation* info);
103 
107  virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
108 
110 
113  void Print(vtkInformation* info);
114  virtual void Print(ostream& os, vtkInformation* info);
116 
126  virtual bool NeedToExecute(vtkInformation* vtkNotUsed(pipelineInfo),
127  vtkInformation* vtkNotUsed(dobjInfo)) {return false;}
128 
143  virtual void StoreMetaData(vtkInformation* vtkNotUsed(request),
144  vtkInformation* vtkNotUsed(pipelineInfo),
145  vtkInformation* vtkNotUsed(dobjInfo)) {}
146 
155  virtual void CopyDefaultInformation(vtkInformation* vtkNotUsed(request),
156  vtkInformation* vtkNotUsed(fromInfo),
157  vtkInformation* vtkNotUsed(toInfo)) {}
158 
159 protected:
160  char* Name;
161  char* Location;
162 
163 #define vtkInformationKeySetStringMacro(name) \
164 virtual void Set##name (const char* _arg) \
165 { \
166  if ( this->name == NULL && _arg == NULL) { return;} \
167  if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
168  delete [] this->name; \
169  if (_arg) \
170  { \
171  size_t n = strlen(_arg) + 1; \
172  char *cp1 = new char[n]; \
173  const char *cp2 = (_arg); \
174  this->name = cp1; \
175  do { *cp1++ = *cp2++; } while ( --n ); \
176  } \
177  else \
178  { \
179  this->name = NULL; \
180  } \
181 }
182 
185 
186  // Set/Get the value associated with this key instance in the given
187  // information object.
188  void SetAsObjectBase(vtkInformation* info, vtkObjectBase* value);
189  const vtkObjectBase* GetAsObjectBase(vtkInformation* info) const;
190  vtkObjectBase* GetAsObjectBase(vtkInformation* info);
191 
192  // Report the object associated with this key instance in the given
193  // information object to the collector.
194  void ReportAsObjectBase(vtkInformation* info,
195  vtkGarbageCollector* collector);
196 
197  // Helper for debug leaks support.
198  void ConstructClass(const char*);
199 
200 private:
201  vtkInformationKey(const vtkInformationKey&) VTK_DELETE_FUNCTION;
202  void operator=(const vtkInformationKey&) VTK_DELETE_FUNCTION;
203 };
204 
205 // Macros to define an information key instance in a C++ source file.
206 // The corresponding method declaration must appear in the class
207 // definition in the header file.
208 #define vtkInformationKeyMacro(CLASS, NAME, type) \
209  static vtkInformation##type##Key* CLASS##_##NAME = \
210  new vtkInformation##type##Key(#NAME, #CLASS); \
211  vtkInformation##type##Key* CLASS::NAME() \
212  { \
213  return CLASS##_##NAME; \
214  }
215 #define vtkInformationKeySubclassMacro(CLASS, NAME, type, super) \
216  static vtkInformation##type##Key* CLASS##_##NAME = \
217  new vtkInformation##type##Key(#NAME, #CLASS); \
218  vtkInformation##super##Key* CLASS::NAME() \
219  { \
220  return CLASS##_##NAME; \
221  }
222 #define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required) \
223  static vtkInformation##type##Key* CLASS##_##NAME = \
224  new vtkInformation##type##Key(#NAME, #CLASS, required); \
225  vtkInformation##type##Key* CLASS::NAME() \
226  { \
227  return CLASS##_##NAME; \
228  }
229 
230 
231 #endif
virtual void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
Duplicate (new instance created) the entry associated with this key from one information object to an...
Store vtkAlgorithm input/output information.
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
#define vtkInformationKeySetStringMacro(name)
virtual bool NeedToExecute(vtkInformation *vtkNotUsed(pipelineInfo), vtkInformation *vtkNotUsed(dobjInfo))
This function is only relevant when the pertaining key is used in a VTK pipeline. ...
Detect and break reference loops.
Superclass for vtkInformation keys.
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void StoreMetaData(vtkInformation *vtkNotUsed(request), vtkInformation *vtkNotUsed(pipelineInfo), vtkInformation *vtkNotUsed(dobjInfo))
This function is only relevant when the pertaining key is used in a VTK pipeline. ...
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
virtual void CopyDefaultInformation(vtkInformation *vtkNotUsed(request), vtkInformation *vtkNotUsed(fromInfo), vtkInformation *vtkNotUsed(toInfo))
This function is only relevant when the pertaining key is used in a VTK pipeline. ...
void Print(ostream &os)
Print an object to an ostream.