VTK  9.1.0
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 "vtkObject.h" // Need vtkTypeMacro
34#include "vtkObjectBase.h"
35
36class vtkInformation;
37
38class VTKCOMMONCORE_EXPORT vtkInformationKey : public vtkObjectBase
39{
40public:
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
47 void Register(vtkObjectBase*) override;
48
52 void UnRegister(vtkObjectBase*) override;
53
58 const char* GetName();
59
64 const char* GetLocation();
65
67
74 vtkInformationKey(const char* name, const char* location);
77
83 virtual void ShallowCopy(vtkInformation* from, vtkInformation* to) = 0;
84
91 virtual void DeepCopy(vtkInformation* from, vtkInformation* to) { this->ShallowCopy(from, to); }
92
96 virtual int Has(vtkInformation* info);
97
101 virtual void Remove(vtkInformation* info);
102
106 virtual void Report(vtkInformation* info, vtkGarbageCollector* collector);
107
109
113 virtual void Print(ostream& os, vtkInformation* info);
115
125 virtual bool NeedToExecute(
126 vtkInformation* vtkNotUsed(pipelineInfo), vtkInformation* vtkNotUsed(dobjInfo))
127 {
128 return false;
129 }
130
145 virtual void StoreMetaData(vtkInformation* vtkNotUsed(request),
146 vtkInformation* vtkNotUsed(pipelineInfo), vtkInformation* vtkNotUsed(dobjInfo))
147 {
148 }
149
158 virtual void CopyDefaultInformation(vtkInformation* vtkNotUsed(request),
159 vtkInformation* vtkNotUsed(fromInfo), vtkInformation* vtkNotUsed(toInfo))
160 {
161 }
162
163protected:
164 char* Name;
165 char* Location;
166
167#define vtkInformationKeySetStringMacro(name) \
168 virtual void Set##name(const char* _arg) \
169 { \
170 if (this->name == nullptr && _arg == nullptr) \
171 { \
172 return; \
173 } \
174 if (this->name && _arg && (!strcmp(this->name, _arg))) \
175 { \
176 return; \
177 } \
178 delete[] this->name; \
179 if (_arg) \
180 { \
181 size_t n = strlen(_arg) + 1; \
182 char* cp1 = new char[n]; \
183 const char* cp2 = (_arg); \
184 this->name = cp1; \
185 do \
186 { \
187 *cp1++ = *cp2++; \
188 } while (--n); \
189 } \
190 else \
191 { \
192 this->name = nullptr; \
193 } \
194 }
195
198
199 // Set/Get the value associated with this key instance in the given
200 // information object.
204
205 // Report the object associated with this key instance in the given
206 // information object to the collector.
208
209 // Helper for debug leaks support.
210 void ConstructClass(const char*);
211
212private:
213 vtkInformationKey(const vtkInformationKey&) = delete;
214 void operator=(const vtkInformationKey&) = delete;
215};
216
217// Macros to define an information key instance in a C++ source file.
218// The corresponding method declaration must appear in the class
219// definition in the header file.
220#define vtkInformationKeyMacro(CLASS, NAME, type) \
221 static vtkInformation##type##Key* CLASS##_##NAME = new vtkInformation##type##Key(#NAME, #CLASS); \
222 vtkInformation##type##Key* CLASS::NAME() { return CLASS##_##NAME; }
223#define vtkInformationKeySubclassMacro(CLASS, NAME, type, super) \
224 static vtkInformation##type##Key* CLASS##_##NAME = new vtkInformation##type##Key(#NAME, #CLASS); \
225 vtkInformation##super##Key* CLASS::NAME() { return CLASS##_##NAME; }
226#define vtkInformationKeyRestrictedMacro(CLASS, NAME, type, required) \
227 static vtkInformation##type##Key* CLASS##_##NAME = \
228 new vtkInformation##type##Key(#NAME, #CLASS, required); \
229 vtkInformation##type##Key* CLASS::NAME() { return CLASS##_##NAME; }
230
231#endif
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:113
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
Key instances are static data that need to be created and destroyed.
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 DeepCopy(vtkInformation *from, vtkInformation *to)
Duplicate (new instance created) the entry associated with this key from one information object to an...
virtual void Remove(vtkInformation *info)
Remove this key from the given information object.
void ConstructClass(const char *)
virtual void ShallowCopy(vtkInformation *from, vtkInformation *to)=0
Copy the entry associated with this key from one information object to another.
virtual void Print(ostream &os, vtkInformation *info)
Print the key's value in an information object to a stream.
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
void operator=(const vtkObjectBase &)
@ location
Definition: vtkX3D.h:412
@ info
Definition: vtkX3D.h:382
@ value
Definition: vtkX3D.h:226
@ name
Definition: vtkX3D.h:225