SimpleITK  2.0.0
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 
23 namespace itk {
24 
35 template< class T >
37  : public itk::Command
38 {
39 public:
40  using ObjectType = T;
41 
44 
47 
49 
50  void Set(const ObjectType object) { this->m_Object = object; }
51  ObjectType &Get() {return this->m_Object;}
52  const ObjectType &Get() const {return this->m_Object;}
53 
54  void Execute(itk::Object*, const itk::EventObject&) override {}
55  void Execute(const itk::Object*, const itk::EventObject&) override {}
56 
57  void operator=(const HolderCommand&) = delete;
58  HolderCommand(const HolderCommand&) = delete;
59 
60 protected:
61  HolderCommand() = default;
62  ~HolderCommand() override = default;
63 
64 private:
66 
67 };
68 
69 template< class T >
70 class HolderCommand<T*>
71  : public itk::Command
72 {
73 public:
74  using ObjectType = T;
75 
78 
81 
82  itkNewMacro( HolderCommand );
83 
84  void Set(ObjectType *object) { this->m_Object = object; }
85  ObjectType *Get() {return this->m_Object;}
86  const ObjectType *Get() const {return this->m_Object;}
87 
88  void Execute(itk::Object*, const itk::EventObject&) override {}
89  void Execute(const itk::Object*, const itk::EventObject&) override {}
90 
91  void operator=(const HolderCommand&) = delete;
92  HolderCommand(const HolderCommand&) = delete;
93 
94 protected:
95  HolderCommand() : m_Object(nullptr) {};
96  ~HolderCommand() override { delete m_Object;}
97 
98 private:
99 
101 
102 };
103 
104 } // end namespace
105 
106 #endif
itk::HolderCommand< T * >::Get
const ObjectType * Get() const
Definition: itkHolderCommand.h:86
itk::HolderCommand::~HolderCommand
~HolderCommand() override=default
itk::HolderCommand< T * >::HolderCommand
HolderCommand()
Definition: itkHolderCommand.h:95
itk::SmartPointer< Self >
itk::HolderCommand< T * >::Set
void Set(ObjectType *object)
Definition: itkHolderCommand.h:84
itk::HolderCommand::Set
void Set(const ObjectType object)
Definition: itkHolderCommand.h:50
itk::HolderCommand< T * >::m_Object
ObjectType * m_Object
Definition: itkHolderCommand.h:100
itk::HolderCommand::Get
ObjectType & Get()
Definition: itkHolderCommand.h:51
itk::Command
itk::Command
class ITK_FORWARD_EXPORT Command
itk::HolderCommand< T * >::Execute
void Execute(itk::Object *, const itk::EventObject &) override
Definition: itkHolderCommand.h:88
itk::HolderCommand::itkNewMacro
itkNewMacro(HolderCommand)
itk::HolderCommand::ObjectType
T ObjectType
Definition: itkHolderCommand.h:40
itk::HolderCommand::operator=
void operator=(const HolderCommand &)=delete
itk::HolderCommand
An ITK Command class to hold a object until destruction.
Definition: itkHolderCommand.h:36
itk::HolderCommand::Execute
void Execute(const itk::Object *, const itk::EventObject &) override
Definition: itkHolderCommand.h:55
itk::HolderCommand< T * >::Execute
void Execute(const itk::Object *, const itk::EventObject &) override
Definition: itkHolderCommand.h:89
itk::HolderCommand::Execute
void Execute(itk::Object *, const itk::EventObject &) override
Definition: itkHolderCommand.h:54
itk::HolderCommand< T * >::Get
ObjectType * Get()
Definition: itkHolderCommand.h:85
itk::HolderCommand::HolderCommand
HolderCommand()=default
itk
itk::HolderCommand::m_Object
ObjectType m_Object
Definition: itkHolderCommand.h:65
itk::Object
itk::HolderCommand< T * >::ObjectType
T ObjectType
Definition: itkHolderCommand.h:74
itk::EventObject
itkCommand.h
itk::HolderCommand::Get
const ObjectType & Get() const
Definition: itkHolderCommand.h:52
itk::HolderCommand< T * >::~HolderCommand
~HolderCommand() override
Definition: itkHolderCommand.h:96