ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkOptimizerParameters.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 * https://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 itkOptimizerParameters_h
19#define itkOptimizerParameters_h
20
21#include "itkArray.h"
23
24#include <memory> // For unique_ptr.
25
26namespace itk
27{
34
35template <typename TParametersValueType>
36class ITK_TEMPLATE_EXPORT OptimizerParameters : public Array<TParametersValueType>
37{
38public:
40 using ValueType = TParametersValueType;
45 using typename Superclass::SizeValueType;
46
50
54
61 : Array<TParametersValueType>(rhs)
62 {
63 // Note: don't copy the OptimizerParametersHelper.
64 // The Array copy constructor will allocate new memory
65 // and copy the data to it. So we end up here with a generic
66 // OptimizerParameters data object even if 'rhs' points to
67 // something different.
68 }
69
74 : Array<TParametersValueType>(dimension)
75 {}
76
79 : Array<TParametersValueType>(array)
80 {}
81
83 explicit OptimizerParameters(const SizeValueType dimension, const ValueType & value)
84 : Array<TParametersValueType>(dimension, value)
85 {}
86
87
89 explicit OptimizerParameters(const ValueType * const inputData, const SizeValueType dimension)
90 : Array<TParametersValueType>(inputData, dimension)
91 {}
92
93
95 void
97 {
98 // Set the default OptimizerParametersHelper
99 this->m_Helper = std::make_unique<OptimizerParametersHelperType>();
100 }
101
102
108 virtual void
109 MoveDataPointer(TParametersValueType * pointer)
110 {
111 if (m_Helper == nullptr)
112 {
113 itkGenericExceptionMacro("OptimizerParameters::MoveDataPointer: "
114 "m_Helper must be set.");
115 }
116 this->m_Helper->MoveDataPointer(this, pointer);
117 }
118
119
124 virtual void
126 {
127 if (m_Helper == nullptr)
128 {
129 itkGenericExceptionMacro("OptimizerParameters::SetParameterObject: "
130 "m_Helper must be set.");
131 }
132 this->m_Helper->SetParametersObject(this, object);
133 }
134
135
141 virtual void
143 {
144 this->m_Helper.reset(helper);
145 }
146
148 OptimizerParametersHelperType *
150 {
151 return m_Helper.get();
152 }
153
159 Self &
160 operator=(const Self & rhs)
161 {
162 // Note: there's no need to copy the OptimizerParametersHelper.
163 // Call the superclass implementation.
164 this->ArrayType::operator=(rhs);
165 return *this;
166 }
167
168
169 Self &
170 operator=(const ArrayType & rhs)
171 {
172 // Call the superclass implementation
173 this->ArrayType::operator=(rhs);
174 return *this;
175 }
176
177 Self &
179 {
180 // Call the superclass implementation
181 this->ArrayType::operator=(rhs);
182 return *this;
183 }
184
185 ~OptimizerParameters() override = default;
186
187private:
188 std::unique_ptr<OptimizerParametersHelperType> m_Helper{ std::make_unique<OptimizerParametersHelperType>() };
189};
190
191} // namespace itk
192
193#endif
vnl_vector< TParametersValueType > VnlVectorType
Definition itkArray.h:54
typename vnl_vector< TParametersValueType >::size_type SizeValueType
Definition itkArray.h:55
Light weight base class for most itk classes.
Basic helper class to manage parameter data as an Array type, the default type.
virtual void SetParametersObject(LightObject *object)
virtual void MoveDataPointer(TParametersValueType *pointer)
OptimizerParameters(const OptimizerParameters &rhs)
Array< TParametersValueType > Superclass
Self & operator=(const ArrayType &rhs)
Self & operator=(const Self &rhs)
Self & operator=(const VnlVectorType &rhs)
~OptimizerParameters() override=default
std::unique_ptr< OptimizerParametersHelperType > m_Helper
OptimizerParametersHelperType * GetHelper()
OptimizerParameters(const ValueType *const inputData, const SizeValueType dimension)
OptimizerParameters(const ArrayType &array)
virtual void SetHelper(OptimizerParametersHelperType *helper)
OptimizerParameters(const SizeValueType dimension, const ValueType &value)
typename Superclass::VnlVectorType VnlVectorType
OptimizerParameters(SizeValueType dimension)
OptimizerParametersHelper< TParametersValueType > OptimizerParametersHelperType
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....