26 #include <sys/prctl.h>
34 #include <boost/shared_ptr.hpp>
36 #include "WModuleInputConnector.h"
37 #include "WModuleOutputConnector.h"
38 #include "WModuleInputData.h"
39 #include "WModuleOutputData.h"
40 #include "WModuleConnectorSignals.h"
41 #include "WModuleContainer.h"
42 #include "WModuleFactory.h"
43 #include "exceptions/WModuleSignalUnknown.h"
44 #include "exceptions/WModuleSignalSubscriptionFailed.h"
45 #include "exceptions/WModuleConnectorInitFailed.h"
46 #include "exceptions/WModuleConnectorNotFound.h"
47 #include "exceptions/WModuleUninitialized.h"
48 #include "exceptions/WModuleRequirementNotMet.h"
49 #include "../common/WException.h"
50 #include "../common/exceptions/WNameNotUnique.h"
51 #include "../common/WLogger.h"
52 #include "../common/WCondition.h"
53 #include "../common/WConditionOneShot.h"
54 #include "../common/WConditionSet.h"
55 #include "../common/WPathHelper.h"
56 #include "../common/WProgressCombiner.h"
57 #include "../common/WPredicateHelper.h"
71 m_readyProgress( boost::shared_ptr<
WProgress >( new
WProgress(
"Initializing Module" ) ) ),
77 m_infoProperties = boost::shared_ptr< WProperties >(
new WProperties(
"Informational Properties",
"Module's information properties" ) );
78 m_infoProperties->setPurpose( PV_PURPOSE_INFORMATION );
80 m_runtimeName =
m_properties->addProperty(
"Name",
"The name of the module defined by the user. This is, by default, the module name but "
81 "can be changed by the user to provide some kind of simple identification upon many modules.",
82 std::string(
"" ),
false );
84 m_active =
m_properties->addProperty(
"active",
"Determines whether the module should be activated.",
true,
true );
93 m_container = boost::shared_ptr< WModuleContainer >();
121 throw WNameNotUnique( std::string(
"Could not add the connector " + con->getCanonicalName() +
" since names must be unique." ) );
140 throw WNameNotUnique( std::string(
"Could not add the connector " + con->getCanonicalName() +
" since names must be unique." ) );
152 ( *listIter )->disconnectAll();
157 ( *listIter )->disconnectAll();
163 WCombinerTypes::WDisconnectList discons;
169 WCombinerTypes::WDisconnectGroup g = WCombinerTypes::WDisconnectGroup( ( *listIter )->getName(),
170 ( *listIter )->getPossibleDisconnections() );
172 if( g.second.size() )
174 discons.push_back( g );
182 WCombinerTypes::WDisconnectGroup g = WCombinerTypes::WDisconnectGroup( ( *listIter )->getName(),
183 ( *listIter )->getPossibleDisconnections() );
185 if( g.second.size() )
187 discons.push_back( g );
235 std::string(
". Reason: already initialized." ) );
273 return MODULE_ARBITRARY;
293 if( ( name == ( *listIter )->getCanonicalName() ) || ( name == ( *listIter )->getName() ) )
295 return ( *listIter );
299 return boost::shared_ptr< WModuleInputConnector >();
309 std::string(
"\" does not exist in the module \"" ) +
getName() + std::string(
"\"." ) );
322 if( ( name == ( *listIter )->getCanonicalName() ) || ( name == ( *listIter )->getName() ) )
324 return ( *listIter );
328 return boost::shared_ptr< WModuleOutputConnector >();
338 std::string(
"\" does not exist in the module \"" ) +
getName() +
339 std::string(
"\"." ) );
360 boost::shared_ptr< WModuleConnector > p =
findConnector( name );
365 std::string(
"\" does not exist in the module \"" ) +
getName() +
366 std::string(
"\"." ) );
379 std::ostringstream s;
380 s <<
"Could not subscribe to unknown signal.";
393 std::ostringstream s;
394 s <<
"Could not subscribe to unknown signal.";
404 case CONNECTION_ESTABLISHED:
406 case CONNECTION_CLOSED:
411 std::ostringstream s;
412 s <<
"Could not subscribe to unknown signal. You need to implement this signal type explicitly in your module.";
455 boost::shared_ptr< WModuleConnector > )
461 boost::shared_ptr< WModuleConnector > )
467 boost::shared_ptr< WModuleConnector > )
490 static const char * o_xpm[] =
511 if( !( *i )->isComplied() )
524 prctl( PR_SET_NAME, (
"openwalnut (" +
getName() +
")" ).c_str() );
552 catch(
const std::exception& e )