File: vtkInformationDataObjectKey.cxx

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (60 lines) | stat: -rw-r--r-- 2,668 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkInformationDataObjectKey.h"

// This file does not include vtkDataObject.h, because doing so introduces a
// dependency cycle between CommonCore and CommonDataModel that complicates
// both compilation and linking.  For example, some tools such as UBSan
// complain about undefined symbols for "typeinfo for vtkDataObject" when
// building the vtkCommonCore library.

// Since vtkDataObject.h is not included, static_cast<> cannot be used to cast
// between vtkObjectBase* and vtkDataObject*, and reinterpret_cast<> is used
// instead.  This is done on the assumption that, for single-inheritance,
// the address of an object is not changed by upcasting or downcasting.  The
// C++ standard does not guarantee this to be true, but every compiler that
// is supported by VTK implements single-inheritance polymorphism this way.

//------------------------------------------------------------------------------
VTK_ABI_NAMESPACE_BEGIN
vtkInformationDataObjectKey::vtkInformationDataObjectKey(const char* name, const char* location)
  : vtkInformationKey(name, location)
{
  vtkCommonInformationKeyManager::Register(this);
}

//------------------------------------------------------------------------------
vtkInformationDataObjectKey::~vtkInformationDataObjectKey() = default;

//------------------------------------------------------------------------------
void vtkInformationDataObjectKey::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);
}

//------------------------------------------------------------------------------
void vtkInformationDataObjectKey::Set(vtkInformation* info, vtkDataObject* value)
{
  // see comments at top of file regarding the reinterpret_cast
  this->SetAsObjectBase(info, reinterpret_cast<vtkObjectBase*>(value));
}

//------------------------------------------------------------------------------
vtkDataObject* vtkInformationDataObjectKey::Get(vtkInformation* info)
{
  // see comments at top of file regarding the reinterpret_cast
  return reinterpret_cast<vtkDataObject*>(this->GetAsObjectBase(info));
}

//------------------------------------------------------------------------------
void vtkInformationDataObjectKey::ShallowCopy(vtkInformation* from, vtkInformation* to)
{
  this->Set(to, this->Get(from));
}

//------------------------------------------------------------------------------
void vtkInformationDataObjectKey::Report(vtkInformation* info, vtkGarbageCollector* collector)
{
  this->ReportAsObjectBase(info, collector);
}
VTK_ABI_NAMESPACE_END