OpenWalnut  1.4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
WKernel Class Reference

OpenWalnut kernel, managing modules and interaction between UI, GE and DataHandler. More...

#include <WKernel.h>

+ Inheritance diagram for WKernel:

List of all members.

Public Types

enum  KERNEL_SIGNAL { KERNEL_STARTUPCOMPLETE }
 Enum of all possible signals WKernel instances can emit. More...
typedef boost::function< void(void) > t_KernelGenericSignalHandlerType
 Signal for generic events.
typedef
boost::signals2::signal< void(void) > 
t_KernelGenericSignalType
 Generic signal type used in the most signals.

Public Member Functions

virtual ~WKernel ()
 Destructor.
boost::signals2::connection subscribeSignal (KERNEL_SIGNAL signal, t_KernelGenericSignalHandlerType notifier)
 Subscribe to several signals.
void finalize ()
 Stops execution of the modules in the root container.
boost::shared_ptr
< WGraphicsEngine
getGraphicsEngine () const
 Returns pointer to currently running instance of graphics engine.
const WBoolFlagisFinishRequested () const
 Determines whether all threads should finish.
WBatchLoader::SPtr loadDataSets (std::vector< std::string > filenames, bool suppressColormaps=false)
 Load specified datasets.
WBatchLoader::SPtr loadDataSetsSynchronously (std::vector< std::string > filenames, bool suppressColormaps=false)
 Loads the specified files synchronously.
boost::shared_ptr< WModuleapplyModule (boost::shared_ptr< WModule > applyOn, boost::shared_ptr< WModule > prototype)
 Function combines to modules.
boost::shared_ptr
< WModuleContainer
getRootContainer () const
 Returns the root module container.
boost::shared_ptr< WUIgetUI () const
 Getter for the associated UI.
boost::shared_ptr< WROIManagergetRoiManager ()
 get for roi manager
boost::shared_ptr
< WSelectionManager
getSelectionManager ()
 get for selection manager
boost::shared_ptr< WScriptEnginegetScriptEngine ()
 Get the script engine of this kernel.
WTimer::ConstSPtr getTimer () const
 Returns the system timer.

Static Public Member Functions

static WKernelinstance (boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WUI > ui)
 Returns pointer to the running kernel or a new if no kernel was there.
static WKernelgetRunningKernel ()
 Returns pointer to the currently running kernel.

Protected Member Functions

 WKernel (boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WUI > ui)
 Constructor is protected because this class is a singleton.
virtual void threadMain ()
 Function that has to be overwritten for execution.

Protected Attributes

boost::shared_ptr< WUIm_ui
 The UI.
boost::shared_ptr
< WGraphicsEngine
m_graphicsEngine
 Pointer to an initialized graphics engine.
boost::shared_ptr< WROIManagerm_roiManager
 Pointer to a roi manager.
boost::shared_ptr
< WSelectionManager
m_selectionManager
 pointer to a selection manager
boost::shared_ptr< WModuleFactorym_moduleFactory
 The module factory to use.
boost::shared_ptr
< WModuleContainer
m_moduleContainer
 The container containing the modules.
boost::shared_ptr< WScriptEnginem_scriptEngine
 The script engine to use.

Private Member Functions

void loadModules ()
 Loads all the modules it can find.
void init ()
 Initializes the graphics engine, data handler and so on.

Private Attributes

WTimer::SPtr m_timer
 The ow system timer.
WConditionOneShot m_startupCompleted
 Notified when the startup, including GE and UI has been completed.

Static Private Attributes

static WKernelm_kernel = NULL
 Pointer to the unique instance of this singleton class.

Detailed Description

OpenWalnut kernel, managing modules and interaction between UI, GE and DataHandler.

Definition at line 61 of file WKernel.h.


Member Typedef Documentation

typedef boost::function< void ( void ) > WKernel::t_KernelGenericSignalHandlerType

Signal for generic events.

Definition at line 68 of file WKernel.h.

typedef boost::signals2::signal< void ( void ) > WKernel::t_KernelGenericSignalType

Generic signal type used in the most signals.

Definition at line 73 of file WKernel.h.


Member Enumeration Documentation

Enum of all possible signals WKernel instances can emit.

Definition at line 78 of file WKernel.h.


Constructor & Destructor Documentation

WKernel::~WKernel ( ) [virtual]

Destructor.

Definition at line 76 of file WKernel.cpp.

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

WKernel::WKernel ( boost::shared_ptr< WGraphicsEngine ge,
boost::shared_ptr< WUI ui 
) [protected]

Constructor is protected because this class is a singleton.

Awaits an INITIALIZED graphics engine an UI.

Parameters:
geinitialized graphics engine.
uiinitialized UI.

Definition at line 56 of file WKernel.cpp.

References WLogger::addLogMessage(), wlog::debug(), WLogger::getLogger(), init(), m_graphicsEngine, m_kernel, m_ui, and WThreadedRunner::setThreadName().

Referenced by instance().


Member Function Documentation

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

Function combines to modules.

This is a simple alias for "getRootContainer()->applyModule". It runs synchronously, which could freeze the calling thread for a couple of 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 204 of file WKernel.cpp.

References getRootContainer().

Stops execution of the modules in the root container.

Note that this does not wait for the kernel thread since this could cause a dead lock. This is actually an alias for getRootContainer()->stop().

Definition at line 137 of file WKernel.cpp.

References WLogger::addLogMessage(), WDataHandler::getDataHandler(), WLogger::getLogger(), and getRootContainer().

boost::shared_ptr< WGraphicsEngine > WKernel::getGraphicsEngine ( ) const

Returns pointer to currently running instance of graphics engine.

Returns:
the graphics engine instance.

Definition at line 122 of file WKernel.cpp.

References m_graphicsEngine.

Referenced by WSelectionManager::getFrontSector(), and WSelectionManager::setPaintMode().

boost::shared_ptr< WROIManager > WKernel::getRoiManager ( )

get for roi manager

Returns:
Pointer to the ROI manager.

Definition at line 209 of file WKernel.cpp.

References m_roiManager.

Referenced by WRoiProjectFileIO::done(), WRoiProjectFileIO::save(), WFiberSelector::slotAddRoi(), WFiberSelector::WFiberSelector(), and WFiberSelector::~WFiberSelector().

boost::shared_ptr< WModuleContainer > WKernel::getRootContainer ( ) const

Returns the root module container.

This is the actual module graph container.

Returns:
the root container.

Definition at line 127 of file WKernel.cpp.

References m_moduleContainer.

Referenced by applyModule(), finalize(), WProjectFile::load(), loadDataSets(), loadDataSetsSynchronously(), WProjectFile::onThreadException(), WModuleProjectFileCombiner::save(), and WProjectFile::threadMain().

boost::shared_ptr< WScriptEngine > WKernel::getScriptEngine ( )

Get the script engine of this kernel.

Returns:
A pointer to the script engine.

Definition at line 219 of file WKernel.cpp.

References m_scriptEngine.

get for selection manager

Returns:
Pointer to the selection manager.

Definition at line 214 of file WKernel.cpp.

References m_selectionManager.

Returns the system timer.

If you need timing for animations and similar, use this one. This timer can change to frame based timing if the user plays back some animation. So, everything which uses this timer can always do accurate per-frame animations even if frame time and real-time differ.

Returns:
the timer

Definition at line 224 of file WKernel.cpp.

References m_timer.

boost::shared_ptr< WUI > WKernel::getUI ( ) const

Getter for the associated UI.

Returns:
the UI.

Definition at line 132 of file WKernel.cpp.

References m_ui.

void WKernel::init ( ) [private]

Initializes the graphics engine, data handler and so on.

Definition at line 92 of file WKernel.cpp.

References WDataHandler::getDataHandler(), WModuleFactory::getModuleFactory(), m_moduleContainer, m_moduleFactory, m_roiManager, m_scriptEngine, and m_selectionManager.

Referenced by WKernel().

WKernel * WKernel::instance ( boost::shared_ptr< WGraphicsEngine ge,
boost::shared_ptr< WUI ui 
) [static]

Returns pointer to the running kernel or a new if no kernel was there.

If a running kernel exists the function return it and does not check if GE and UI of the running kernel are equivalent to the ones given as parameters.

Parameters:
geinitialized graphics engine.
uiinitialized ui.
Returns:
the kernel instance.

Definition at line 82 of file WKernel.cpp.

References m_kernel, and WKernel().

Determines whether all threads should finish.

Returns:
true if so.

Definition at line 189 of file WKernel.cpp.

References WThreadedRunner::m_shutdownFlag.

WBatchLoader::SPtr WKernel::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 batch loader responsible for loading. Can be queried for the list of data modules.

Definition at line 194 of file WKernel.cpp.

References getRootContainer().

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

Loads the specified files synchronously.

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 batch loader responsible for loading. Can be queried for the list of data modules.

Definition at line 199 of file WKernel.cpp.

References getRootContainer().

void WKernel::loadModules ( ) [private]

Loads all the modules it can find.

boost::signals2::connection WKernel::subscribeSignal ( WKernel::KERNEL_SIGNAL  signal,
WKernel::t_KernelGenericSignalHandlerType  notifier 
)

Subscribe to several signals.

Parameters:
signalthe signal to subscribe
notifierthe notifier to call
Returns:
connection variable. Keep this in any case. If not, the connection may be lost.

Definition at line 229 of file WKernel.cpp.

References m_startupCompleted, and WCondition::subscribeSignal().

void WKernel::threadMain ( ) [protected, virtual]

Function that has to be overwritten for execution.

It gets executed in a separate thread after run() has been called.

Reimplemented from WThreadedRunner.

Definition at line 148 of file WKernel.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), WModuleFactory::getModuleLoader(), wlog::info(), m_graphicsEngine, m_startupCompleted, m_ui, WConditionOneShot::notify(), WThreadedRunner::waitForStop(), and wlog::warn().


Member Data Documentation

boost::shared_ptr< WGraphicsEngine > WKernel::m_graphicsEngine [protected]

Pointer to an initialized graphics engine.

Definition at line 239 of file WKernel.h.

Referenced by getGraphicsEngine(), threadMain(), and WKernel().

WKernel * WKernel::m_kernel = NULL [static, private]

Pointer to the unique instance of this singleton class.

Used for program wide access to the kernel.

Definition at line 280 of file WKernel.h.

Referenced by getRunningKernel(), instance(), and WKernel().

boost::shared_ptr< WModuleContainer > WKernel::m_moduleContainer [protected]

The container containing the modules.

Definition at line 259 of file WKernel.h.

Referenced by getRootContainer(), and init().

boost::shared_ptr< WModuleFactory > WKernel::m_moduleFactory [protected]

The module factory to use.

Definition at line 254 of file WKernel.h.

Referenced by init().

boost::shared_ptr< WROIManager > WKernel::m_roiManager [protected]

Pointer to a roi manager.

Definition at line 244 of file WKernel.h.

Referenced by getRoiManager(), and init().

boost::shared_ptr< WScriptEngine > WKernel::m_scriptEngine [protected]

The script engine to use.

Definition at line 264 of file WKernel.h.

Referenced by getScriptEngine(), and init().

boost::shared_ptr< WSelectionManager > WKernel::m_selectionManager [protected]

pointer to a selection manager

Definition at line 249 of file WKernel.h.

Referenced by getSelectionManager(), and init().

Notified when the startup, including GE and UI has been completed.

Definition at line 290 of file WKernel.h.

Referenced by subscribeSignal(), and threadMain().

The ow system timer.

Definition at line 285 of file WKernel.h.

Referenced by getTimer().

boost::shared_ptr< WUI > WKernel::m_ui [protected]

The UI.

Definition at line 234 of file WKernel.h.

Referenced by getUI(), threadMain(), and WKernel().


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