OpenWalnut  1.3.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
WModuleContainer Class Reference

Class able to contain other modules. More...

#include <WModuleContainer.h>

+ Inheritance diagram for WModuleContainer:

Public Types

typedef std::vector
< boost::shared_ptr< WModule > > 
ModuleVectorType
 A vector of modules. More...
 
typedef std::set
< boost::shared_ptr< WModule > > 
ModuleContainerType
 For shortening: a type defining a shared vector of WModule pointers. More...
 
typedef WSharedObject
< ModuleContainerType
ModuleSharedContainerType
 The alias for a shared container. More...
 
typedef
ModuleContainerType::const_iterator 
ModuleConstIterator
 The const iterator type of the container. More...
 
typedef
ModuleContainerType::iterator 
ModuleIterator
 The iterator type of the container. More...
 
typedef std::set
< boost::shared_ptr
< WDataModule > > 
DataModuleListType
 Simple type for WDataModule pointer lists. More...
 
- Public Types inherited from WModule
typedef std::vector
< boost::shared_ptr
< WModuleInputConnector > > 
InputConnectorList
 The type for the list of input connectors. More...
 
typedef std::vector
< boost::shared_ptr
< WModuleOutputConnector > > 
OutputConnectorList
 The type for the list of output connectors. More...
 
typedef boost::shared_ptr
< WModule
SPtr
 Shared pointer to a WModule. More...
 
typedef boost::shared_ptr
< const WModule
ConstSPtr
 Shared pointer to a const WModule. More...
 
- Public Types inherited from WThreadedRunner
typedef boost::function< void(void) > THREADFUNCTION
 Type used for simple thread functions. More...
 

Public Member Functions

 WModuleContainer (std::string name="Unnamed Module Container", std::string description="Used as container for several modules.")
 Constructor. More...
 
virtual ~WModuleContainer ()
 Destructor. More...
 
virtual void add (boost::shared_ptr< WModule > module, bool run=true)
 Add a module to this container and start it. More...
 
virtual WModule::SPtr createAndAdd (std::string name)
 Convenience method to create a module instance with a given name and automatically add it to the container. More...
 
virtual void remove (boost::shared_ptr< WModule > module)
 Remove the given module from this container if it is associated with it. More...
 
virtual void stop ()
 Stops all modules inside this container. More...
 
virtual const std::string getName () const
 Gives back the name of this module. More...
 
virtual const std::string getDescription () const
 Gives back a description of this module. More...
 
virtual void addDefaultNotifier (MODULE_SIGNAL signal, t_ModuleErrorSignalHandlerType notifier)
 Add a specified notifier to the list of default notifiers which get connected to each added module. More...
 
virtual void addDefaultNotifier (MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier)
 Add a specified notifier to the list of default notifiers which get connected to each added module. More...
 
virtual void addDefaultNotifier (MODULE_CONNECTOR_SIGNAL signal, t_GenericSignalHandlerType notifier)
 Add a specified notifier to the list of default notifiers which get connected to each added module. More...
 
virtual boost::shared_ptr
< WModule
applyModule (boost::shared_ptr< WModule > applyOn, std::string what, bool tryOnly=false)
 Function combines two modules. More...
 
virtual boost::shared_ptr
< WModule
applyModule (boost::shared_ptr< WModule > applyOn, boost::shared_ptr< WModule > prototype)
 Function combines two modules. More...
 
WBatchLoader::SPtr loadDataSets (std::vector< std::string > filenames, bool suppressColormaps=false)
 Load specified datasets. More...
 
WBatchLoader::SPtr loadDataSetsSynchronously (std::vector< std::string > filenames, bool suppressColormaps=false)
 Loads the specified files synchronously. More...
 
void addPendingThread (boost::shared_ptr< WThreadedRunner > thread)
 Add the specified thread to the list of pending jobs. More...
 
void finishedPendingThread (boost::shared_ptr< WThreadedRunner > thread)
 The specified thread has finished and does not longer depend upon this container instance. More...
 
void setCrashIfModuleCrashes (bool crashIfCrashed=true)
 Sets a flag denoting whether the container (which also is a module) should be marked as "crashed" if a nested module crashes. More...
 
virtual boost::shared_ptr
< WModule
factory () const
 Due to the prototype design pattern used to build modules, this method returns a new instance of this method. More...
 
DataModuleListType getDataModules ()
 Returns a vector of pointers to the loaded data modules in the container. More...
 
ModuleSharedContainerType::ReadTicket getModules () const
 Method returns a read ticket allowing read-access to the list of modules inside the container. More...
 
ModuleVectorType getModules (std::string name) const
 Queries the container to find all modules with a given name. More...
 
WCombinerTypes::WCompatiblesList getPossibleConnections (boost::shared_ptr< WModule > module)
 This method creates a list of combiner instances, for each possible connection that can be made between the specified module and the module currently inside the container. More...
 
- Public Member Functions inherited from WModule
 WModule ()
 Constructs a new WModule instance. More...
 
virtual ~WModule ()
 Destructor. More...
 
const InputConnectorListgetInputConnectors () const
 Gives back input connectors. More...
 
boost::shared_ptr
< WModuleInputConnector
getInputConnector (std::string name)
 Finds the named connector for the module. More...
 
boost::shared_ptr
< WModuleInputConnector
findInputConnector (std::string name)
 Finds the named connector for the module. More...
 
const OutputConnectorListgetOutputConnectors () const
 Gives back output connectors. More...
 
boost::shared_ptr
< WModuleOutputConnector
getOutputConnector (std::string name)
 Finds the named connector for the module. More...
 
boost::shared_ptr
< WModuleOutputConnector
findOutputConnector (std::string name)
 Finds the named connector for the module. More...
 
boost::shared_ptr
< WModuleConnector
getConnector (std::string name)
 Finds the named connector for the module. More...
 
boost::shared_ptr
< WModuleConnector
findConnector (std::string name)
 Finds the named connector for the module. More...
 
boost::shared_ptr< WPropertiesgetProperties () const
 Return a pointer to the properties object of the module. More...
 
boost::shared_ptr< WPropertiesgetInformationProperties () const
 Return a pointer to the information properties object of the module. More...
 
const WBoolFlagisInitialized () const
 Determines whether the module instance is properly initialized. More...
 
const WBoolFlagisUseable () const
 Checks whether the module instance is ready to be used. More...
 
const WBoolFlagisAssociated () const
 Checks whether this module is associated with an container. More...
 
const WBoolFlagisReady () const
 Checks whether this module is ready. More...
 
const WBoolFlagisReadyOrCrashed () const
 This is the logical or of isReady and isCrashed. More...
 
const WBoolFlagisRunning () const
 Returns a flag denoting whether the thread currently is running or nor. More...
 
boost::shared_ptr
< WModuleContainer
getAssociatedContainer () const
 The container this module is associated with. More...
 
virtual boost::signals2::connection subscribeSignal (MODULE_SIGNAL signal, t_ModuleGenericSignalHandlerType notifier)
 Connects a specified notify function with a signal this module instance is offering. More...
 
virtual boost::signals2::connection subscribeSignal (MODULE_SIGNAL signal, t_ModuleErrorSignalHandlerType notifier)
 Connects a specified notify function with a signal this module instance is offering. More...
 
virtual boost::shared_ptr
< WProgressCombiner
getRootProgressCombiner ()
 Gets the modules base progress. More...
 
virtual const char ** getXPMIcon () const
 Get the icon for this module in XPM format. More...
 
virtual MODULE_TYPE getType () const
 Gets the type of the module. More...
 
void disconnect ()
 Completely disconnects all connected connectors of this module. More...
 
WCombinerTypes::WDisconnectList getPossibleDisconnections ()
 Gives a list of all WDisconnectCombiners possible. More...
 
boost::filesystem::path getLocalPath () const
 Returns the local path of the module. More...
 
boost::filesystem::path getLibPath () const
 Returns the absolute path to the library containing this module. More...
 
std::string getPackageName () const
 Returns the name of the package the module belongs to, The package name basically is the name of the library containing this and maybe other modules. More...
 
bool isDeprecated () const
 Checks whether the module was marked as deprecated. More...
 
std::string getDeprecationMessage () const
 Queries the deprecation message of a module if specified. More...
 
virtual
WModuleMetaInformation::ConstSPtr 
getMetaInformation () const
 The meta information of this module. More...
 
- Public Member Functions inherited from WThreadedRunner
 WThreadedRunner ()
 Default constructor. More...
 
virtual ~WThreadedRunner ()
 Destructor. More...
 
virtual void run ()
 Run thread. More...
 
void run (THREADFUNCTION f)
 Run thread. More...
 
void wait (bool requestFinish=false)
 Wait for the thread to be finished. More...
 
virtual void requestStop ()
 This method's purpose is to request a stop without waiting for it. More...
 
virtual boost::signals2::connection subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier)
 Connects a specified notify function with a signal this thread instance is offering. More...
 
const WBoolFlagisCrashed () const
 Checks whether this thread has been crashed. More...
 
const std::string & getCrashMessage () const
 Get the message of the exception finally causing the crash. More...
 
void setThreadName (std::string name)
 Set the name of the thread. More...
 
std::string getThreadName () const
 Returns the current thread name. More...
 
- Public Member Functions inherited from WPrototyped
 WPrototyped ()
 Default constructor. More...
 
virtual ~WPrototyped ()
 Destructor. More...
 
template<typename T >
bool isA ()
 Checks whether the actual prototype has the specified runtime type. More...
 

Protected Member Functions

virtual void moduleMain ()
 Entry point after loading the module. More...
 
virtual void moduleError (boost::shared_ptr< WModule > module, const WException &exception)
 This method is called whenever a module inside the container crashes. More...
 
- Protected Member Functions inherited from WModule
void threadMain ()
 Thread entry point. More...
 
virtual void onThreadException (const WException &e)
 This method is called if an exception was caught, which came from the custom thread code. More...
 
void setAssociatedContainer (boost::shared_ptr< WModuleContainer > container)
 Sets the container this module is associated with. More...
 
virtual void connectors ()
 Initialize connectors in this function. More...
 
virtual void properties ()
 Initialize properties in this function. More...
 
virtual void requirements ()
 Initialize requirements in this function. More...
 
virtual std::string deprecated () const
 This function allows module programmers to mark their modules deprecated in a user-friendly way. More...
 
void initialize ()
 Manages connector initialization. More...
 
virtual void cleanup ()
 Called whenever the module should shutdown. More...
 
void addConnector (boost::shared_ptr< WModuleInputConnector > con)
 Adds the specified connector to the list of inputs. More...
 
void addConnector (boost::shared_ptr< WModuleOutputConnector > con)
 Adds the specified connector to the list of outputs. More...
 
void removeConnectors ()
 Removes all connectors properly. More...
 
virtual void activate ()
 Callback for m_active. More...
 
virtual const
t_GenericSignalHandlerType 
getSignalHandler (MODULE_CONNECTOR_SIGNAL signal)
 Gives the signal handler function responsible for a given signal. More...
 
virtual void notifyConnectionEstablished (boost::shared_ptr< WModuleConnector > here, boost::shared_ptr< WModuleConnector > there)
 Gets called whenever a connector gets connected to the specified input. More...
 
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. More...
 
virtual void notifyDataChange (boost::shared_ptr< WModuleConnector > input, boost::shared_ptr< WModuleConnector > output)
 Gets called when the data on one input connector changed. More...
 
void ready ()
 Call this whenever your module is ready and can react on property changes. More...
 
wlog::WStreamedLogger infoLog () const
 Logger instance for comfortable info logging. More...
 
wlog::WStreamedLogger debugLog () const
 Logger instance for comfortable debug logging. More...
 
wlog::WStreamedLogger warnLog () const
 Logger instance for comfortable warning- logs. More...
 
wlog::WStreamedLogger errorLog () const
 Logger instance for comfortable error logging. More...
 
void setLocalPath (boost::filesystem::path path)
 Sets the local module path. More...
 
void setLibPath (boost::filesystem::path path)
 Set the path to the library which contains this module. More...
 
void setPackageName (std::string name)
 Set the package name. More...
 
- Protected Member Functions inherited from WThreadedRunner
virtual void notifyStop ()
 Gets called when the thread should be stopped. More...
 
void yield () const
 Give remaining execution timeslice to another thread. More...
 
void sleep (const int32_t t) const
 Sets thread asleep. More...
 
void msleep (const int32_t t) const
 Sets thread asleep. More...
 
void waitForStop ()
 Let the thread sleep until a stop request was given. More...
 
void handleDeadlyException (const WException &e, std::string sender="WThreadedRunner")
 Handle the specified exception which was not caught in the thread, which basically means the thread has crashed. More...
 

Protected Attributes

ModuleSharedContainerType m_modules
 The modules associated with this container. More...
 
std::string m_name
 Name of the module. More...
 
std::string m_description
 Description of the module. More...
 
boost::shared_mutex m_errorNotifiersLock
 Lock for error notifiers set. More...
 
std::list
< t_ModuleErrorSignalHandlerType > 
m_errorNotifiers
 The error notifiers connected to added modules by default. More...
 
boost::shared_mutex m_readyNotifiersLock
 Lock for ready notifiers set. More...
 
std::list
< t_ModuleGenericSignalHandlerType > 
m_readyNotifiers
 The ready notifiers connected to added modules by default. More...
 
boost::shared_mutex m_associatedNotifiersLock
 Lock for associated notifiers set. More...
 
std::list
< t_ModuleGenericSignalHandlerType > 
m_associatedNotifiers
 The notifiers connected to added modules by default and fired whenever the module got associated. More...
 
boost::shared_mutex m_removedNotifiersLock
 Lock for remove-notifiers set. More...
 
std::list
< t_ModuleGenericSignalHandlerType > 
m_removedNotifiers
 The notifiers connected to added modules by default and fired whenever the module got removed again. More...
 
boost::shared_mutex m_connectorNotifiersLock
 Lock for connector-notifiers set. More...
 
std::list
< t_GenericSignalHandlerType > 
m_connectorEstablishedNotifiers
 The notifiers connected to added modules by default and fired whenever the module connectors got connected. More...
 
std::list
< t_GenericSignalHandlerType > 
m_connectorClosedNotifiers
 The notifiers connected to added modules by default and fired whenever the module connectors got disconnected. More...
 
std::set< boost::shared_ptr
< WThreadedRunner > > 
m_pendingThreads
 Set of all threads that currently depend upon this container. More...
 
boost::shared_mutex m_pendingThreadsLock
 Lock for m_pendingThreads. More...
 
bool m_crashIfModuleCrashes
 This flag denotes whether the whole container should be marked as crashed if one of the contained modules crashes. More...
 
- Protected Attributes inherited from WModule
boost::shared_ptr< WPropertiesm_properties
 The property object for the module. More...
 
boost::shared_ptr< WPropertiesm_infoProperties
 The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION". More...
 
boost::shared_ptr
< WProgressCombiner
m_progress
 Progress indicator used as parent for all progress' of this module. More...
 
WBoolFlag m_initialized
 True if everything is initialized and ready to be used. More...
 
WBoolFlag m_isAssociated
 True if container got associated with this flag. More...
 
WBoolFlag m_isUsable
 True if associated && initialized. More...
 
WBoolFlag m_isReady
 True if ready() was called. More...
 
WBoolFlag m_isReadyOrCrashed
 It is true whenever m_isReady or WThreadedRunner::m_isCrashed is true. More...
 
WBoolFlag m_isRunning
 True if the module currently is running. More...
 
boost::shared_ptr< WProgressm_readyProgress
 Progress indicator for the "ready" state. More...
 
WConditionSet m_moduleState
 The internal state of the module. More...
 
boost::shared_ptr
< WModuleContainer
m_container
 The container this module belongs to. More...
 
InputConnectorList m_inputConnectors
 Set of input connectors associated with this module. More...
 
OutputConnectorList m_outputConnectors
 Set of output connectors associated with this module. More...
 
WPropBool m_active
 True whenever the module should be active. More...
 
WPropString m_runtimeName
 This property holds a user specified name for the current module instance. More...
 
boost::filesystem::path m_localPath
 The path where the module binary resides in. More...
 
boost::filesystem::path m_libPath
 The absolute path to the library containing this module. More...
 
std::string m_packageName
 The name of the lib/the package containing this module. More...
 
Requirements m_requirements
 The list of requirements. More...
 
- Protected Attributes inherited from WThreadedRunner
boost::thread m_thread
 Thread instance. More...
 
WBoolFlag m_shutdownFlag
 Condition getting fired whenever the thread should quit. More...
 
WBoolFlag m_isCrashed
 True whenever an exception is thrown during threadMain. More...
 
std::string m_crashMessage
 The crash message. More...
 

Private Types

typedef std::pair
< boost::shared_ptr< WModule >
, boost::signals2::connection > 
ModuleSubscription
 A type for mapping a module to all its subscriptions. More...
 
typedef std::multimap
< boost::shared_ptr< WModule >
, boost::signals2::connection > 
ModuleSubscriptionsType
 For shortening: a type defining a shared vector of subscriptions a module made to a notifier during add(). More...
 
typedef WSharedObject
< ModuleSubscriptionsType
ModuleSubscriptionsSharedType
 The alias for a shared container. More...
 
typedef
ModuleSubscriptionsType::const_iterator 
ModuleSubscriptionsConstIterator
 The const iterator type of the container. More...
 
typedef
ModuleSubscriptionsType::iterator 
ModuleSubscriptionsIterator
 The iterator type of the container. More...
 

Private Attributes

ModuleSubscriptionsSharedType m_moduleSubscriptions
 The module's signal subscriptions. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from WThreadedRunner
static void setThisThreadName (std::string name)
 Static function to set the name of the calling thread. More...
 
- Protected Types inherited from WModule
typedef std::vector
< WRequirement * > 
Requirements
 The type of the requirement list. More...
 

Detailed Description

Class able to contain other modules.

It manages several tasks like finding appropriate modules, managing data modules and module initialization.

Definition at line 59 of file WModuleContainer.h.

Member Typedef Documentation

typedef std::set< boost::shared_ptr< WDataModule > > WModuleContainer::DataModuleListType

Simple type for WDataModule pointer lists.

Definition at line 262 of file WModuleContainer.h.

typedef ModuleContainerType::const_iterator WModuleContainer::ModuleConstIterator

The const iterator type of the container.

Definition at line 82 of file WModuleContainer.h.

typedef std::set< boost::shared_ptr< WModule > > WModuleContainer::ModuleContainerType

For shortening: a type defining a shared vector of WModule pointers.

Definition at line 72 of file WModuleContainer.h.

typedef ModuleContainerType::iterator WModuleContainer::ModuleIterator

The iterator type of the container.

Definition at line 87 of file WModuleContainer.h.

The alias for a shared container.

Definition at line 77 of file WModuleContainer.h.

typedef std::pair< boost::shared_ptr< WModule >, boost::signals2::connection > WModuleContainer::ModuleSubscription
private

A type for mapping a module to all its subscriptions.

Definition at line 409 of file WModuleContainer.h.

typedef ModuleSubscriptionsType::const_iterator WModuleContainer::ModuleSubscriptionsConstIterator
private

The const iterator type of the container.

Definition at line 424 of file WModuleContainer.h.

typedef ModuleSubscriptionsType::iterator WModuleContainer::ModuleSubscriptionsIterator
private

The iterator type of the container.

Definition at line 429 of file WModuleContainer.h.

The alias for a shared container.

Definition at line 419 of file WModuleContainer.h.

typedef std::multimap< boost::shared_ptr< WModule >, boost::signals2::connection > WModuleContainer::ModuleSubscriptionsType
private

For shortening: a type defining a shared vector of subscriptions a module made to a notifier during add().

Definition at line 414 of file WModuleContainer.h.

typedef std::vector< boost::shared_ptr< WModule > > WModuleContainer::ModuleVectorType

A vector of modules.

Definition at line 67 of file WModuleContainer.h.

Constructor & Destructor Documentation

WModuleContainer::WModuleContainer ( std::string  name = "Unnamed Module Container",
std::string  description = "Used as container for several modules." 
)

Constructor.

Initializes container.

Parameters
namename of the container
descriptionshort description.

Definition at line 49 of file WModuleContainer.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), and getName().

Referenced by factory().

WModuleContainer::~WModuleContainer ( )
virtual

Destructor.

Definition at line 59 of file WModuleContainer.cpp.

Member Function Documentation

void WModuleContainer::add ( boost::shared_ptr< WModule module,
bool  run = true 
)
virtual

Add a module to this container and start it.

Please note, that a module can be added only once. If it already is associated with this container nothing happens.

Parameters
modulethe module to add.
runtrue when the module should be run automatically after adding it.
Exceptions
WModuleUninitializedthrown whenever someone wants to add a module not yet initialized.

Definition at line 77 of file WModuleContainer.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), getName(), WSharedObject< T >::getWriteTicket(), m_associatedNotifiers, m_associatedNotifiersLock, m_connectorClosedNotifiers, m_connectorEstablishedNotifiers, m_connectorNotifiersLock, m_errorNotifiers, m_errorNotifiersLock, m_modules, m_moduleSubscriptions, WModule::m_progress, m_readyNotifiers, m_readyNotifiersLock, and moduleError().

Referenced by applyModule(), and createAndAdd().

void WModuleContainer::addDefaultNotifier ( MODULE_SIGNAL  signal,
t_ModuleErrorSignalHandlerType  notifier 
)
virtual

Add a specified notifier to the list of default notifiers which get connected to each added module.

Parameters
signalthe signal the notifier should get connected to
notifierthe notifier function

Definition at line 343 of file WModuleContainer.cpp.

References m_errorNotifiers, and m_errorNotifiersLock.

void WModuleContainer::addDefaultNotifier ( MODULE_SIGNAL  signal,
t_ModuleGenericSignalHandlerType  notifier 
)
virtual

Add a specified notifier to the list of default notifiers which get connected to each added module.

Parameters
signalthe signal the notifier should get connected to
notifierthe notifier function

Definition at line 315 of file WModuleContainer.cpp.

References m_associatedNotifiers, m_associatedNotifiersLock, m_readyNotifiers, m_readyNotifiersLock, m_removedNotifiers, and m_removedNotifiersLock.

void WModuleContainer::addDefaultNotifier ( MODULE_CONNECTOR_SIGNAL  signal,
t_GenericSignalHandlerType  notifier 
)
virtual

Add a specified notifier to the list of default notifiers which get connected to each added module.

This is especially used for all the connector related events like connect and disconnect.

Notes:
This signal is only called for input connectors!
Parameters
signalthe signal the notifier should get connected to
notifierthe notifier function

Definition at line 361 of file WModuleContainer.cpp.

References m_connectorClosedNotifiers, m_connectorEstablishedNotifiers, and m_connectorNotifiersLock.

void WModuleContainer::addPendingThread ( boost::shared_ptr< WThreadedRunner thread)

Add the specified thread to the list of pending jobs.

Only this ensures, that ALL pending threads get stopped before the container gets stopped.

Notes:
use this to register threads whenever you start threads belonging to this container. This avoids shutting down the container while other threads depend upon it.
Parameters
threadthe thread to add

Definition at line 462 of file WModuleContainer.cpp.

References m_pendingThreads, and m_pendingThreadsLock.

boost::shared_ptr< WModule > WModuleContainer::applyModule ( boost::shared_ptr< WModule applyOn,
std::string  what,
bool  tryOnly = false 
)
virtual

Function combines two modules.

This runs synchronously. It might take some time to finish since combination of modules is allowed only with modules marked as "ready" which might take some time.

Parameters
applyOnthe module which already has to be in the container and to apply the other one on.
whatthe prototype name of the module to apply on the other one specified.
tryOnlyIf set to false and the prototype "what" does not exist this will throw an exception. If set to true and the prototype does not exist, the nothing will happen.
Returns
the newly created module connected with the one specified in applyOn. If the prototype could not be found and tryOnly was set to true it will return NULL.

Definition at line 384 of file WModuleContainer.cpp.

References WModuleFactory::getModuleFactory().

boost::shared_ptr< WModule > WModuleContainer::applyModule ( boost::shared_ptr< WModule applyOn,
boost::shared_ptr< WModule prototype 
)
virtual

Function combines two modules.

This runs synchronously. It might take some time to finish since combination of modules is allowed only with modules marked as "ready" which might take some time.

Parameters
applyOnthe module which already has to be in the container and to apply the other one on.
prototypethe prototype of the module to apply on the other one specified.
Returns
the newly created module connected with the one specified in applyOn.

Definition at line 404 of file WModuleContainer.cpp.

References add(), and WModuleFactory::getModuleFactory().

WModule::SPtr WModuleContainer::createAndAdd ( std::string  name)
virtual

Convenience method to create a module instance with a given name and automatically add it to the container.

Parameters
namethe prototype name to create
Returns
the created and added module

Definition at line 184 of file WModuleContainer.cpp.

References add(), and WModuleFactory::getModuleFactory().

boost::shared_ptr< WModule > WModuleContainer::factory ( ) const
virtual

Due to the prototype design pattern used to build modules, this method returns a new instance of this method.

NOTE: it should never be initialized or modified in some other way. A simple new instance is required.

Returns
the prototype used to create every module in OpenWalnut.

Implements WModule.

Definition at line 71 of file WModuleContainer.cpp.

References getDescription(), getName(), and WModuleContainer().

void WModuleContainer::finishedPendingThread ( boost::shared_ptr< WThreadedRunner thread)

The specified thread has finished and does not longer depend upon this container instance.

Parameters
threadthe thread.

Definition at line 469 of file WModuleContainer.cpp.

References m_pendingThreads, and m_pendingThreadsLock.

WModuleContainer::DataModuleListType WModuleContainer::getDataModules ( )

Returns a vector of pointers to the loaded data modules in the container.

Returns
the list of data modules.

Definition at line 246 of file WModuleContainer.cpp.

References WSharedObject< T >::getReadTicket(), and m_modules.

const std::string WModuleContainer::getDescription ( ) const
virtual

Gives back a description of this module.

Returns
description to module.

Implements WPrototyped.

Definition at line 310 of file WModuleContainer.cpp.

References m_description.

Referenced by factory().

WModuleContainer::ModuleSharedContainerType::ReadTicket WModuleContainer::getModules ( ) const

Method returns a read ticket allowing read-access to the list of modules inside the container.

Notes:
If done, ensure the ticket gets destroyed.
Returns
the read ticket.

Definition at line 496 of file WModuleContainer.cpp.

References WSharedObject< T >::getReadTicket(), and m_modules.

Referenced by getModules().

WModuleContainer::ModuleVectorType WModuleContainer::getModules ( std::string  name) const

Queries the container to find all modules with a given name.

This can be useful to check for existence of certain modules inside the container.

Parameters
namename of the modules to find
Returns
the vector of modules. Empty if nothing was found.

Definition at line 501 of file WModuleContainer.cpp.

References getModules().

const std::string WModuleContainer::getName ( ) const
virtual

Gives back the name of this module.

Returns
the module's name.

Implements WPrototyped.

Definition at line 305 of file WModuleContainer.cpp.

References m_name.

Referenced by add(), factory(), remove(), stop(), and WModuleContainer().

WCombinerTypes::WCompatiblesList WModuleContainer::getPossibleConnections ( boost::shared_ptr< WModule module)

This method creates a list of combiner instances, for each possible connection that can be made between the specified module and the module currently inside the container.

It might be possible that a module which is contained in the returned list is not associated anymore if the combiner gets applied.

Parameters
modulethe module to which the possible connections should be returned
Returns
the possible combinations of connectors.

Definition at line 522 of file WModuleContainer.cpp.

References WSharedObject< T >::getReadTicket(), and m_modules.

WBatchLoader::SPtr WModuleContainer::loadDataSets ( std::vector< std::string >  filenames,
bool  suppressColormaps = false 
)

Load specified datasets.

It immediately returns and starts another thread, which actually loads the data.

Parameters
filenameslist of filenames to load. The registered notification handler for the root container will get notified on error and success.
suppressColormapsif true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you combine multiple data loaders into one new data loader or data set
Returns
the loader handling the load operation

Definition at line 439 of file WModuleContainer.cpp.

WBatchLoader::SPtr WModuleContainer::loadDataSetsSynchronously ( std::vector< std::string >  filenames,
bool  suppressColormaps = false 
)

Loads the specified files synchronously.

The returned batchloader can be queried for the list of data modules that have been added.

Parameters
filenameslist of filenames to load. The registered notification handler for the root container will get notified on error and success.
suppressColormapsif true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you combine multiple data loaders into one new data loader or data set
Returns
the loader has handled the load operation

Definition at line 450 of file WModuleContainer.cpp.

void WModuleContainer::moduleError ( boost::shared_ptr< WModule module,
const WException exception 
)
protectedvirtual

This method is called whenever a module inside the container crashes.

By default, this method does nothing but forwarding the using WModule's signals.

Parameters
modulethe module that has crashed.
exceptionthe exception.

Definition at line 476 of file WModuleContainer.cpp.

References WModule::errorLog(), WModule::infoLog(), m_crashIfModuleCrashes, WThreadedRunner::m_isCrashed, WThreadedRunner::requestStop(), and WModule::signal_error.

Referenced by add().

void WModuleContainer::moduleMain ( )
protectedvirtual

Entry point after loading the module.

Runs in separate thread. The module container does not use this method. It simply returns.

Implements WModule.

Definition at line 64 of file WModuleContainer.cpp.

References WModule::ready().

void WModuleContainer::remove ( boost::shared_ptr< WModule module)
virtual

Remove the given module from this container if it is associated with it.

It only provides flat removal. It does not remove depending modules. Please be aware that this method does NOT stop the module. It just removes it from the container. If you release the shared pointer after removing from the container, the instance gets freed although it still might run. To also wait for the module to quit, use module->wait( true ).

Parameters
modulethe module to remove.

Definition at line 197 of file WModuleContainer.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), getName(), WSharedObject< T >::getWriteTicket(), m_modules, m_moduleSubscriptions, WModule::m_progress, m_removedNotifiers, and m_removedNotifiersLock.

void WModuleContainer::setCrashIfModuleCrashes ( bool  crashIfCrashed = true)

Sets a flag denoting whether the container (which also is a module) should be marked as "crashed" if a nested module crashes.

Parameters
crashIfCrashedtrue if it also should crash.

Definition at line 491 of file WModuleContainer.cpp.

References m_crashIfModuleCrashes.

void WModuleContainer::stop ( )
virtual

Stops all modules inside this container.

Note that this function could take some time, since it waits until the last module has quit.

Definition at line 272 of file WModuleContainer.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), getName(), WSharedObject< T >::getReadTicket(), WSharedObject< T >::getWriteTicket(), m_modules, m_pendingThreads, and m_pendingThreadsLock.

Member Data Documentation

std::list< t_ModuleGenericSignalHandlerType > WModuleContainer::m_associatedNotifiers
protected

The notifiers connected to added modules by default and fired whenever the module got associated.

Definition at line 350 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

boost::shared_mutex WModuleContainer::m_associatedNotifiersLock
protected

Lock for associated notifiers set.

Definition at line 345 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

std::list< t_GenericSignalHandlerType > WModuleContainer::m_connectorClosedNotifiers
protected

The notifiers connected to added modules by default and fired whenever the module connectors got disconnected.

Definition at line 375 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

std::list< t_GenericSignalHandlerType > WModuleContainer::m_connectorEstablishedNotifiers
protected

The notifiers connected to added modules by default and fired whenever the module connectors got connected.

Definition at line 370 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

boost::shared_mutex WModuleContainer::m_connectorNotifiersLock
protected

Lock for connector-notifiers set.

Definition at line 365 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

bool WModuleContainer::m_crashIfModuleCrashes
protected

This flag denotes whether the whole container should be marked as crashed if one of the contained modules crashes.

By default, this is true. The root container (the container not nested in any other container) sets this to false explicitly. Modules using the container to encapsulate a whole bunch of modules can decide, but by default they crash too.

Definition at line 401 of file WModuleContainer.h.

Referenced by moduleError(), and setCrashIfModuleCrashes().

std::string WModuleContainer::m_description
protected

Description of the module.

Definition at line 320 of file WModuleContainer.h.

Referenced by getDescription().

std::list< t_ModuleErrorSignalHandlerType > WModuleContainer::m_errorNotifiers
protected

The error notifiers connected to added modules by default.

Definition at line 330 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

boost::shared_mutex WModuleContainer::m_errorNotifiersLock
protected

Lock for error notifiers set.

Definition at line 325 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

ModuleSharedContainerType WModuleContainer::m_modules
protected

The modules associated with this container.

Definition at line 310 of file WModuleContainer.h.

Referenced by add(), getDataModules(), getModules(), getPossibleConnections(), remove(), and stop().

ModuleSubscriptionsSharedType WModuleContainer::m_moduleSubscriptions
private

The module's signal subscriptions.

Definition at line 434 of file WModuleContainer.h.

Referenced by add(), and remove().

std::string WModuleContainer::m_name
protected

Name of the module.

Definition at line 315 of file WModuleContainer.h.

Referenced by getName().

std::set< boost::shared_ptr< WThreadedRunner > > WModuleContainer::m_pendingThreads
protected

Set of all threads that currently depend upon this container.

Definition at line 380 of file WModuleContainer.h.

Referenced by addPendingThread(), finishedPendingThread(), and stop().

boost::shared_mutex WModuleContainer::m_pendingThreadsLock
protected

Lock for m_pendingThreads.

Definition at line 385 of file WModuleContainer.h.

Referenced by addPendingThread(), finishedPendingThread(), and stop().

std::list< t_ModuleGenericSignalHandlerType > WModuleContainer::m_readyNotifiers
protected

The ready notifiers connected to added modules by default.

Definition at line 340 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

boost::shared_mutex WModuleContainer::m_readyNotifiersLock
protected

Lock for ready notifiers set.

Definition at line 335 of file WModuleContainer.h.

Referenced by add(), and addDefaultNotifier().

std::list< t_ModuleGenericSignalHandlerType > WModuleContainer::m_removedNotifiers
protected

The notifiers connected to added modules by default and fired whenever the module got removed again.

Definition at line 360 of file WModuleContainer.h.

Referenced by addDefaultNotifier(), and remove().

boost::shared_mutex WModuleContainer::m_removedNotifiersLock
protected

Lock for remove-notifiers set.

Definition at line 355 of file WModuleContainer.h.

Referenced by addDefaultNotifier(), and remove().


The documentation for this class was generated from the following files: