#include // ------------------------------------------------------------------------- cpPlugins::BaseObjects::Port:: Port( bool required ) : m_Required( required ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::Port:: ~Port( ) { } // ------------------------------------------------------------------------- bool cpPlugins::BaseObjects::Port:: IsRequired( ) const { return( this->m_Required ); } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::Port:: Clear( ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::SingleDataPort:: SingleDataPort( bool required ) : Superclass( required ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::SingleDataPort:: ~SingleDataPort( ) { } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::SingleDataPort:: Add( cpPlugins::BaseObjects::DataObject* o ) { if( this->m_Sample.IsNull( ) ) throw std::logic_error( "cpPlugins::SingleDataPort: Port not yet configured" ); if( o != NULL ) { if( this->m_Sample->IsCompatible( o ) ) this->m_Data = o; else throw std::logic_error( "cpPlugins::SingleDataPort: incompatible types \"" + std::string( typeid( *o ).name( ) ) + std::string( "\" and \"" ) + std::string( typeid( *( this->m_Sample.GetPointer( ) ) ).name( ) ) + std::string( "\"" ) ); } else this->m_Data = NULL; } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::SingleDataPort:: Get( unsigned int i ) { return( this->m_Data.GetPointer( ) ); } // ------------------------------------------------------------------------- const cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::SingleDataPort:: Get( unsigned int i ) const { return( this->m_Data.GetPointer( ) ); } // ------------------------------------------------------------------------- unsigned int cpPlugins::BaseObjects::SingleDataPort:: Size( ) const { return( 1 ); } // ------------------------------------------------------------------------- bool cpPlugins::BaseObjects::SingleDataPort:: IsValid( ) const { return( this->m_Data.IsNotNull( ) ); } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::SingleDataPort:: Clear( ) { this->m_Data = NULL; } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::OutputPort:: OutputPort( bool required ) : Superclass( required ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::OutputPort:: ~OutputPort( ) { } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::OutputPort:: Set( DataObject* o ) { this->m_Sample = o; this->m_Data = o; } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::InputPort:: InputPort( bool required ) : Superclass( required ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::InputPort:: ~InputPort( ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::MultipleInputsPort:: MultipleInputsPort( bool required ) : Superclass( required ) { } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::MultipleInputsPort:: ~MultipleInputsPort( ) { } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::MultipleInputsPort:: Add( cpPlugins::BaseObjects::DataObject* o ) { if( this->m_Sample.IsNull( ) ) throw std::logic_error( "cpPlugins::SingleDataPort: Port not yet configured" ); if( o != NULL ) { if( this->m_Sample->IsCompatible( o ) ) { this->m_Data.push_back( o ); } else throw std::logic_error( "cpPlugins::SingleDataPort: incompatible types \"" + std::string( typeid( *o ).name( ) ) + std::string( "\" and \"" ) + std::string( typeid( *( this->m_Sample.GetPointer( ) ) ).name( ) ) + std::string( "\"" ) ); } // fi } // ------------------------------------------------------------------------- cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::MultipleInputsPort:: Get( unsigned int i ) { if( i < this->m_Data.size( ) ) return( this->m_Data[ i ].GetPointer( ) ); else return( NULL ); } // ------------------------------------------------------------------------- const cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::MultipleInputsPort:: Get( unsigned int i ) const { if( i < this->m_Data.size( ) ) return( this->m_Data[ i ].GetPointer( ) ); else return( NULL ); } // ------------------------------------------------------------------------- unsigned int cpPlugins::BaseObjects::MultipleInputsPort:: Size( ) const { return( this->m_Data.size( ) ); } // ------------------------------------------------------------------------- bool cpPlugins::BaseObjects::MultipleInputsPort:: IsValid( ) const { if( this->m_Data.size( ) > 0 ) return( this->m_Data[ 0 ].IsNotNull( ) ); else return( false ); } // ------------------------------------------------------------------------- void cpPlugins::BaseObjects::MultipleInputsPort:: Clear( ) { this->m_Data.clear( ); } // eof - $RCSfile$