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: m_Helper must be set.");
114 }
115 this->m_Helper->MoveDataPointer(this, pointer);
116 }
117
122 virtual void
124 {
125 if (m_Helper == nullptr)
126 {
127 itkGenericExceptionMacro("OptimizerParameters::SetParameterObject: m_Helper must be set.");
128 }
129 this->m_Helper->SetParametersObject(this, object);
130 }
131
137 virtual void
139 {
140 this->m_Helper.reset(helper);
141 }
142
144 OptimizerParametersHelperType *
146 {
147 return m_Helper.get();
148 }
149
156 Self &
157 operator=(const Self & rhs)
158 {
159 // Note: there's no need to copy the OptimizerParametersHelper.
160 // Call the superclass implementation.
161 this->ArrayType::operator=(rhs);
162 return *this;
163 }
164
165 Self &
166 operator=(const ArrayType & rhs)
167 {
168 // Call the superclass implementation
169 this->ArrayType::operator=(rhs);
170 return *this;
171 }
172
173 Self &
175 {
176 // Call the superclass implementation
177 this->ArrayType::operator=(rhs);
178 return *this;
179 }
180
181
182 ~OptimizerParameters() override = default;
183
184private:
185 std::unique_ptr<OptimizerParametersHelperType> m_Helper{ std::make_unique<OptimizerParametersHelperType>() };
186};
187
188} // namespace itk
189
190#endif
vnl_vector< TParametersValueType > VnlVectorType
Definition itkArray.h:53
typename vnl_vector< TParametersValueType >::size_type SizeValueType
Definition itkArray.h:54
Self & operator=(const Self &rhs)
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
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....