SimpleITK  
sitkObjectOwnedBase.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 sitkObjectOwnedBase_h
19 #define sitkObjectOwnedBase_h
20 
21 
22 #include "sitkCommon.h"
23 #include "sitkNonCopyable.h"
24 
25 #include <map>
26 #include <functional>
27 
28 
29 namespace itk
30 {
31 
32 class Object;
33 
34 namespace simple
35 {
36 
48 {
49 public:
50  virtual ~ObjectOwnedBase()
51 #ifndef SWIGR
52  = 0
53 #endif
54  ;
55 
56  ObjectOwnedBase() = default;
57 
59  virtual std::string
60  GetName() const;
61 
63  virtual void
64  SetName(const std::string & name);
65 
66 protected:
75 
76 
77 #ifndef SWIG
78 
84  virtual size_t
85  AddObjectCallback(itk::Object * o, std::function<void()> onDelete);
86 
87  virtual size_t
88  RemoveObject(const itk::Object *);
89 
90 
99  virtual void
100  SetOwnedByObjects(bool o);
101  virtual bool
102  GetOwnedByObjects() const;
103  virtual void
104  OwnedByObjectsOn();
105  virtual void
106  OwnedByObjectsOff();
108 #endif
109 
110 
111 private:
112  void
113  ExecuteCallbacks(void);
114 
115  bool m_OwnedByObjects{ false };
116  std::multimap<itk::Object *, std::function<void()>> m_ReferencedObjectsCallbacks;
117  std::string m_Name;
118 };
119 
120 } // namespace simple
121 } // namespace itk
122 #endif
sitkNonCopyable.h
sitkCommon.h
itk::simple::ObjectOwnedBase::m_Name
std::string m_Name
Definition: sitkObjectOwnedBase.h:117
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::NonCopyable
An inheritable class to disable copying of a class.
Definition: sitkNonCopyable.h:49
itk
itk::simple::ObjectOwnedBase::m_ReferencedObjectsCallbacks
std::multimap< itk::Object *, std::function< void()> > m_ReferencedObjectsCallbacks
Definition: sitkObjectOwnedBase.h:116
itk::Object
itk::simple::ObjectOwnedBase
An abstract base class to connect this object with the lifetime of another.
Definition: sitkObjectOwnedBase.h:47