X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPorts.h;fp=lib%2FcpPlugins%2FPorts.h;h=cb133298726ce7363d2fa6f0df0001bdf053709c;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=0000000000000000000000000000000000000000;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpPlugins/Ports.h b/lib/cpPlugins/Ports.h new file mode 100644 index 0000000..cb13329 --- /dev/null +++ b/lib/cpPlugins/Ports.h @@ -0,0 +1,128 @@ +// ========================================================================= +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ========================================================================= +#ifndef __cpPlugins__Ports__h__ +#define __cpPlugins__Ports__h__ + +#include +#include + +namespace cpPlugins +{ + class Object; + class DataObject; + class Functor; + + /** + */ + class CPPLUGINS_EXPORT BasePort + { + public: + BasePort( ); + virtual ~BasePort( ); + }; // end class + + /** + */ + class CPPLUGINS_EXPORT InputPort + : public BasePort + { + public: + typedef InputPort Self; + typedef BasePort Superclass; + + typedef std::shared_ptr< DataObject > SharedPtr; + typedef std::weak_ptr< DataObject > WeakPtr; + + public: + InputPort( ); + virtual ~InputPort( ); + + template< class _TObject > + void Configure( bool required, bool multiple ) + { + this->m_Required = required; + this->m_Multiple = multiple; + this->m_Data.clear( ); + this->m_Template = _TObject::New( ); + } + + DataObject* Get( const unsigned int& i ); + const DataObject* Get( const unsigned int& i ) const; + unsigned int Count( ) const; + bool IsValid( ) const; + bool Set( DataObject* data ); + bool Update( ); + + protected: + std::vector< SharedPtr > m_Data; + SharedPtr m_Template; + bool m_Required; + bool m_Multiple; + }; // end class + + /** + */ + class CPPLUGINS_EXPORT OutputPort + : public BasePort + { + public: + typedef OutputPort Self; + typedef BasePort Superclass; + + typedef std::shared_ptr< DataObject > SharedPtr; + typedef std::weak_ptr< DataObject > WeakPtr; + + public: + OutputPort( ); + virtual ~OutputPort( ); + + DataObject* Get( ); + const DataObject* Get( ) const; + + template< class _TObject > + void Configure( ) + { + this->m_Data = _TObject::New( ); + } + + protected: + SharedPtr m_Data; + }; // end class + + /** + */ + class CPPLUGINS_EXPORT FunctorPort + : public BasePort + { + public: + typedef FunctorPort Self; + typedef BasePort Superclass; + + typedef std::shared_ptr< Functor > SharedPtr; + typedef std::weak_ptr< Functor > WeakPtr; + + public: + FunctorPort( ); + virtual ~FunctorPort( ); + + template< class _TFunctor > + void Configure( bool required ) + { + this->m_Required = required; + } + + Functor* Get( ); + const Functor* Get( ) const; + bool Set( Functor* f ); + bool Update( ); + + protected: + SharedPtr m_Functor; + bool m_Required; + }; // end class +} // end namespace + +#endif // __cpPlugins__Ports__h__ + +// eof - $RCSfile$