Skip to content
Snippets Groups Projects
Commit 8db4df61 authored by Kasper Marstal's avatar Kasper Marstal
Browse files

ENH: ELASTIX-9 Add ComponentDescriptor class

parent 4cea7e80
No related branches found
No related tags found
No related merge requests found
......@@ -19,30 +19,37 @@ public:
elxNewMacro( Blueprint, itk::DataObject );
typedef TComponentDescriptor ComponentDescriptorType;
typedef TComponentDescriptor ComponentDescriptorType;
typedef typename TComponentDescriptor::ComponentNameType ComponentNameType;
typedef boost::adjacency_list< boost::listS,
boost::listS,
boost::directedS,
ComponentDescriptorType > GraphType;
ComponentDescriptorType > GraphType;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType;
typedef typename boost::graph_traits< GraphType >::vertex_iterator ComponentIterator, ComponentIteratorEnd;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType;
typedef typename boost::graph_traits< GraphType >::vertex_iterator ComponentIterator, ComponentIteratorEnd;
typedef typename boost::graph_traits< GraphType >::edge_descriptor ConnectionDescriptorType;
typedef typename boost::graph_traits< GraphType >::edge_iterator ConnectionIterator, ConnectionIteratorEnd;
// TODO: Why can't we get the vertex index map type like they show in
// http://www.boost.org/doc/libs/1_38_0/libs/graph/doc/quick_tour.html
// under "Access Vertex Set"?
typedef boost::vertex_index_t ComponentIndexType;
typedef typename boost::property_map< GraphType, ComponentIndexType >::type ComponentIndexMapType;
typedef typename boost::graph_traits< GraphType >::in_edge_iterator InputIterator, InputIteratorEnd;
typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd;
typedef typename boost::graph_traits< GraphType >::edge_descriptor ConnectionDescriptorType;
typedef typename boost::graph_traits< GraphType >::edge_iterator ConnectionIterator, ConnectionIteratorEnd;
void SetGraph( GraphType graph ) { this->m_Graph = graph; };
GraphType GetGraph( void ) const { return m_Graph; };
typedef typename boost::graph_traits< GraphType >::in_edge_iterator InputIterator, InputIteratorEnd;
typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd;
void AddComponent( ComponentDescriptorType component );
void RemoveComponent( ComponentDescriptorType component );
bool AddComponent( ComponentDescriptorType component );
// bool SetComponent( ComponentIndexType componentIndex, ComponentDescriptorType component );
// ComponentDescriptorType GetComponent( ComponentIndexType componentIndex );
void AddConnection( ComponentDescriptorType upstream, ComponentDescriptorType downstream );
void RemoveConnection( ConnectionDescriptorType connection );
// bool SetConnection( ComponentIndexType upstream, ComponentIndexType downstream );
ConnectionDescriptorType GetConnection( ConnectionDescriptorType Connection );
private:
......
......@@ -2,29 +2,29 @@
#define __ComponentDescriptor_h
#include "elxMacro.h"
#include "itkLightObject.h"
#include "itkDataObject.h"
namespace elx {
class ComponentDescriptor : public itk::LightObject
class ComponentDescriptor : public itk::DataObject
{
public:
elxNewMacro( ComponentDescriptor, itk::LightObject );
elxNewMacro( ComponentDescriptor, itk::DataObject );
typedef std::string ComponentNameType;
typedef std::map< std::string, std::vector< std::string > > ParameterMapType;
// Identifier to find component in the component database
typedef std::string ComponentNameType;
void SetComponentName( ComponentNameType componentName ) { this->m_ComponentName = componentName; };
ComponentNameType GetComponentName( void ) { return this->m_ComponentName; };
// TODO: Setter should validate ComponentName exists in ComponentDatabase
itkSetMacro( ComponentName, ComponentNameType );
itkGetMacro( ComponentName, ComponentNameType );
private:
ComponentNameType m_ComponentName;
ParameterMapType m_ParameterMap;
ComponentNameType m_ComponentName;
};
}
#endif // __ComponentDescriptor_h
\ No newline at end of file
#endif // __ComponentDescriptor_h
......@@ -11,13 +11,14 @@ void
Blueprint< ComponentDescriptor >
::Blueprint( void )
{
this->m_Graph = GraphType;
this->SetGraph( GraphType );
}
ComponentDescriptorType
Blueprint< ComponentDescriptor >
::AddComponent( ComponentDescriptorType component )
{
// TODO: Check that the component is in the component::ComponentName is in the ComponentDatabase
this->Modified();
return this->m_Graph->add_vertex( component );
}
......
#ifndef __ComponentDescriptor_hxx
#define __ComponentDescriptor_hxx
#include "elxComponentDescriptor.h"
// TODO: Need enum for component name?
namespace elx {
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( this->GenerateUniqueId() );
this->SetParameterMap( this->ParameterMapType() );
}
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName,
const ComponentUniqueIdType componentUniqueId )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( componentUniqueId );
this->SetParameterMap( this->ParameterMapType() );
}
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName,
const ComponentIdType componentUniqueId,
const ParameterMapType parameterMap )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( componentUniqueId );
this->SetParameterMap( parameterMap );
}
ComponentDescriptor::ComponentIdType
ComponentDescriptor
::GenerateUniqueId()
{
}
} // namespace elx
#endif // __ComponentDescriptor_hxx
\ No newline at end of file
include_directories( include )
#ifndef __ElastixFilter_h
#define __ElastixFilter_h
#endif // #define __ElastixFilter_h
\ No newline at end of file
......@@ -6,21 +6,18 @@ namespace elx {
TEST( Blueprint, Instantiation )
{
typedef Blueprint< ComponentDescriptor > BlueprintType;
BlueprintType::Pointer blueprint = BlueprintType::New();
typedef Blueprint< ComponentDescriptor > BlueprintType;
BlueprintType::Pointer blueprint;
EXPECT_NO_THROW( blueprint = BlueprintType::New() );
typedef BlueprintType::ComponentDescriptorType ComponentDescriptorType;
ComponentDescriptorType::Pointer componentDescriptor = ComponentDescriptorType::New();
ComponentDescriptorType::Pointer componentDescriptor;
EXPECT_NO_THROW( componentDescriptor = ComponentDescriptorType::New() );
typedef ComponentDescriptorType::ComponentNameType ComponentNameType;
ComponentNameType componentName = ComponentNameType("Metric");
componentDescriptor->SetComponentName( componentName );
// We would like to save all data in the graph itself, but the following is
// not possible because the component (of type itk::LightObject has private copy
// constructor. How do we save data in graph and make this as itk-like as possible?
// Ideally when a component descriptor is changed the blueprint calls Modified() on itself
// blueprint->AddComponent( (*componentDescriptor) );
ComponentNameType componentName;
EXPECT_NO_THROW( componentName = ComponentNameType("Metric") );
EXPECT_NO_THROW( componentDescriptor->SetComponentName( componentName ) );
ASSERT_TRUE( true );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment