Workspace( )
: m_LastLoadedPlugin( "" )
{
+ this->m_Graph = TGraph::New( );
}
// -------------------------------------------------------------------------
return( EMPTY );
}
+// -------------------------------------------------------------------------
+cpPlugins::Interface::Workspace::
+TGraph* cpPlugins::Interface::Workspace::
+GetGraph( )
+{
+ return( this->m_Graph );
+}
+
+// -------------------------------------------------------------------------
+const cpPlugins::Interface::Workspace::
+TGraph* cpPlugins::Interface::Workspace::
+GetGraph( ) const
+{
+ return( this->m_Graph );
+}
+
// -------------------------------------------------------------------------
bool cpPlugins::Interface::Workspace::
CreateFilter( const std::string& filter, const std::string& name )
{
// Get or create new filter from name
- auto vIt = this->m_Vertices.find( name );
- if( vIt == this->m_Vertices.end( ) )
+ if( !( this->m_Graph->HasVertexIndex( name ) ) )
{
- TFilter::Pointer o = this->m_Interface.CreateObject( filter );
- if( o.IsNotNull( ) )
+ TFilter::Pointer f = this->m_Interface.CreateObject( filter );
+ if( f.IsNotNull( ) )
{
- o->SetName( name );
- this->m_Vertices[ name ] = o;
+ f->SetName( name );
+ TObject::Pointer o = f.GetPointer( );
+ this->m_Graph->InsertVertex( name, o );
return( true );
}
else
)
{
// Get filters
- auto oIt = this->m_Vertices.find( orig_filter );
- if( oIt == this->m_Vertices.end( ) )
- return( false );
- auto dIt = this->m_Vertices.find( dest_filter );
- if( dIt == this->m_Vertices.end( ) )
- return( false );
- TFilter* orig = dynamic_cast< TFilter* >( oIt->second.GetPointer( ) );
- TFilter* dest = dynamic_cast< TFilter* >( dIt->second.GetPointer( ) );
+ TFilter* orig =
+ dynamic_cast< TFilter* >(
+ this->m_Graph->GetVertex( orig_filter ).GetPointer( )
+ );
+ TFilter* dest =
+ dynamic_cast< TFilter* >(
+ this->m_Graph->GetVertex( dest_filter ).GetPointer( )
+ );
if( orig == NULL || dest == NULL )
return( false );
// Real connection
dest->SetInput( input_name, orig->GetOutput< TData >( output_name ) );
- this->m_AdjMatrix[ orig_filter ][ dest_filter ].push_back(
+ this->m_Graph->AddConnection(
+ orig_filter, dest_filter,
TConnection( output_name, input_name )
);
return( false );
TParameters* cpPlugins::Interface::Workspace::
GetParameters( const std::string& name )
{
- auto vIt = this->m_Vertices.find( name );
- if( vIt != this->m_Vertices.end( ) )
- {
- TFilter* f = dynamic_cast< TFilter* >( vIt->second.GetPointer( ) );
- if( f != NULL )
- return( f->GetParameters( ) );
- else
- return( NULL );
- }
+ TFilter* f =
+ dynamic_cast< TFilter* >(
+ this->m_Graph->GetVertex( name ).GetPointer( )
+ );
+ if( f != NULL )
+ return( f->GetParameters( ) );
else
return( NULL );
}
TParameters* cpPlugins::Interface::Workspace::
GetParameters( const std::string& name ) const
{
- auto vIt = this->m_Vertices.find( name );
- if( vIt != this->m_Vertices.end( ) )
- {
- const TFilter* f =
- dynamic_cast< const TFilter* >( vIt->second.GetPointer( ) );
- if( f != NULL )
- return( f->GetParameters( ) );
- else
- return( NULL );
- }
+ const TFilter* f =
+ dynamic_cast< const TFilter* >(
+ this->m_Graph->GetVertex( name ).GetPointer( )
+ );
+ if( f != NULL )
+ return( f->GetParameters( ) );
else
return( NULL );
}
bool cpPlugins::Interface::Workspace::
Reduce( const std::string& name )
{
+ return( false );
}
// -------------------------------------------------------------------------
Execute( )
{
// Find sinks
- std::set< std::string > sinks;
- auto vIt = this->m_Vertices.begin( );
- for( ; vIt != this->m_Vertices.end( ); ++vIt )
- sinks.insert( vIt->first );
- auto mIt = this->m_AdjMatrix.begin( );
- for( ; mIt != this->m_AdjMatrix.end( ); ++mIt )
- sinks.erase( mIt->first );
+ std::set< std::string > sinks = this->m_Graph->GetSinks( );
// Update sinks
std::string err = "";
Execute( const std::string& name )
{
// Get filter
- auto vIt = this->m_Vertices.find( name );
- if( vIt == this->m_Vertices.end( ) )
- return(
- std::string( "cpPlugins::Interface::Workspace: No filter \"" ) +
- name + std::string( "\"" )
+ TFilter* f =
+ dynamic_cast< TFilter* >(
+ this->m_Graph->GetVertex( name ).GetPointer( )
);
- TFilter* f = dynamic_cast< TFilter* >( vIt->second.GetPointer( ) );
if( f == NULL )
return(
std::string( "cpPlugins::Interface::Workspace: Vertex \"" ) +