ITK  5.2.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  * http://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 
34 namespace itk
35 {
65 template <typename T>
66 class ITK_TEMPLATE_EXPORT DataObjectDecorator : public DataObject
67 {
68 public:
69  ITK_DISALLOW_COPY_AND_MOVE(DataObjectDecorator);
70 
76 
78  using ComponentType = T;
79  using ComponentPointer = typename T::Pointer;
80  using ComponentConstPointer = typename T::ConstPointer;
81 
83  itkNewMacro(Self);
84 
86  itkTypeMacro(DataObjectDecorator, DataObject);
87 
89  virtual void
90  Set(const ComponentType * val);
91 
93  virtual const ComponentType *
94  Get() const;
95  virtual ComponentType *
96  GetModifiable();
98 
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  }
137 
138 protected:
139  DataObjectDecorator() = default;
140  ~DataObjectDecorator() override = default;
141  void
142  PrintSelf(std::ostream & os, Indent indent) const override;
143 
144 protected:
145 private:
147 };
148 } // end namespace itk
149 
150 #ifndef ITK_MANUAL_INSTANTIATION
151 # include "itkDataObjectDecorator.hxx"
152 #endif
153 
154 #endif
itkObjectFactory.h
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itk::DataObjectDecorator::m_Component
ComponentPointer m_Component
Definition: itkDataObjectDecorator.h:146
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkDataObject.h
itk::DataObjectDecorator::Get
virtual const ComponentType * Get() const
itk::DataObjectDecorator
Decorates any subclass of itkObject with a DataObject API.
Definition: itkDataObjectDecorator.h:66
itk::DataObjectDecorator::ComponentType
T ComponentType
Definition: itkDataObjectDecorator.h:78
itk::DataObjectDecorator::ComponentConstPointer
typename T::ConstPointer ComponentConstPointer
Definition: itkDataObjectDecorator.h:80
itk::DataObject
class ITK_FORWARD_EXPORT DataObject
Definition: itkDataObject.h:42
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DataObjectDecorator::Graft
void Graft(const DataObjectDecorator< TOther > *decorator)
Definition: itkDataObjectDecorator.h:127
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::DataObjectDecorator::ComponentPointer
typename T::Pointer ComponentPointer
Definition: itkDataObjectDecorator.h:79
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293