SimpleITK  
itkHolderCommand.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#ifndef itkHolderCommand_h
19#define itkHolderCommand_h
20
21#include "itkCommand.h"
22
23namespace itk
24{
25
36template <class T>
38{
39public:
40 using ObjectType = T;
41
44
47
49
50 void
51 Set(const ObjectType object)
52 {
53 this->m_Object = object;
54 }
57 {
58 return this->m_Object;
59 }
60 const ObjectType &
61 Get() const
62 {
63 return this->m_Object;
64 }
65
66 void
68 {}
69 void
70 Execute(const itk::Object *, const itk::EventObject &) override
71 {}
72
73 void
74 operator=(const HolderCommand &) = delete;
75 HolderCommand(const HolderCommand &) = delete;
76
77protected:
78 HolderCommand() = default;
79 ~HolderCommand() override = default;
80
81private:
83};
84
85template <class T>
86class HolderCommand<T *> : public itk::Command
87{
88public:
89 using ObjectType = T;
90
93
96
98
99 void
100 Set(ObjectType * object)
101 {
102 this->m_Object = object;
103 }
104 ObjectType *
106 {
107 return this->m_Object;
108 }
109 const ObjectType *
110 Get() const
111 {
112 return this->m_Object;
113 }
114
115 void
117 {}
118 void
119 Execute(const itk::Object *, const itk::EventObject &) override
120 {}
121
122 void
123 operator=(const HolderCommand &) = delete;
124 HolderCommand(const HolderCommand &) = delete;
125
126protected:
128 : m_Object(nullptr) {};
129 ~HolderCommand() override { delete m_Object; }
130
131private:
133};
134
135} // namespace itk
136
137#endif
void Execute(const itk::Object *, const itk::EventObject &) override
itkNewMacro(HolderCommand)
void Execute(itk::Object *, const itk::EventObject &) override
const ObjectType * Get() const
itk::SmartPointer< const Self > ConstPointer
HolderCommand(const HolderCommand &)=delete
void operator=(const HolderCommand &)=delete
void Set(ObjectType *object)
itk::SmartPointer< Self > Pointer
void operator=(const HolderCommand &)=delete
void Execute(itk::Object *, const itk::EventObject &) override
void Execute(const itk::Object *, const itk::EventObject &) override
const ObjectType & Get() const
itk::Command Superclass
itkNewMacro(HolderCommand)
itk::SmartPointer< Self > Pointer
void Set(const ObjectType object)
HolderCommand(const HolderCommand &)=delete
~HolderCommand() override=default
HolderCommand()=default
itk::SmartPointer< const Self > ConstPointer