1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
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 #include "itkCommand.h"
19 
20 namespace itk
21 {
22   Command::Command() = default;
23 
24   Command::~Command() = default;
25 
CStyleCommand()26   CStyleCommand::CStyleCommand()
27 
28   {}
29 
~CStyleCommand()30   CStyleCommand::~CStyleCommand()
31     {
32     if ( m_ClientDataDeleteCallback )
33       {
34       m_ClientDataDeleteCallback(m_ClientData);
35       }
36     }
37 
SetClientData(void * cd)38   void CStyleCommand::SetClientData(void *cd)
39     {
40     m_ClientData = cd;
41     }
SetCallback(FunctionPointer f)42   void CStyleCommand::SetCallback(FunctionPointer f)
43     {
44     m_Callback = f;
45     }
SetConstCallback(ConstFunctionPointer f)46   void CStyleCommand::SetConstCallback(ConstFunctionPointer f)
47     {
48     m_ConstCallback = f;
49     }
SetClientDataDeleteCallback(DeleteDataFunctionPointer f)50   void CStyleCommand::SetClientDataDeleteCallback(DeleteDataFunctionPointer f)
51     {
52     m_ClientDataDeleteCallback = f;
53     }
54 
Execute(Object * caller,const EventObject & event)55   void CStyleCommand::Execute(Object *caller, const EventObject & event)
56     {
57     if ( m_Callback )
58       {
59       m_Callback(caller, event, m_ClientData);
60       }
61     }
62 
Execute(const Object * caller,const EventObject & event)63   void CStyleCommand::Execute(const Object *caller, const EventObject & event)
64     {
65     if ( m_ConstCallback )
66       {
67       m_ConstCallback(caller, event, m_ClientData);
68       }
69     }
70 }
71