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=========================================================================*/
32#ifndef vtkInformationKey_h
33#define vtkInformationKey_h
34
35#include "vtkCommonCoreModule.h" // For export macro
36#include "vtkObjectBase.h"
37#include "vtkObject.h" // Need vtkTypeMacro
38
39class vtkInformation;
40
41class VTKCOMMONCORE_EXPORT vtkInformationKey : public vtkObjectBase
42{
43public:
45 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
46
50 void Register(vtkObjectBase*) VTK_OVERRIDE;
51
55 void UnRegister(vtkObjectBase*) VTK_OVERRIDE;
56
61 const char* GetName();
62
67 const char* GetLocation();
68
70
77 vtkInformationKey(const char* name, const char* location);
78 ~vtkInformationKey() VTK_OVERRIDE;
80
86 virtual void ShallowCopy(vtkInformation* from, vtkInformation* to)=0;
87
94 virtual void DeepCopy(vtkInformation *from, vtkInformation *to)
95 { this->ShallowCopy(from, to); }
96
100 virtual int Has(vtkInformation* info);
101
105 virtual void Remove(vtkInformation* info);
106
110 virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
111
113
117 virtual void Print(ostream& os, vtkInformation* info);
119
129 virtual bool NeedToExecute(vtkInformation* vtkNotUsed(pipelineInfo),
130 vtkInformation* vtkNotUsed(dobjInfo)) {return false;}
131
146 virtual void StoreMetaData(vtkInformation* vtkNotUsed(request),
147 vtkInformation* vtkNotUsed(pipelineInfo),
148 vtkInformation* vtkNotUsed(dobjInfo)) {}
149
158 virtual void CopyDefaultInformation(vtkInformation* vtkNotUsed(request),
159 vtkInformation* vtkNotUsed(fromInfo),
160 vtkInformation* vtkNotUsed(toInfo)) {}
161
162protected:
163 char* Name;
164 char* Location;
165
166#define vtkInformationKeySetStringMacro(name) \
167virtual void Set##name (const char* _arg) \
168{ \
169 if ( this->name == NULL && _arg == NULL) { return;} \
170 if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
171 delete [] this->name; \
172 if (_arg) \
173 { \
174 size_t n = strlen(_arg) + 1; \
175 char *cp1 = new char[n]; \
176 const char *cp2 = (_arg); \
177 this->name = cp1; \
178 do { *cp1++ = *cp2++; } while ( --n ); \
179 } \
180 else \
181 { \
182 this->name = NULL; \
183 } \
184}
185
188
189 // Set/Get the value associated with this key instance in the given
190 // information object.
194
195 // Report the object associated with this key instance in the given
196 // information object to the collector.
198 vtkGarbageCollector* collector);
199
200 // Helper for debug leaks support.
201 void ConstructClass(const char*);
202
203private:
204 vtkInformationKey(const vtkInformationKey&) VTK_DELETE_FUNCTION;
205 void operator=(const vtkInformationKey&) VTK_DELETE_FUNCTION;
206};
207
208// Macros to define an information key instance in a C++ source file.
209// The corresponding method declaration must appear in the class
210// definition in the header file.
211#define vtkInformationKeyMacro(CLASS, NAME, type) \
212 static vtkInformation##type##Key* CLASS##_##NAME = \
213 new vtkInformation##type##Key(#NAME, #CLASS); \
214 vtkInformation##type##Key* CLASS::NAME() \
215 { \
216 return CLASS##_##NAME; \
217 }
218#define vtkInformationKeySubclassMacro(CLASS, NAME, type, super) \
219 static vtkInformation##type##Key* CLASS##_##NAME = \
220 new vtkInformation##type##Key(#NAME, #CLASS); \
221 vtkInformation##super##Key* CLASS::NAME() \
222 { \
223 return CLASS##_##NAME; \
224 }
225#define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required) \
226 static vtkInformation##type##Key* CLASS##_##NAME = \
227 new vtkInformation##type##Key(#NAME, #CLASS, required); \
228 vtkInformation##type##Key* CLASS::NAME() \
229 { \
230 return CLASS##_##NAME; \
231 }
232
233
234#endif
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:40
Superclass for vtkInformation keys.
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.
virtual void Report(vtkInformation *info, vtkGarbageCollector *collector)
Report a reference this key has in the given information object.
void ReportAsObjectBase(vtkInformation *info, vtkGarbageCollector *collector)
vtkInformationKeySetStringMacro(Location)
void Print(vtkInformation *info)
Print the key's value in an information object to a stream.
vtkBaseTypeMacro(vtkInformationKey, vtkObjectBase)
vtkInformationKeySetStringMacro(Name)
vtkObjectBase * GetAsObjectBase(vtkInformation *info)
void UnRegister(vtkObjectBase *) override
Prevent normal vtkObject reference counting behavior.
~vtkInformationKey() override
void SetAsObjectBase(vtkInformation *info, vtkObjectBase *value)
const char * GetName()
Get the name of the key.
const char * GetLocation()
Get the location of the key.
vtkInformationKey(const char *name, const char *location)
Key instances are static data that need to be created and destroyed.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int Has(vtkInformation *info)
Check whether this key appears in the given information object.
void Register(vtkObjectBase *) override
Prevent normal vtkObject reference counting behavior.
const vtkObjectBase * GetAsObjectBase(vtkInformation *info) const
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.
virtual bool NeedToExecute(vtkInformation *vtkNotUsed(pipelineInfo), vtkInformation *vtkNotUsed(dobjInfo))
This function is only relevant when the pertaining key is used in a VTK pipeline.
virtual void Remove(vtkInformation *info)
Remove this key from the given information object.
void ConstructClass(const char *)
virtual void Print(ostream &os, vtkInformation *info)
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
void operator=(const vtkObjectBase &)
@ location
Definition: vtkX3D.h:406
@ info
Definition: vtkX3D.h:376
@ value
Definition: vtkX3D.h:220
@ name
Definition: vtkX3D.h:219
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)