ITK  6.0.0
Insight Toolkit
itkDataObjectDecorator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkDataObjectDecorator_h
29#define itkDataObjectDecorator_h
30
31#include "itkDataObject.h"
32#include "itkObjectFactory.h"
33
34namespace itk
35{
65template <typename T>
66class ITK_TEMPLATE_EXPORT DataObjectDecorator : public DataObject
67{
68public:
69 ITK_DISALLOW_COPY_AND_MOVE(DataObjectDecorator);
70
76
78 using ComponentType = T;
79 using ComponentPointer = typename T::Pointer;
81
83 itkNewMacro(Self);
84
86 itkOverrideGetNameOfClassMacro(DataObjectDecorator);
87
89 virtual void
90 Set(const ComponentType * val);
91
93 virtual const ComponentType *
94 Get() const;
95 virtual ComponentType *
101 GetMTime() const override;
102
106 void
107 Initialize() override;
108
115 void
116 Graft(const DataObject *) override;
117 void
118 Graft(const Self * data);
119
125 template <typename TOther>
126 void
128 {
129 auto * component = const_cast<ComponentType *>(dynamic_cast<const ComponentType *>(decorator->Get()));
130 if (!component)
131 {
132 return;
133 }
134 this->Set(component);
135 }
138protected:
140 ~DataObjectDecorator() override = default;
141 void
142 PrintSelf(std::ostream & os, Indent indent) const override;
143
144protected:
145private:
146 ComponentPointer m_Component{};
147};
148} // end namespace itk
149
150#ifndef ITK_MANUAL_INSTANTIATION
151# include "itkDataObjectDecorator.hxx"
152#endif
153
154#endif
Decorates any subclass of itkObject with a DataObject API.
ModifiedTimeType GetMTime() const override
virtual ComponentType * GetModifiable()
void Graft(const Self *data)
typename T::Pointer ComponentPointer
void Graft(const DataObjectDecorator< TOther > *decorator)
~DataObjectDecorator() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void Set(const ComponentType *val)
virtual const ComponentType * Get() const
typename T::ConstPointer ComponentConstPointer
void Graft(const DataObject *) override
Graft the content of one decorator onto another.
void Initialize() override
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for most ITK classes.
Definition: itkObject.h:62
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105