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