Commit e4089f81 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: big refactor: all selx Components are not itk objects anymore.

Replaced all itk::SmartPointer-s by std::shared_ptr-s and all raw
interface pointers too.
parent ee81b25f
......@@ -31,12 +31,12 @@ class Accepting< >
public:
static unsigned int CountMeetsCriteria( const ComponentBase::InterfaceCriteriaType ) { return 0; }
int ConnectFromImpl( ComponentBase * other, const ComponentBase::InterfaceCriteriaType interfaceCriteria ) { return 0; } //no interface called interfacename ;
InterfaceStatus CanAcceptConnectionFrom( ComponentBase * other, const ComponentBase::InterfaceCriteriaType interfaceCriteria )
int ConnectFromImpl(ComponentBase::Pointer other, const ComponentBase::InterfaceCriteriaType interfaceCriteria) { return 0; } //no interface called interfacename ;
InterfaceStatus CanAcceptConnectionFrom(ComponentBase::ConstPointer, const ComponentBase::InterfaceCriteriaType interfaceCriteria)
{
return InterfaceStatus::noaccepter;
}
int ConnectFromImpl( ComponentBase * ) { return 0; } //Empty RestInterfaces does 0 successful connects ;
int ConnectFromImpl(ComponentBase::Pointer) { return 0; } //Empty RestInterfaces does 0 successful connects ;
protected:
};
......@@ -48,11 +48,11 @@ public:
static unsigned int CountMeetsCriteria( const ComponentBase::InterfaceCriteriaType );
int ConnectFromImpl( ComponentBase * other, const ComponentBase::InterfaceCriteriaType interfaceCriteria );
int ConnectFromImpl( ComponentBase::Pointer other, const ComponentBase::InterfaceCriteriaType interfaceCriteria );
InterfaceStatus CanAcceptConnectionFrom( ComponentBase * other, const ComponentBase::InterfaceCriteriaType interfaceCriteria );
InterfaceStatus CanAcceptConnectionFrom( ComponentBase::ConstPointer other, const ComponentBase::InterfaceCriteriaType interfaceCriteria );
int ConnectFromImpl( ComponentBase * );
int ConnectFromImpl(ComponentBase::Pointer);
protected:
};
......
......@@ -28,7 +28,7 @@ namespace selx
template< typename FirstInterface, typename ... RestInterfaces >
int
Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase * other,
Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase::Pointer other,
const ComponentBase::InterfaceCriteriaType interfaceCriteria )
{
// Does our component have an accepting interface sufficing the right criteria (e.g interfaceName)?
......@@ -48,7 +48,7 @@ Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase
template< typename FirstInterface, typename ... RestInterfaces >
int
Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase * other )
Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase::Pointer other)
{
// cast always succeeds since we know via the template arguments of the component which InterfaceAcceptors its base classes are.
InterfaceAcceptor< FirstInterface > * acceptIF = ( this );
......@@ -61,7 +61,7 @@ Accepting< FirstInterface, RestInterfaces ... >::ConnectFromImpl( ComponentBase
template< typename FirstInterface, typename ... RestInterfaces >
InterfaceStatus
Accepting< FirstInterface, RestInterfaces ... >::CanAcceptConnectionFrom( ComponentBase * other,
Accepting< FirstInterface, RestInterfaces ... >::CanAcceptConnectionFrom( ComponentBase::ConstPointer other,
const ComponentBase::InterfaceCriteriaType interfaceCriteria )
{
InterfaceStatus restInterfacesStatus = Accepting< RestInterfaces ... >::CanAcceptConnectionFrom( other, interfaceCriteria );
......
......@@ -20,9 +20,6 @@
#ifndef ComponentBase_h
#define ComponentBase_h
#include "itkLightObject.h"
#include "itkObjectFactory.h"
#include "itkMacro.h"
#include "selxInterfaceStatus.h"
#include <list>
#include <iostream>
......@@ -30,21 +27,21 @@
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <memory>
namespace selx
{
class ComponentBase : public itk::LightObject
class ComponentBase
{
public:
//ComponentBase() = delete;
ComponentBase();
ComponentBase(const std::string & name);
virtual ~ComponentBase() {}
/** Standard class typedefs */
typedef ComponentBase Self;
typedef itk::LightObject Superclass;
typedef itk::SmartPointer< Self > Pointer;
/** Run-time type information (and related methods). */
itkTypeMacro( ComponentBase, Superclass );
typedef std::shared_ptr<ComponentBase> Pointer;
typedef std::shared_ptr<const ComponentBase> ConstPointer;
typedef std::string ParameterKeyType;
typedef std::vector< std::string > ParameterValueType;
//typedef std::map< ParameterKeyType, ParameterValueType > ParameterMapType;
......@@ -54,28 +51,21 @@ public:
typedef std::map< std::string, std::string > InterfaceCriteriaType;
virtual int AcceptConnectionFrom( ComponentBase *, const InterfaceCriteriaType ) = 0;
virtual int AcceptConnectionFrom( Pointer, const InterfaceCriteriaType) = 0;
virtual int AcceptConnectionFrom( ComponentBase * ) = 0;
virtual int AcceptConnectionFrom( Pointer ) = 0;
virtual bool MeetsCriterion( const CriterionType & criterion ) = 0;
virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase *, const InterfaceCriteriaType ) = 0;
virtual InterfaceStatus CanAcceptConnectionFrom(ConstPointer, const InterfaceCriteriaType) = 0;
virtual unsigned int CountAcceptingInterfaces( const InterfaceCriteriaType ) = 0;
virtual unsigned int CountProvidingInterfaces( const InterfaceCriteriaType ) = 0;
//virtual const std::map< std::string, std::string > TemplateProperties(); //TODO should be overridden
void Name(const std::string setName){ m_Name = setName; }; //Setter should be via constructor. We should get rid of itk factory design.
//const std::string GetComponentName() { return m_Name; };
protected:
ComponentBase() {}
virtual ~ComponentBase() {}
std::string m_Name;
const std::string m_Name;
};
} // end namespace selx
......
......@@ -31,27 +31,17 @@ namespace selx
*/
template <class ComponentList>
class ComponentSelector : public itk::Object
class ComponentSelector
{
public:
/** Standard class typedefs. */
typedef ComponentSelector Self;
typedef Object Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
/** Class methods used to interface with the registered factories. */
//virtual const char * GetITKSourceVersion() const { return ITK_SOURCE_VERSION; }
/** Run-time type information (and related methods). */
itkTypeMacro( ComponentSelector, Object );
/** New macro for creation of through the object factory. */
itkNewMacro( Self );
typedef ComponentSelector<ComponentList> Self;
typedef std::shared_ptr< Self > Pointer;
typedef std::shared_ptr< const Self > ConstPointer;
/** Convenient typedefs. */
typedef ComponentBase::Pointer ComponentBasePointer;
typedef ComponentBase::Pointer ComponentBasePointer;
typedef ComponentBase::CriteriaType CriteriaType;
typedef ComponentBase::CriterionType CriterionType;
typedef ComponentBase::InterfaceCriteriaType InterfaceCriteriaType;
......@@ -60,6 +50,8 @@ public:
typedef ComponentListType::size_type NumberOfComponentsType;
/** set selection criteria for possibleComponents*/
ComponentSelector(const std::string & name);
/** Narrow selection criteria*/
void AddCriterion( const CriterionType & criterion );
......@@ -78,12 +70,8 @@ public:
void PrintComponents(void);
void ComponentName(const std::string); //Setter should be via constructor. We should get rid of itk factory design.
protected:
ComponentListType m_PossibleComponents;
ComponentSelector();
~ComponentSelector();
private:
......
......@@ -28,7 +28,7 @@ namespace selx
template< >
struct ContructComponentsFromTypeList< TypeList< > >
{
static std::list<ComponentBase::Pointer> fill(std::list<ComponentBase::Pointer> &components, std::string &name)
static std::list<ComponentBase::Pointer> fill(std::list<ComponentBase::Pointer> &components, const std::string &name)
{
return components;
}
......@@ -37,47 +37,19 @@ namespace selx
template< typename ComponentType, typename ... Rest >
struct ContructComponentsFromTypeList< TypeList< ComponentType, Rest ... > >
{
static std::list<ComponentBase::Pointer> fill(std::list<ComponentBase::Pointer> &components, std::string &name)
static std::list<ComponentBase::Pointer> fill(std::list<ComponentBase::Pointer> &components, const std::string &name)
{
//components->push_back(new ComponentType(name));
components.push_back(ComponentType::New().GetPointer());
components.push_back(std::make_shared<ComponentType>(name));
return ContructComponentsFromTypeList<TypeList< Rest ... >>::fill(components, name);
}
};
template <class ComponentList>
ComponentSelector<ComponentList>::ComponentSelector()
ComponentSelector<ComponentList>::ComponentSelector(const std::string & name)
{
m_PossibleComponents = std::list<ComponentBase::Pointer>();
std::string name = "name";
m_PossibleComponents = ContructComponentsFromTypeList<ComponentList>::fill(m_PossibleComponents, name);
//std::list< itk::LightObject::Pointer > allobjects
// = itk::ObjectFactoryBase::CreateAllInstance( "ComponentBase" );
//for( std::list< itk::LightObject::Pointer >::iterator i = allobjects.begin();
// i != allobjects.end(); ++i )
//{
// ComponentBase * component
// = dynamic_cast< ComponentBase * >( i->GetPointer() );
// if (component)
// {
// this->m_PossibleComponents.push_back(component);
// }
//}
}
template <class ComponentList>
ComponentSelector<ComponentList>::~ComponentSelector()
{
}
template <class ComponentList>
void ComponentSelector<ComponentList>::ComponentName(const std::string name)
{
for (const auto & component : this->m_PossibleComponents)
{
component->Name(name);
}
}
template <class ComponentList>
......
......@@ -32,15 +32,15 @@ template< class InterfaceT >
class InterfaceAcceptor
{
public:
using Pointer = std::shared_ptr<InterfaceAcceptor<InterfaceT>>;
// Set() is called by a succesfull Connect()
// The implementation of Set() must be provided by component developers.
virtual int Set( InterfaceT * ) = 0;
virtual int Set( typename InterfaceT::Pointer ) = 0;
// Connect tries to connect this accepting interface with all interfaces of the provider component.
int Connect( ComponentBase * );
int Connect( ComponentBase::Pointer );
bool CanAcceptConnectionFrom( ComponentBase * );
bool CanAcceptConnectionFrom( ComponentBase::ConstPointer );
private:
......
......@@ -24,9 +24,9 @@ namespace selx
{
template< class InterfaceT >
int
InterfaceAcceptor< InterfaceT >::Connect( ComponentBase * providerComponent )
InterfaceAcceptor< InterfaceT >::Connect( ComponentBase::Pointer providerComponent )
{
InterfaceT * providerInterface = dynamic_cast< InterfaceT * >( providerComponent );
std::shared_ptr<InterfaceT> providerInterface = std::dynamic_pointer_cast< InterfaceT >( providerComponent );
if( !providerInterface )
{
//TODO log message?
......@@ -41,9 +41,9 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase * providerComponent )
template< class InterfaceT >
bool
InterfaceAcceptor< InterfaceT >::CanAcceptConnectionFrom( ComponentBase * providerComponent )
InterfaceAcceptor< InterfaceT >::CanAcceptConnectionFrom( ComponentBase::ConstPointer providerComponent )
{
InterfaceT * providerInterface = dynamic_cast< InterfaceT * >( providerComponent );
std::shared_ptr<const InterfaceT> providerInterface = std::dynamic_pointer_cast< const InterfaceT >(providerComponent);
return bool(providerInterface);
}
......
......@@ -35,7 +35,7 @@ namespace selx
// How specific Source Components connect to the graph is up to them, i.e. they might adapt the passed Object to other types.
public:
using Pointer = std::shared_ptr<SourceInterface>;
virtual void SetMiniPipelineInput(itk::DataObject::Pointer) = 0;
virtual AnyFileReader::Pointer GetInputFileReader(void) = 0;
};
......@@ -47,7 +47,7 @@ namespace selx
// How specific Sink Components connect to the graph is up to them, i.e. they might adapt the passed Object to other types.
public:
using Pointer = std::shared_ptr<SinkInterface>;
typedef itk::DataObject::Pointer DataObjectPointer;
virtual void SetMiniPipelineOutput(DataObjectPointer) = 0;
virtual DataObjectPointer GetMiniPipelineOutput(void) = 0;
......@@ -64,7 +64,7 @@ class RegistrationControllerStartInterface
// This interface is to control the execution of the network
public:
using Pointer = std::shared_ptr<RegistrationControllerStartInterface>;
virtual void RegistrationControllerStart() = 0;
};
......@@ -73,7 +73,7 @@ class RunRegistrationInterface
// This interface is to control the execution of the network
public:
using Pointer = std::shared_ptr<RunRegistrationInterface>;
virtual void RunRegistration() = 0;
};
......@@ -82,7 +82,7 @@ class AfterRegistrationInterface
// This interface is to control the execution of the network
public:
using Pointer = std::shared_ptr<AfterRegistrationInterface>;
virtual void AfterRegistration() = 0;
};
......@@ -91,7 +91,7 @@ class RunResolutionInterface
// This interface is to control the execution of the network
public:
using Pointer = std::shared_ptr<RunResolutionInterface>;
virtual bool RunResolution() = 0;
};
......@@ -100,7 +100,7 @@ class ReconnectTransformInterface
// This interface is to control the execution of the network
public:
using Pointer = std::shared_ptr<ReconnectTransformInterface>;
virtual void ReconnectTransform() = 0;
};
......
......@@ -51,12 +51,12 @@ public:
typedef Blueprint::ComponentNameType ComponentNameType;
typedef std::map<
std::string, SourceInterface * > SourceInterfaceMapType;
std::string, SourceInterface::Pointer > SourceInterfaceMapType;
typedef std::map<
std::string, SinkInterface * > SinkInterfaceMapType;
std::string, SinkInterface::Pointer > SinkInterfaceMapType;
typedef std::map<
std::string, RegistrationControllerStartInterface * > RegistrationControllerStartInterfaceMapType;
std::string, RegistrationControllerStartInterface::Pointer > RegistrationControllerStartInterfaceMapType;
NetworkBuilder();
virtual ~NetworkBuilder() {};
......
......@@ -158,9 +158,7 @@ NetworkBuilder<ComponentList>::ApplyComponentConfiguration()
for( auto const & name : componentNames )
{
std::cout << " Blueprint Node: " << name << std::endl;
typename ComponentSelector<ComponentList>::Pointer currentComponentSelectorA = ComponentSelector<ComponentList>::New();
ComponentSelectorPointer currentComponentSelector = ComponentSelectorType::New();
currentComponentSelector->ComponentName(name); // Todo via constructor
ComponentSelectorPointer currentComponentSelector = std::make_shared<ComponentSelectorType>(name);
Blueprint::ParameterMapType currentProperty = this->m_Blueprint->GetComponent( name );
for( auto const & criterion : currentProperty )
......@@ -397,8 +395,8 @@ NetworkBuilder<ComponentList>::GetSourceInterfaces()
if( component->CountProvidingInterfaces( { { keys::NameOfInterface, keys::SourceInterface } } ) == 1 )
{
SourceInterface * provingSourceInterface = dynamic_cast< SourceInterface * >( component.GetPointer() );
if( provingSourceInterface == nullptr ) // is actually a double-check for sanity: based on criterion cast should be successful
SourceInterface::Pointer provingSourceInterface = std::dynamic_pointer_cast< SourceInterface >( component );
if(!provingSourceInterface) // is actually a double-check for sanity: based on criterion cast should be successful
{
throw std::runtime_error( "dynamic_cast<SourceInterface*> fails, but based on component criterion it shouldn't" );
}
......@@ -420,8 +418,8 @@ NetworkBuilder<ComponentList>::GetSinkInterfaces()
ComponentBase::Pointer component = componentSelector.second->GetComponent();
if( component->CountProvidingInterfaces( { { keys::NameOfInterface, keys::SinkInterface } } ) == 1 )
{
SinkInterface * provingSinkInterface = dynamic_cast< SinkInterface * >( component.GetPointer() );
if( provingSinkInterface == nullptr ) // is actually a double-check for sanity: based on criterion cast should be successful
SinkInterface::Pointer provingSinkInterface = std::dynamic_pointer_cast< SinkInterface>( component );
if(!provingSinkInterface ) // is actually a double-check for sanity: based on criterion cast should be successful
{
throw std::runtime_error( "dynamic_cast<SinkInterface*> fails, but based on component criterion it shouldn't" );
}
......@@ -496,8 +494,8 @@ NetworkBuilder<ComponentList>::GetRealizedNetwork()
/** Scans all Components to find those with Sinking capability and store the outputs in outputObjectsMap */
if (component->CountProvidingInterfaces({ { keys::NameOfInterface, keys::SinkInterface } }) == 1)
{
SinkInterface * provingSinkInterface = dynamic_cast<SinkInterface *>(component.GetPointer());
if (provingSinkInterface == nullptr) // is actually a double-check for sanity: based on criterion cast should be successful
SinkInterface::Pointer provingSinkInterface = std::dynamic_pointer_cast<SinkInterface>(component);
if (!provingSinkInterface) // is actually a double-check for sanity: based on criterion cast should be successful
{
throw std::runtime_error("dynamic_cast<SinkInterface*> fails, but based on component criterion it shouldn't");
}
......
......@@ -50,9 +50,9 @@ public:
typedef Blueprint::ComponentNameType ComponentNameType;
typedef Blueprint::ComponentNamesType ComponentNamesType;
typedef std::map<
std::string, SourceInterface * > SourceInterfaceMapType;
std::string, SourceInterface::Pointer > SourceInterfaceMapType;
typedef std::map<
std::string, SinkInterface * > SinkInterfaceMapType;
std::string, SinkInterface::Pointer > SinkInterfaceMapType;
typedef std::map<
std::string, RegistrationControllerStartInterface * > RegistrationControllerStartInterfaceMapType;
......
......@@ -34,7 +34,7 @@ namespace selx
// a (light weight) ComponentContainer with 1 Execute button. All other data such as graphs and selectors can be deleted.
public:
using ComponentContainerType = std::vector<ComponentBase::Pointer>;
using ComponentContainerType = std::vector<std::shared_ptr<ComponentBase>>;
using OutputObjectsMapType = std::map<std::string, itk::DataObject::Pointer>;
NetworkContainer(ComponentContainerType components, OutputObjectsMapType outputObjectsMap);
......
......@@ -42,13 +42,14 @@ public:
using AcceptingInterfacesTypeList = AcceptingInterfaces;
using ProvidingInterfacesTypeList = ProvidingInterfaces;
virtual int AcceptConnectionFrom( ComponentBase * other, const InterfaceCriteriaType interfaceCriteria );
SuperElastixComponent(const std::string & name) : ComponentBase(name) {};
virtual int AcceptConnectionFrom( ComponentBase::Pointer other, const InterfaceCriteriaType interfaceCriteria );
virtual int AcceptConnectionFrom( ComponentBase * );
virtual int AcceptConnectionFrom( ComponentBase::Pointer);
protected:
virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase * other, const InterfaceCriteriaType interfaceCriteria ) override;
virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase::ConstPointer , const InterfaceCriteriaType interfaceCriteria ) override;
virtual unsigned int CountAcceptingInterfaces( const ComponentBase::InterfaceCriteriaType interfaceCriteria ) override
{
......
......@@ -26,7 +26,7 @@ namespace selx
//////////////////////////////////////////////////////////////////////////
template< typename AcceptingInterfaces, typename ProvidingInterfaces >
int
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnectionFrom( ComponentBase * other,
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnectionFrom( ComponentBase::Pointer other,
const InterfaceCriteriaType interfaceCriteria )
{
return AcceptingInterfaces::ConnectFromImpl( other, interfaceCriteria );
......@@ -35,7 +35,7 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnect
template< typename AcceptingInterfaces, typename ProvidingInterfaces >
int
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnectionFrom( ComponentBase * other )
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnectionFrom( ComponentBase::Pointer other)
{
return AcceptingInterfaces::ConnectFromImpl( other );
}
......@@ -44,7 +44,7 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::AcceptConnect
template< typename AcceptingInterfaces, typename ProvidingInterfaces >
InterfaceStatus
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >
::CanAcceptConnectionFrom( ComponentBase * other, const InterfaceCriteriaType interfaceCriteria )
::CanAcceptConnectionFrom( ComponentBase::ConstPointer other, const InterfaceCriteriaType interfaceCriteria )
{
return AcceptingInterfaces::CanAcceptConnectionFrom( other, interfaceCriteria );
}
......
......@@ -21,6 +21,13 @@
namespace selx
{
// TODO delete this constructor
ComponentBase::ComponentBase() : m_Name("undefined")
{
}
ComponentBase::ComponentBase(const std::string & name) : m_Name(name)
{
}
//const std::map< std::string, std::string > ComponentBase::TemplateProperties()
// { return{}; }
} // end namespace selx
......@@ -36,8 +36,8 @@ namespace selx
{
if (component->CountProvidingInterfaces({ { keys::NameOfInterface, keys::RegistrationControllerStartInterface } }) == 1)
{
RegistrationControllerStartInterface * providingInterface = dynamic_cast<RegistrationControllerStartInterface *>(component.GetPointer());
if (providingInterface == nullptr) // is actually a double-check for sanity: based on criterion cast should be successful
std::shared_ptr<RegistrationControllerStartInterface> providingInterface = std::dynamic_pointer_cast<RegistrationControllerStartInterface>(component);
if (!providingInterface) // is actually a double-check for sanity: based on criterion cast should always be successful
{
throw std::runtime_error("dynamic_cast<RegistrationControllerStartInterface*> fails, but based on component criterion it shouldn't");
}
......
......@@ -32,11 +32,11 @@ public:
virtual void SetUp()
{
metric3p = new SSDMetric3rdPartyComponent();
optimizer3p = new GDOptimizer3rdPartyComponent();
metric3p = std::make_shared<SSDMetric3rdPartyComponent>("nameless");
optimizer3p = std::make_shared<GDOptimizer3rdPartyComponent>("nameless");
metric4p = new SSDMetric4thPartyComponent();
optimizer4p = new GDOptimizer4thPartyComponent();
metric4p = std::make_shared<SSDMetric4thPartyComponent>("nameless");
optimizer4p = std::make_shared<GDOptimizer4thPartyComponent>("nameless");
}
......@@ -50,10 +50,10 @@ public:
// types as if returned by our component factory
ComponentBase * metric3p;
ComponentBase * optimizer3p;
ComponentBase * metric4p;
ComponentBase * optimizer4p;
ComponentBase::Pointer metric3p;
ComponentBase::Pointer optimizer3p;
ComponentBase::Pointer metric4p;
ComponentBase::Pointer optimizer4p;
};
TEST_F( InterfaceTest, InterfaceNameTraits )
......@@ -66,27 +66,27 @@ TEST_F( InterfaceTest, DynamicCast )
{
int returnval;
//metric3p should have a MetricValueInterface
MetricValueInterface * valueIF = dynamic_cast< MetricValueInterface * >( metric3p );
MetricValueInterface::Pointer valueIF = std::dynamic_pointer_cast< MetricValueInterface >( metric3p );
ASSERT_NE( valueIF, nullptr );
EXPECT_NO_THROW( returnval = valueIF->GetValue() );
//metric3p should have a MetricDerivativeInterface
MetricDerivativeInterface * derivativeIF = dynamic_cast< MetricDerivativeInterface * >( metric3p );
MetricDerivativeInterface::Pointer derivativeIF = std::dynamic_pointer_cast< MetricDerivativeInterface >(metric3p);
ASSERT_NE( derivativeIF, nullptr );
EXPECT_NO_THROW( returnval = derivativeIF->GetDerivative() );
//optimizer3p should have a OptimizerUpdateInterface
OptimizerUpdateInterface * updateIF = dynamic_cast< OptimizerUpdateInterface * >( optimizer3p );
OptimizerUpdateInterface::Pointer updateIF = std::dynamic_pointer_cast< OptimizerUpdateInterface >(optimizer3p);
ASSERT_NE( updateIF, nullptr );
//EXPECT_NO_THROW(returnval = updateIF->Update()); // Update can only be called if metric and optimizer are connected
//optimizer3p should have a InterfaceAcceptor<MetricValueInterface>
InterfaceAcceptor< MetricValueInterface > * valueAcceptorIF = dynamic_cast< InterfaceAcceptor< MetricValueInterface > * >( optimizer3p );
InterfaceAcceptor< MetricValueInterface >::Pointer valueAcceptorIF = std::dynamic_pointer_cast< InterfaceAcceptor< MetricValueInterface > >(optimizer3p);
ASSERT_NE( valueAcceptorIF, nullptr );
//optimizer3p should have a InterfaceAcceptor<MetricDerivativeInterface>
InterfaceAcceptor< MetricDerivativeInterface > * derivativeAcceptorIF
= dynamic_cast< InterfaceAcceptor< MetricDerivativeInterface > * >( optimizer3p );
InterfaceAcceptor< MetricDerivativeInterface >::Pointer derivativeAcceptorIF
= std::dynamic_pointer_cast< InterfaceAcceptor< MetricDerivativeInterface > >(optimizer3p);
ASSERT_NE( derivativeAcceptorIF, nullptr );
}
......@@ -122,12 +122,12 @@ TEST_F( InterfaceTest, ConnectAll )
{
int connectionCount = 0;
int returnval;
OptimizerUpdateInterface * updateIF;
OptimizerUpdateInterface::Pointer updateIF;