Commit 5148c908 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added convenience methods to output forwarder

parent 977a5b67
......@@ -78,6 +78,7 @@ friend class WModuleConnector; // requires access to notify members
template< typename T > friend class WModuleInputData; // requires access for convenience functions to automatically add a created connector
template< typename T > friend class WModuleInputForwardData; // requires access for convenience functions to automatically add a created connector
template< typename T > friend class WModuleOutputData; // requires access for convenience functions to automatically add a created connector
template< typename T > friend class WModuleOutputForwardData; // requires access for convenience functions to automatically add a created connector
friend class WModuleFactory; // for proper creation of module instances, the factory needs access to protected functions.
// (especially initialize)
friend class WModuleContainer; // for proper management of m_container WModuleContainer needs access.
......
......@@ -43,6 +43,59 @@ template< typename T >
class WModuleOutputForwardData: public WModuleOutputData< T >
{
public:
/**
* Pointer to this. For convenience.
*/
typedef boost::shared_ptr< WModuleOutputForwardData< T > > SPtr;
/**
* Pointer to this. For convenience.
*/
typedef boost::shared_ptr< const WModuleOutputForwardData< T > > ConstSPtr;
/**
* Pointer to this. For convenience.
*/
typedef SPtr PtrType;
/**
* Reference to this type.
*/
typedef WModuleOutputForwardData< T >& RefType;
/**
* Type of the connector.
*/
typedef WModuleOutputForwardData< T > Type;
/**
* Typedef to the contained transferable.
*/
typedef T TransferType;
/**
* Convenience method to create a new instance of this out data connector with proper type.
*
* \param module the module owning this instance
* \param name the name of this connector.
* \param description the description of this connector.
*
* \return the pointer to the created connector.
*/
static PtrType create( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" );
/**
* Convenience method to create a new instance of this out data connector with proper type and add it to the list of connectors of the
* specified module.
*
* \param module the module owning this instance
* \param name the name of this connector.
* \param description the description of this connector.
*
* \return the pointer to the created connector.
*/
static PtrType createAndAdd( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" );
/**
* Constructor. This creates a new output data connector which is able to forward data changes <b>FROM</b> other output data connectors.
*
......@@ -107,5 +160,23 @@ protected:
private:
};
template < typename T >
typename WModuleOutputForwardData< T >::PtrType WModuleOutputForwardData< T >::create( boost::shared_ptr< WModule > module, std::string name,
std::string description )
{
typedef typename WModuleOutputForwardData< T >::PtrType PTR;
typedef typename WModuleOutputForwardData< T >::Type TYPE;
return PTR( new TYPE( module, name, description ) );
}
template < typename T >
typename WModuleOutputForwardData< T >::PtrType WModuleOutputForwardData< T >::createAndAdd( boost::shared_ptr< WModule > module, std::string name,
std::string description )
{
typename WModuleOutputForwardData< T >::PtrType c = create( module, name, description );
module->addConnector( c );
return c;
}
#endif // WMODULEOUTPUTFORWARDDATA_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment