33 #include <boost/enable_shared_from_this.hpp>
36 #include <boost/filesystem.hpp>
39 #include <boost/function.hpp>
42 #include <boost/shared_ptr.hpp>
45 #include <boost/signals2/signal.hpp>
48 #include <boost/thread.hpp>
51 #include "../common/WConditionSet.h"
52 #include "../common/WLogger.h"
53 #include "../common/WProgress.h"
54 #include "../common/WProgressCombiner.h"
55 #include "../common/WProperties.h"
56 #include "../common/WPrototyped.h"
57 #include "../common/WRequirement.h"
58 #include "../common/WThreadedRunner.h"
59 #include "../dataHandler/WDataSet.h"
60 #include "../dataHandler/WDataSetSingle.h"
61 #include "../dataHandler/WValueSet.h"
63 #include "WModuleCombinerTypes.h"
64 #include "WModuleConnectorSignals.h"
65 #include "WModuleSignals.h"
66 #include "WModuleTypes.h"
67 #include "WModuleMetaInformation.h"
85 public boost::enable_shared_from_this< WModule >
121 typedef boost::shared_ptr< WModule >
SPtr;
143 boost::shared_ptr< WModuleInputConnector >
getInputConnector( std::string name );
190 boost::shared_ptr< WModuleConnector >
getConnector( std::string name );
200 boost::shared_ptr< WModuleConnector >
findConnector( std::string name );
302 virtual boost::shared_ptr< WModule >
factory()
const = 0;
314 virtual boost::signals2::connection
subscribeSignal( MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier );
328 virtual boost::signals2::connection
subscribeSignal( MODULE_SIGNAL signal, t_ModuleErrorSignalHandlerType notifier );
349 virtual MODULE_TYPE
getType()
const;
415 const std::string&
getUUID()
const;
506 void addConnector( boost::shared_ptr<WModuleInputConnector> con );
513 void addConnector( boost::shared_ptr<WModuleOutputConnector> con );
541 virtual const t_GenericSignalHandlerType
getSignalHandler( MODULE_CONNECTOR_SIGNAL signal );
550 boost::shared_ptr<WModuleConnector> there );
557 virtual void notifyConnectionClosed( boost::shared_ptr<WModuleConnector> here, boost::shared_ptr<WModuleConnector> there );
566 boost::shared_ptr<WModuleConnector> output );
619 void setLibPath( boost::filesystem::path path );
797 void setUUID( std::string uuid );
803 typedef std::vector< boost::shared_ptr< WModule > > WModuleList;
808 typedef void ( *W_LOADABLE_MODULE_SIGNATURE )( WModuleList& );
813 typedef void ( *W_LOADABLE_REGISTERARBITRARY_SIGNATURE )(
const boost::filesystem::path& );
822 #define W_LOADABLE_MODULE( MODULECLASS ) \
823 extern "C" void WLoadModule( WModuleList& m ) { m.push_back( boost::shared_ptr< WModule >( new MODULECLASS ) ); } // NOLINT
828 #define W_LOADABLE_MODULE_SYMBOL "WLoadModule"
833 #define W_LOADABLE_REGISTERARBITRARY_SYMBOL "WRegisterArbitrary"
t_ModuleErrorSignalType signal_error
Signal fired whenever a module main thread throws an exception/error.
virtual boost::signals2::connection subscribeSignal(MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier)
Connects a specified notify function with a signal this module instance is offering.
boost::shared_ptr< WModuleContainer > m_container
The container this module belongs to.
void reportRestoreComplete()
Called by loaders to tell the module that loading has been completed.
wlog::WStreamedLogger errorLog() const
Logger instance for comfortable error logging.
virtual void connectors()
Initialize connectors in this function.
virtual WModuleMetaInformation::ConstSPtr getMetaInformation() const
The meta information of this module.
Class able to create a new copy of an arbitrary module.
void setUUID(std::string uuid)
Set a uuid.
boost::shared_ptr< const WModule > ConstSPtr
Shared pointer to a const WModule.
WBoolFlag m_isReadyOrCrashed
It is true whenever m_isReady or WThreadedRunner::m_isCrashed is true.
void ready()
Call this whenever your module is ready and can react on property changes.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
std::vector< WRequirement * > Requirements
The type of the requirement list.
This is a simple class which forwards output data to output data connectors.
virtual void moduleMain()=0
Entry point after loading the module.
virtual void onThreadException(const WException &e)
This method is called if an exception was caught, which came from the custom thread code...
Loads module prototypes from shared objects in a given directory and injects it into the module facto...
boost::shared_ptr< WProperties > getProperties() const
Return a pointer to the properties object of the module.
void removeConnectors()
Removes all connectors properly.
Class representing a single module of OpenWalnut.
WBoolFlag m_isUsable
True if associated && initialized.
void setAssociatedContainer(boost::shared_ptr< WModuleContainer > container)
Sets the container this module is associated with.
std::vector< boost::shared_ptr< WModuleOutputConnector > > OutputConnectorList
The type for the list of output connectors.
void setLibPath(boost::filesystem::path path)
Set the path to the library which contains this module.
WModuleMetaInformation::SPtr m_meta
Lock for m_inputConnectors.
boost::shared_ptr< WModuleOutputConnector > getOutputConnector(std::string name)
Finds the named connector for the module.
WBoolFlag m_isRunning
True if the module currently is running.
std::string getPackageName() const
Returns the name of the package the module belongs to, The package name basically is the name of the ...
boost::shared_ptr< WModuleConnector > findConnector(std::string name)
Finds the named connector for the module.
bool isRestoreNeeded() const
Check whether this module is in restore mode.
boost::shared_ptr< WProperties > getInformationProperties() const
Return a pointer to the information properties object of the module.
boost::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
void waitRestored()
This method waits for the module to be restored completely.
boost::filesystem::path getLocalPath() const
Returns the local path of the module.
const WBoolFlag & isReadyOrCrashed() const
This is the logical or of isReady and isCrashed.
WCombinerTypes::WDisconnectList getPossibleDisconnections()
Gives a list of all WDisconnectCombiners possible.
virtual void notifyConnectionClosed(boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
Gets called whenever a connection between a remote and local connector gets closed.
static SPtr findByUUID(std::string uuid)
Find a module instance by UUID.
WPropBool m_active
True whenever the module should be active.
Class offering an instantiate-able data connection between modules.
virtual void activate()
Callback for m_active.
virtual void requirements()
Initialize requirements in this function.
Interface class for the concept "Prototype".
Base class for all classes needing to be executed in a separate thread.
const WBoolFlag & isReady() const
Checks whether this module is ready.
virtual void properties()
Initialize properties in this function.
void setRestoreNeeded(bool restore=true)
Change the restore mode.
WBoolFlag m_isReady
True if ready() was called.
virtual ~WModule()
Destructor.
boost::shared_ptr< WModuleContainer > getAssociatedContainer() const
The container this module is associated with.
Resource class for streamed logging.
Class allowing multiple conditions to be used for one waiting cycle.
const InputConnectorList & getInputConnectors() const
Gives back input connectors.
WBoolFlag m_isAssociated
True if container got associated with this flag.
boost::filesystem::path m_localPath
The path where the module binary resides in.
const OutputConnectorList & getOutputConnectors() const
Gives back output connectors.
Base class for all possible kinds of requirements.
boost::shared_ptr< WProperties > m_properties
The property object for the module.
void disconnect()
Completely disconnects all connected connectors of this module.
virtual MODULE_TYPE getType() const
Gets the type of the module.
boost::shared_ptr< WModuleOutputConnector > findOutputConnector(std::string name)
Finds the named connector for the module.
WModule()
Constructs a new WModule instance.
std::string m_packageName
The name of the lib/the package containing this module.
const WRequirement * checkRequirements() const
This method checks whether all the requirements of the module are complied.
boost::filesystem::path m_libPath
The absolute path to the library containing this module.
const WBoolFlag & isRunning() const
Returns a flag denoting whether the thread currently is running or nor.
virtual std::string deprecated() const
This function allows module programmers to mark their modules deprecated in a user-friendly way...
Class implementing output connection functionality between modules.
boost::filesystem::path getLibPath() const
Returns the absolute path to the library containing this module.
boost::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
void initialize()
Manages initialization.
boost::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION"...
WBoolFlag m_initialized
True if everything is initialized and ready to be used.
boost::shared_ptr< WModuleInputConnector > getInputConnector(std::string name)
Finds the named connector for the module.
std::vector< boost::shared_ptr< WModuleInputConnector > > InputConnectorList
The type for the list of input connectors.
const WBoolFlag & isUseable() const
Checks whether the module instance is ready to be used.
virtual boost::shared_ptr< WProgressCombiner > getRootProgressCombiner()
Gets the modules base progress.
virtual void cleanup()
Called whenever the module should shutdown.
WPropString m_runtimeName
This property holds a user specified name for the current module instance.
wlog::WStreamedLogger warnLog() const
Logger instance for comfortable warning- logs.
boost::shared_ptr< WModuleConnector > getConnector(std::string name)
Finds the named connector for the module.
std::string getDeprecationMessage() const
Queries the deprecation message of a module if specified.
void setPackageName(std::string name)
Set the package name.
const std::string & getUUID() const
Get the UUID of the module instance.
virtual boost::shared_ptr< WModule > factory() const =0
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
InputConnectorList m_inputConnectors
Set of input connectors associated with this module.
const WBoolFlag & isAssociated() const
Checks whether this module is associated with an container.
virtual void notifyConnectionEstablished(boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
Gets called whenever a connector gets connected to the specified input.
void setLocalPath(boost::filesystem::path path)
Sets the local module path.
t_ModuleGenericSignalType signal_ready
Signal fired whenever a module main thread is ready.
Class able to contain other modules.
Requirements m_requirements
The list of requirements.
WBoolFlag m_isLoadFinished
Flag to denote whether the module container and the project loader have finished their work...
const WBoolFlag & isInitialized() const
Determines whether the module instance is properly initialized.
bool m_restoreMode
Flag denoting the current restore mode.
Base class for modelling connections between kernel modules.
WConditionSet m_moduleState
The internal state of the module.
virtual void notifyDataChange(boost::shared_ptr< WModuleConnector > input, boost::shared_ptr< WModuleConnector > output)
Gets called when the data on one input connector changed.
void addConnector(boost::shared_ptr< WModuleInputConnector > con)
Adds the specified connector to the list of inputs.
boost::shared_ptr< WModuleInputConnector > findInputConnector(std::string name)
Finds the named connector for the module.
void threadMain()
Thread entry point.
boost::shared_ptr< WProgress > m_readyProgress
Progress indicator for the "ready" state.
bool isDeprecated() const
Checks whether the module was marked as deprecated.
std::string m_uuid
The unique ID of the module instance.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
OutputConnectorList m_outputConnectors
Set of output connectors associated with this module.
virtual const t_GenericSignalHandlerType getSignalHandler(MODULE_CONNECTOR_SIGNAL signal)
Gives the signal handler function responsible for a given signal.