1 #include <cpPlugins/BaseObjects/Port.h>
3 // -------------------------------------------------------------------------
4 cpPlugins::BaseObjects::Port::
6 : m_Required( required )
10 // -------------------------------------------------------------------------
11 cpPlugins::BaseObjects::Port::
16 // -------------------------------------------------------------------------
17 bool cpPlugins::BaseObjects::Port::
20 return( this->m_Required );
23 // -------------------------------------------------------------------------
24 void cpPlugins::BaseObjects::Port::
29 // -------------------------------------------------------------------------
30 cpPlugins::BaseObjects::SingleDataPort::
31 SingleDataPort( bool required )
32 : Superclass( required )
36 // -------------------------------------------------------------------------
37 cpPlugins::BaseObjects::SingleDataPort::
42 // -------------------------------------------------------------------------
43 void cpPlugins::BaseObjects::SingleDataPort::
44 Add( cpPlugins::BaseObjects::DataObject* o )
46 if( this->m_Sample.IsNull( ) )
47 throw std::logic_error(
48 "cpPlugins::SingleDataPort: Port not yet configured"
52 if( this->m_Sample->IsCompatible( o ) )
55 throw std::logic_error(
56 "cpPlugins::SingleDataPort: incompatible types \"" +
57 std::string( typeid( *o ).name( ) ) + std::string( "\" and \"" ) +
58 std::string( typeid( *( this->m_Sample.GetPointer( ) ) ).name( ) ) +
66 // -------------------------------------------------------------------------
67 cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::SingleDataPort::
70 return( this->m_Data.GetPointer( ) );
73 // -------------------------------------------------------------------------
74 const cpPlugins::BaseObjects::DataObject* cpPlugins::BaseObjects::SingleDataPort::
75 Get( unsigned int i ) const
77 return( this->m_Data.GetPointer( ) );
80 // -------------------------------------------------------------------------
81 unsigned int cpPlugins::BaseObjects::SingleDataPort::
87 // -------------------------------------------------------------------------
88 bool cpPlugins::BaseObjects::SingleDataPort::
91 return( this->m_Data.IsNotNull( ) );
94 // -------------------------------------------------------------------------
95 void cpPlugins::BaseObjects::SingleDataPort::
101 // -------------------------------------------------------------------------
102 cpPlugins::BaseObjects::OutputPort::
103 OutputPort( bool required )
104 : Superclass( required )
108 // -------------------------------------------------------------------------
109 cpPlugins::BaseObjects::OutputPort::
114 // -------------------------------------------------------------------------
115 void cpPlugins::BaseObjects::OutputPort::
122 // -------------------------------------------------------------------------
123 cpPlugins::BaseObjects::InputPort::
124 InputPort( bool required )
125 : Superclass( required )
129 // -------------------------------------------------------------------------
130 cpPlugins::BaseObjects::InputPort::
135 // -------------------------------------------------------------------------
136 cpPlugins::BaseObjects::MultipleInputsPort::
137 MultipleInputsPort( bool required )
138 : Superclass( required )
142 // -------------------------------------------------------------------------
143 cpPlugins::BaseObjects::MultipleInputsPort::
144 ~MultipleInputsPort( )
148 // -------------------------------------------------------------------------
149 void cpPlugins::BaseObjects::MultipleInputsPort::
150 Add( cpPlugins::BaseObjects::DataObject* o )
152 if( this->m_Sample.IsNull( ) )
153 throw std::logic_error(
154 "cpPlugins::SingleDataPort: Port not yet configured"
158 if( this->m_Sample->IsCompatible( o ) )
160 this->m_Data.push_back( o );
163 throw std::logic_error(
164 "cpPlugins::SingleDataPort: incompatible types \"" +
165 std::string( typeid( *o ).name( ) ) + std::string( "\" and \"" ) +
166 std::string( typeid( *( this->m_Sample.GetPointer( ) ) ).name( ) ) +
173 // -------------------------------------------------------------------------
174 cpPlugins::BaseObjects::DataObject*
175 cpPlugins::BaseObjects::MultipleInputsPort::
176 Get( unsigned int i )
178 if( i < this->m_Data.size( ) )
179 return( this->m_Data[ i ].GetPointer( ) );
184 // -------------------------------------------------------------------------
185 const cpPlugins::BaseObjects::DataObject*
186 cpPlugins::BaseObjects::MultipleInputsPort::
187 Get( unsigned int i ) const
189 if( i < this->m_Data.size( ) )
190 return( this->m_Data[ i ].GetPointer( ) );
195 // -------------------------------------------------------------------------
196 unsigned int cpPlugins::BaseObjects::MultipleInputsPort::
199 return( this->m_Data.size( ) );
202 // -------------------------------------------------------------------------
203 bool cpPlugins::BaseObjects::MultipleInputsPort::
206 if( this->m_Data.size( ) > 0 )
207 return( this->m_Data[ 0 ].IsNotNull( ) );
212 // -------------------------------------------------------------------------
213 void cpPlugins::BaseObjects::MultipleInputsPort::
216 this->m_Data.clear( );