Loading...
Searching...
No Matches
elxDefaultConstruct.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef elxDefaultConstruct_h
#define elxDefaultConstruct_h
#include <itkLightObject.h>
#include <cassert>
namespace elastix
{
template <typename TObject>
class DefaultConstruct : public TObject
{
public:
ITK_DISALLOW_COPY_AND_MOVE(DefaultConstruct);
DefaultConstruct() = default;
~DefaultConstruct() override
{
// Note: This assertion may fail when a filter is default-constructed _before_ its input, e.g.:
//
// {
// DefaultConstruct<itk::TransformixFilter<ImageType>> transformixFilter{};
// DefaultConstruct<ImageType> movingImage{};
// transformixFilter.SetMovingImage(&movingImage);
// } // <== Assertion failure!
//
// Such a failure may be solved by reordering the declarations (declaring the input first), or by declaring the
// input by their static `New()` member function (instead of by `DefaultConstruct`).
assert(this->itk::LightObject::m_ReferenceCount == 1);
// Suppress warning "Trying to delete object with non-zero reference count."
this->itk::LightObject::m_ReferenceCount = 0;
}
};
} // namespace elastix
#endif
TObject
elastix::DefaultConstruct::DefaultConstruct
DefaultConstruct()=default
Public default-constructor. Just calls the (typically protected) default-constructor of TObject.
elastix::DefaultConstruct::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(DefaultConstruct)
elastix::DefaultConstruct::~DefaultConstruct
~DefaultConstruct() override
Public destructor. Just calls the (typically protected) destructor of TObject.
Definition elxDefaultConstruct.h:44
elastix
Definition elxDefaultConstruct.h:25

Generated on 1768596610 for elastix by 1.15.0 |