25 #ifndef WMODULEINPUTDATA_H
26 #define WMODULEINPUTDATA_H
29 #include <shared_mutex>
32 #include <boost/thread/locks.hpp>
34 #include "../common/WPrototyped.h"
35 #include "../common/WTransferable.h"
36 #include "WModuleInputConnector.h"
37 #include "WModuleOutputConnector.h"
38 #include "WModuleOutputData.h"
39 #include "exceptions/WModuleConnectorUnconnected.h"
45 template <
typename T >
52 typedef std::shared_ptr< WModuleInputData< T > >
PtrType;
57 typedef std::shared_ptr< WModuleInputData< T > >
SPtr;
62 typedef std::shared_ptr< const WModuleInputData< T > >
ConstSPtr;
88 static PtrType create( std::shared_ptr< WModule > module, std::string name =
"", std::string description =
"" );
100 static PtrType createAndAdd( std::shared_ptr< WModule > module, std::string name =
"", std::string description =
"" );
109 WModuleInputData( std::shared_ptr< WModule > module, std::string name =
"", std::string description =
"" ):
128 virtual void disconnect( std::shared_ptr<WModuleConnector> con,
bool removeFromOwnList =
true );
137 const std::shared_ptr< T >
getData(
bool reset =
true )
140 boost::shared_lock<std::shared_mutex> lock = boost::shared_lock<std::shared_mutex>(
m_connectionListLock );
152 return std::shared_ptr< T >();
156 std::shared_ptr< T > dat = std::dynamic_pointer_cast< T >(
157 std::dynamic_pointer_cast< WModuleOutputConnector >( *
m_connected.begin() )->getRawData()
185 std::shared_ptr< WPrototyped > tProto =
189 return dynamic_cast< T*
>( tProto.get() );
200 template <
typename T >
203 m_disconnecting =
true;
205 m_disconnecting =
false;
208 template <
typename T >
210 std::string description )
214 return PTR(
new TYPE( module, name, description ) );
217 template <
typename T >
219 std::string description )
222 module->addConnector( c );
virtual void disconnect(std::shared_ptr< WModuleConnector > con, bool removeFromOwnList=true)
Disconnects this connector if connected.
std::set< std::shared_ptr< WModuleConnector > > m_connected
List of connectors connected to this connector.
std::shared_mutex m_connectionListLock
Lock for avoiding concurrent write to m_Connected (multiple reader, single writer lock).
Class implementing output connection functionality between modules.