ITK  5.2.0
Insight Toolkit
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  * 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 itkOptimizerParameters_h
19 #define itkOptimizerParameters_h
20 
21 #include "itkArray.h"
23 
24 #include <memory> // For unique_ptr.
25 
26 namespace itk
27 {
35 template <typename TParametersValueType>
36 class ITK_TEMPLATE_EXPORT OptimizerParameters : public Array<TParametersValueType>
37 {
38 public:
40  using ValueType = TParametersValueType;
46 
50 
53  OptimizerParameters() = default;
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 
71  explicit OptimizerParameters(SizeValueType dimension)
72  : Array<TParametersValueType>(dimension)
73  {}
74 
77  : Array<TParametersValueType>(array)
78  {}
79 
81  void
83  {
84  // Set the default OptimizerParametersHelper
85  this->m_Helper.reset(new OptimizerParametersHelperType);
86  }
87 
88 
94  virtual void
95  MoveDataPointer(TParametersValueType * pointer)
96  {
97  if (m_Helper == nullptr)
98  {
99  itkGenericExceptionMacro("OptimizerParameters::MoveDataPointer: "
100  "m_Helper must be set.");
101  }
102  this->m_Helper->MoveDataPointer(this, pointer);
103  }
105 
110  virtual void
112  {
113  if (m_Helper == nullptr)
114  {
115  itkGenericExceptionMacro("OptimizerParameters::SetParameterObject: "
116  "m_Helper must be set.");
117  }
118  this->m_Helper->SetParametersObject(this, object);
119  }
121 
127  virtual void
129  {
130  this->m_Helper.reset(helper);
131  }
132 
134  OptimizerParametersHelperType *
136  {
137  return m_Helper.get();
138  }
139 
145  const Self &
146  operator=(const Self & rhs)
147  {
148  // Note: there's no need to copy the OptimizerParametersHelper.
149  // Call the superclass implementation.
150  this->ArrayType::operator=(rhs);
151  return *this;
152  }
154 
155  const Self &
156  operator=(const ArrayType & rhs)
157  {
158  // Call the superclass implementation
159  this->ArrayType::operator=(rhs);
160  return *this;
161  }
162 
163  const Self &
165  {
166  // Call the superclass implementation
167  this->ArrayType::operator=(rhs);
168  return *this;
169  }
170 
171  ~OptimizerParameters() override = default;
172 
173 private:
174  std::unique_ptr<OptimizerParametersHelperType> m_Helper{ new OptimizerParametersHelperType };
175 };
176 
177 } // namespace itk
178 
179 #endif
itkOptimizerParametersHelper.h
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:36
itk::OptimizerParameters::SetParametersObject
virtual void SetParametersObject(LightObject *object)
Definition: itkOptimizerParameters.h:111
itk::OptimizerParameters::SetHelper
virtual void SetHelper(OptimizerParametersHelperType *helper)
Definition: itkOptimizerParameters.h:128
itk::OptimizerParameters::operator=
const Self & operator=(const ArrayType &rhs)
Definition: itkOptimizerParameters.h:156
itk::OptimizerParameters::MoveDataPointer
virtual void MoveDataPointer(TParametersValueType *pointer)
Definition: itkOptimizerParameters.h:95
itk::OptimizerParameters::operator=
const Self & operator=(const Self &rhs)
Definition: itkOptimizerParameters.h:146
itk::Array< TInternalComputationValueType >::SizeValueType
typename vnl_vector< TInternalComputationValueType >::size_type SizeValueType
Definition: itkArray.h:55
itk::OptimizerParameters::OptimizerParameters
OptimizerParameters(const ArrayType &array)
Definition: itkOptimizerParameters.h:76
itk::Array< TInternalComputationValueType >::VnlVectorType
vnl_vector< TInternalComputationValueType > VnlVectorType
Definition: itkArray.h:54
itk::OptimizerParametersHelper
Basic helper class to manage parameter data as an Array type, the default type.
Definition: itkOptimizerParametersHelper.h:34
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::OptimizerParameters::operator=
const Self & operator=(const VnlVectorType &rhs)
Definition: itkOptimizerParameters.h:164
itk::OptimizerParameters::OptimizerParameters
OptimizerParameters(SizeValueType dimension)
Definition: itkOptimizerParameters.h:71
itkArray.h
itk::Array< TInternalComputationValueType >::ValueType
TInternalComputationValueType ValueType
Definition: itkArray.h:52
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::OptimizerParameters::OptimizerParameters
OptimizerParameters(const OptimizerParameters &rhs)
Definition: itkOptimizerParameters.h:60
itk::OptimizerParameters::Initialize
void Initialize()
Definition: itkOptimizerParameters.h:82
itk::OptimizerParameters::GetHelper
OptimizerParametersHelperType * GetHelper()
Definition: itkOptimizerParameters.h:135
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83