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: ...@@ -19,30 +19,37 @@ public:
elxNewMacro( Blueprint, itk::DataObject ); elxNewMacro( Blueprint, itk::DataObject );
typedef TComponentDescriptor ComponentDescriptorType; typedef TComponentDescriptor ComponentDescriptorType;
typedef typename TComponentDescriptor::ComponentNameType ComponentNameType;
typedef boost::adjacency_list< boost::listS, typedef boost::adjacency_list< boost::listS,
boost::listS, boost::listS,
boost::directedS, boost::directedS,
ComponentDescriptorType > GraphType; ComponentDescriptorType > GraphType;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType; 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_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 >::edge_descriptor ConnectionDescriptorType;
typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd; typedef typename boost::graph_traits< GraphType >::edge_iterator ConnectionIterator, ConnectionIteratorEnd;
void SetGraph( GraphType graph ) { this->m_Graph = graph; }; typedef typename boost::graph_traits< GraphType >::in_edge_iterator InputIterator, InputIteratorEnd;
GraphType GetGraph( void ) const { return m_Graph; }; typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd;
void AddComponent( ComponentDescriptorType component ); bool AddComponent( ComponentDescriptorType component );
void RemoveComponent( ComponentDescriptorType component ); // bool SetComponent( ComponentIndexType componentIndex, ComponentDescriptorType component );
// ComponentDescriptorType GetComponent( ComponentIndexType componentIndex );
void AddConnection( ComponentDescriptorType upstream, ComponentDescriptorType downstream ); // bool SetConnection( ComponentIndexType upstream, ComponentIndexType downstream );
void RemoveConnection( ConnectionDescriptorType connection ); ConnectionDescriptorType GetConnection( ConnectionDescriptorType Connection );
private: private:
......
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
#define __ComponentDescriptor_h #define __ComponentDescriptor_h
#include "elxMacro.h" #include "elxMacro.h"
#include "itkLightObject.h" #include "itkDataObject.h"
namespace elx { namespace elx {
class ComponentDescriptor : public itk::LightObject class ComponentDescriptor : public itk::DataObject
{ {
public: public:
elxNewMacro( ComponentDescriptor, itk::LightObject ); elxNewMacro( ComponentDescriptor, itk::DataObject );
typedef std::string ComponentNameType; // Identifier to find component in the component database
typedef std::map< std::string, std::vector< std::string > > ParameterMapType; typedef std::string ComponentNameType;
void SetComponentName( ComponentNameType componentName ) { this->m_ComponentName = componentName; }; // TODO: Setter should validate ComponentName exists in ComponentDatabase
ComponentNameType GetComponentName( void ) { return this->m_ComponentName; }; itkSetMacro( ComponentName, ComponentNameType );
itkGetMacro( ComponentName, ComponentNameType );
private: private:
ComponentNameType m_ComponentName; ComponentNameType m_ComponentName;
ParameterMapType m_ParameterMap;
}; };
} }
#endif // __ComponentDescriptor_h #endif // __ComponentDescriptor_h
\ No newline at end of file
...@@ -11,13 +11,14 @@ void ...@@ -11,13 +11,14 @@ void
Blueprint< ComponentDescriptor > Blueprint< ComponentDescriptor >
::Blueprint( void ) ::Blueprint( void )
{ {
this->m_Graph = GraphType; this->SetGraph( GraphType );
} }
ComponentDescriptorType ComponentDescriptorType
Blueprint< ComponentDescriptor > Blueprint< ComponentDescriptor >
::AddComponent( ComponentDescriptorType component ) ::AddComponent( ComponentDescriptorType component )
{ {
// TODO: Check that the component is in the component::ComponentName is in the ComponentDatabase
this->Modified(); this->Modified();
return this->m_Graph->add_vertex( component ); 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 { ...@@ -6,21 +6,18 @@ namespace elx {
TEST( Blueprint, Instantiation ) TEST( Blueprint, Instantiation )
{ {
typedef Blueprint< ComponentDescriptor > BlueprintType; typedef Blueprint< ComponentDescriptor > BlueprintType;
BlueprintType::Pointer blueprint = BlueprintType::New(); BlueprintType::Pointer blueprint;
EXPECT_NO_THROW( blueprint = BlueprintType::New() );
typedef BlueprintType::ComponentDescriptorType ComponentDescriptorType; typedef BlueprintType::ComponentDescriptorType ComponentDescriptorType;
ComponentDescriptorType::Pointer componentDescriptor = ComponentDescriptorType::New(); ComponentDescriptorType::Pointer componentDescriptor;
EXPECT_NO_THROW( componentDescriptor = ComponentDescriptorType::New() );
typedef ComponentDescriptorType::ComponentNameType ComponentNameType; typedef ComponentDescriptorType::ComponentNameType ComponentNameType;
ComponentNameType componentName = ComponentNameType("Metric"); ComponentNameType componentName;
componentDescriptor->SetComponentName( componentName ); EXPECT_NO_THROW( componentName = ComponentNameType("Metric") );
EXPECT_NO_THROW( 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) );
ASSERT_TRUE( true ); 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