Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
SuperElastix
Commits
1ce87383
Commit
1ce87383
authored
Feb 02, 2017
by
Floris Berendsen
Browse files
ENH: switched to unique_ptr<Blueprint>
parent
77786d9d
Changes
12
Hide whitespace changes
Inline
Side-by-side
Modules/Components/Elastix/test/selxElastixComponentTest.cxx
View file @
1ce87383
...
...
@@ -42,8 +42,8 @@ class ElastixComponentTest : public ::testing::Test
{
public:
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Shared
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Unique
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
BlueprintITKType
::
Pointer
BlueprintITKPointer
;
typedef
Blueprint
::
ParameterMapType
ParameterMapType
;
typedef
Blueprint
::
ParameterValueType
ParameterValueType
;
...
...
@@ -82,7 +82,6 @@ public:
superElastixFilter
=
nullptr
;
}
// Blueprint holds a configuration for SuperElastix
BlueprintPointer
blueprint
;
SuperElastixFilterCustomComponents
<
RegisterComponents
>::
Pointer
superElastixFilter
;
// Data manager provides the paths to the input and output data for unit tests
DataManagerType
::
Pointer
dataManager
;
...
...
@@ -91,7 +90,7 @@ public:
TEST_F
(
ElastixComponentTest
,
ImagesOnly
)
{
/** make example blueprint configuration */
blueprint
=
BlueprintPointer
(
new
Blueprint
()
);
BlueprintPointer
blueprint
=
BlueprintPointer
(
new
Blueprint
());
ParameterMapType
component0Parameters
;
component0Parameters
[
"NameOfClass"
]
=
{
"ElastixComponent"
};
...
...
@@ -163,7 +162,7 @@ TEST_F( ElastixComponentTest, ImagesOnly )
TEST_F
(
ElastixComponentTest
,
MonolithicElastixTransformix
)
{
/** make example blueprint configuration */
blueprint
=
BlueprintPointer
(
new
Blueprint
());
BlueprintPointer
blueprint
=
BlueprintPointer
(
new
Blueprint
());
blueprint
->
SetComponent
(
"RegistrationMethod"
,
{
{
"NameOfClass"
,
{
"MonolithicElastixComponent"
}
},
{
"RegistrationSettings"
,
{
"rigid"
}
},
{
"MaximumNumberOfIterations"
,
{
"2"
}
},
...
...
Modules/Components/Niftyreg/test/selxNiftyregComponentTest.cxx
View file @
1ce87383
...
...
@@ -33,8 +33,8 @@ class NiftyregComponentTest : public ::testing::Test
{
public:
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Shared
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Unique
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
BlueprintITKType
::
Pointer
BlueprintITKPointer
;
typedef
Blueprint
::
ParameterMapType
ParameterMapType
;
typedef
Blueprint
::
ParameterValueType
ParameterValueType
;
...
...
Modules/Components/itkImageRegistrationMethodv4/test/selxRegistrationItkv4Test.cxx
View file @
1ce87383
...
...
@@ -103,8 +103,8 @@ public:
ItkCompositeTransformComponent
<
double
,
3
>
,
ItkCompositeTransformComponent
<
double
,
2
>>
RegisterComponents
;
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Shared
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
itk
::
Unique
PointerDataObjectDecorator
<
Blueprint
>
BlueprintITKType
;
typedef
BlueprintITKType
::
Pointer
BlueprintITKPointer
;
typedef
SuperElastixFilter
::
BlueprintType
SuperElastixFilterBlueprintType
;
...
...
Modules/Core/ComponentInterface/include/selxNetworkBuilder.h
View file @
1ce87383
...
...
@@ -62,7 +62,7 @@ public:
NetworkBuilder
();
virtual
~
NetworkBuilder
()
{};
virtual
bool
AddBlueprint
(
const
std
::
shared
_ptr
<
Blueprint
>
&
blueprint
);
virtual
bool
AddBlueprint
(
const
std
::
unique
_ptr
<
Blueprint
>
&
blueprint
);
/** Read configuration at the blueprints nodes and edges and return true if all components could be uniquely selected*/
virtual
bool
Configure
();
...
...
@@ -110,7 +110,7 @@ protected:
//NetworkBuilder should be constructed with a blueprint.
//Blueprint::ConstPointer m_Blueprint;
//Blueprint const * m_Blueprint;
std
::
shared
_ptr
<
Blueprint
>
m_Blueprint
;
std
::
unique
_ptr
<
Blueprint
>
m_Blueprint
;
// A selector for each node, that each can hold multiple instantiated components. Ultimately is should be 1 component each.
ComponentSelectorContainerType
m_ComponentSelectorContainer
;
...
...
Modules/Core/ComponentInterface/include/selxNetworkBuilder.hxx
View file @
1ce87383
...
...
@@ -31,9 +31,10 @@ NetworkBuilder<ComponentList>::NetworkBuilder() : m_isConfigured(false)
template
<
typename
ComponentList
>
bool
NetworkBuilder
<
ComponentList
>::
AddBlueprint
(
const
std
::
shared
_ptr
<
Blueprint
>
&
blueprint
)
NetworkBuilder
<
ComponentList
>::
AddBlueprint
(
const
std
::
unique
_ptr
<
Blueprint
>
&
blueprint
)
{
m_Blueprint
=
std
::
make_shared
<
Blueprint
>
(
*
blueprint
);
m_Blueprint
->
ComposeWith
(
blueprint
);
//m_Blueprint = std::make_shared< Blueprint >(*blueprint);
return
true
;
}
...
...
Modules/Core/ComponentInterface/include/selxNetworkBuilderBase.h
View file @
1ce87383
...
...
@@ -64,7 +64,7 @@ public:
virtual
~
NetworkBuilderBase
()
{};
virtual
bool
AddBlueprint
(
const
std
::
shared
_ptr
<
Blueprint
>
&
blueprint
)
=
0
;
virtual
bool
AddBlueprint
(
const
std
::
unique
_ptr
<
Blueprint
>
&
blueprint
)
=
0
;
/** Read configuration at the blueprints nodes and edges and return true if all components could be uniquely selected*/
virtual
bool
Configure
()
=
0
;
...
...
Modules/Core/ComponentInterface/test/selxNetworkBuilderTest.cxx
View file @
1ce87383
...
...
@@ -38,7 +38,7 @@ class NetworkBuilderTest : public ::testing::Test
public:
typedef
std
::
unique_ptr
<
NetworkBuilderBase
>
NetworkBuilderPointer
;
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
Blueprint
::
ParameterMapType
ParameterMapType
;
typedef
Blueprint
::
ParameterValueType
ParameterValueType
;
...
...
Modules/Core/Filter/include/itkUniquePointerDataObjectDecorator.h
0 → 100644
View file @
1ce87383
/*=========================================================================
*
* Copyright Insight Software Consortium
*
* 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.
*
*=========================================================================*/
/*=========================================================================
*
* Portions of this file are subject to the VTK Toolkit Version 3 copyright.
*
* Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
*
* For complete copyright, license and disclaimer of warranty information
* please refer to the NOTICE file at the top of the ITK source tree.
*
*=========================================================================*/
#ifndef selxUniquePointerDataObjectDecorator_h
#define selxUniquePointerDataObjectDecorator_h
#include
<memory>
#include
"itkDataObject.h"
#include
"itkObjectFactory.h"
namespace
itk
{
/** \class UniquePointerDataObjectDecorator
* \brief Decorates any std::unique_ptr to a simple object with a DataObject API.
*
* UniquePointerDataObjectDecorator decorates a std::unique_ptr to an object
* with a DataObject API. This allows a pointer to an object to be
* encapsulated in a DataObject and passed through the pipeline. This
* object differs from SimpleDataObjectDecorator in that the decorator
* takes control of deleting the pointer upon destruction.
*
* The decorator provides two methods Set() and Get() to access the
* decorated object (referred internally as the component).
* Using Set() will std::move the unique_ptr argument to the
* UniquePointerDataObjectDecorator component and invalidates the unique_ptr
* argument at the caller.
* Using Get() will std::move the UniquePointerDataObjectDecorator component
* and invalidates internal unique_ptr component.
*
* Note that when an instance of UniquePointerDataObjectDecorator is created,
* the component is initialized with its default constructor (i.e. a
* null pointer).
*
* \sa AutoPointerDataObjectDecorator
* \sa SimpleDataObjectDecorator
* \sa DataObjectDecorator
* \ingroup ITKSystemObjects
*
* \ingroup ITKCommon
*/
template
<
typename
T
>
class
UniquePointerDataObjectDecorator
:
public
DataObject
{
public:
/** Standard typedefs. */
typedef
UniquePointerDataObjectDecorator
Self
;
typedef
DataObject
Superclass
;
typedef
SmartPointer
<
Self
>
Pointer
;
typedef
SmartPointer
<
const
Self
>
ConstPointer
;
/** Typedef for the component type (object being decorated) */
typedef
T
ComponentType
;
typedef
std
::
unique_ptr
<
T
>
ComponentPointer
;
/** Method for creation through the object factory. */
itkNewMacro
(
Self
);
/** Run-time type information (and related methods). */
itkTypeMacro
(
UniquePointerDataObjectDecorator
,
DataObject
);
/** Set the contained object */
virtual
void
Set
(
std
::
unique_ptr
<
T
>
&
val
);
/** Get the contained object */
virtual
std
::
unique_ptr
<
T
>
Get
()
{
return
std
::
move
(
m_Component
);
}
// Get() const cannot exist, since getting a unique_ptr to the component invalides the m_Component and alters the Decorator.
//virtual const std::unique_ptr< T > Get() const { return std::move(m_Component); }
protected:
UniquePointerDataObjectDecorator
();
~
UniquePointerDataObjectDecorator
();
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
Indent
indent
)
const
ITK_OVERRIDE
;
protected:
private:
// ITK_DISALLOW_COPY_AND_ASSIGN(UniquePointerDataObjectDecorator);
ComponentPointer
m_Component
;
};
}
// end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include
"itkUniquePointerDataObjectDecorator.hxx"
#endif
#endif
\ No newline at end of file
Modules/Core/Filter/include/itkUniquePointerDataObjectDecorator.hxx
0 → 100644
View file @
1ce87383
/*=========================================================================
*
* Copyright Insight Software Consortium
*
* 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.
*
*=========================================================================*/
/*=========================================================================
*
* Portions of this file are subject to the VTK Toolkit Version 3 copyright.
*
* Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
*
* For complete copyright, license and disclaimer of warranty information
* please refer to the NOTICE file at the top of the ITK source tree.
*
*=========================================================================*/
#ifndef selxUniquePointerDataObjectDecorator_hxx
#define selxUniquePointerDataObjectDecorator_hxx
#include
"itkUniquePointerDataObjectDecorator.h"
namespace
itk
{
/** Constructor */
template
<
typename
T
>
UniquePointerDataObjectDecorator
<
T
>
::
UniquePointerDataObjectDecorator
()
:
m_Component
()
{}
/** Destructor */
template
<
typename
T
>
UniquePointerDataObjectDecorator
<
T
>
::~
UniquePointerDataObjectDecorator
()
{}
/** Set value */
template
<
typename
T
>
void
UniquePointerDataObjectDecorator
<
T
>
::
Set
(
std
::
unique_ptr
<
T
>
&
val
)
{
if
(
m_Component
!=
val
)
{
m_Component
=
std
::
move
(
val
);
this
->
Modified
();
}
}
/** PrintSelf method */
template
<
typename
T
>
void
UniquePointerDataObjectDecorator
<
T
>
::
PrintSelf
(
std
::
ostream
&
os
,
Indent
indent
)
const
{
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"Component: "
<<
typeid
(
m_Component
).
name
()
<<
std
::
endl
;
}
}
// end namespace itk
#endif
\ No newline at end of file
Modules/Core/Filter/include/selxSuperElastixFilter.h
View file @
1ce87383
...
...
@@ -25,7 +25,8 @@
#include
"selxAnyFileReader.h"
#include
"selxAnyFileWriter.h"
#include
"itkSharedPointerDataObjectDecorator.h"
//#include "itkSharedPointerDataObjectDecorator.h"
#include
"itkUniquePointerDataObjectDecorator.h"
/**
* \class SuperElastixFilter
...
...
@@ -58,7 +59,7 @@ public:
typedef
AnyFileReader
AnyFileReaderType
;
typedef
AnyFileWriter
AnyFileWriterType
;
typedef
itk
::
Shared
PointerDataObjectDecorator
<
Blueprint
>
BlueprintType
;
typedef
itk
::
Unique
PointerDataObjectDecorator
<
Blueprint
>
BlueprintType
;
typedef
BlueprintType
::
Pointer
BlueprintPointer
;
typedef
BlueprintType
::
ConstPointer
BlueprintConstPointer
;
...
...
Modules/Core/Filter/test/selxSuperElastixFilterTest.cxx
View file @
1ce87383
...
...
@@ -19,7 +19,7 @@
#include
"selxSuperElastixFilterCustomComponents.h"
#include
"itk
Shared
PointerDataObjectDecorator.h"
#include
"itk
Unique
PointerDataObjectDecorator.h"
#include
"selxItkSmoothingRecursiveGaussianImageFilterComponent.h"
#include
"selxItkImageSink.h"
...
...
@@ -69,7 +69,7 @@ public:
using
RegisterComponents
=
list_append
<
CustomComponents
,
DefaultComponents
>::
type
;
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
SuperElastixFilter
::
BlueprintType
SuperElastixFilterBlueprintType
;
typedef
SuperElastixFilter
::
BlueprintPointer
SuperElastixFilterBlueprintPointer
;
...
...
Testing/Unit/selxitkImageFilterTest.cxx
View file @
1ce87383
...
...
@@ -46,10 +46,10 @@ namespace selx
class
itkImageFilterTest
:
public
::
testing
::
Test
{
public:
using
BlueprintITKType
=
itk
::
Shared
PointerDataObjectDecorator
<
Blueprint
>
;
using
BlueprintITKType
=
itk
::
Unique
PointerDataObjectDecorator
<
Blueprint
>
;
typedef
BlueprintITKType
::
Pointer
BlueprintITKPointer
;
typedef
std
::
shared
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
std
::
unique
_ptr
<
Blueprint
>
BlueprintPointer
;
typedef
Blueprint
::
ParameterMapType
ParameterMapType
;
typedef
Blueprint
::
ParameterValueType
ParameterValueType
;
typedef
DataManager
DataManagerType
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment