OpenWalnut
1.3.1
|
OpenWalnut kernel, managing modules and interaction between GUI, GE and DataHandler. More...
#include <WKernel.h>
Public Member Functions | |
virtual | ~WKernel () |
Destructor. More... | |
void | finalize () |
Stops execution of the modules in the root container. More... | |
boost::shared_ptr < WGraphicsEngine > | getGraphicsEngine () const |
Returns pointer to currently running instance of graphics engine. More... | |
const WBoolFlag & | isFinishRequested () const |
Determines whether all threads should finish. 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... | |
boost::shared_ptr< WModule > | applyModule (boost::shared_ptr< WModule > applyOn, boost::shared_ptr< WModule > prototype) |
Function combines to modules. More... | |
boost::shared_ptr < WModuleContainer > | getRootContainer () const |
Returns the root module container. More... | |
boost::shared_ptr< WGUI > | getGui () const |
Getter for the associated GUI. More... | |
boost::shared_ptr< WROIManager > | getRoiManager () |
get for roi manager More... | |
boost::shared_ptr < WSelectionManager > | getSelectionManager () |
get for selection manager More... | |
WTimer::ConstSPtr | getTimer () const |
Returns the system timer. More... | |
![]() | |
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 WBoolFlag & | isCrashed () 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... | |
Static Public Member Functions | |
static WKernel * | instance (boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui) |
Returns pointer to the running kernel or a new if no kernel was there. More... | |
static WKernel * | getRunningKernel () |
Returns pointer to the currently running kernel. More... | |
![]() | |
static void | setThisThreadName (std::string name) |
Static function to set the name of the calling thread. More... | |
Protected Member Functions | |
WKernel (boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui) | |
Constructor is protected because this class is a singleton. More... | |
virtual void | threadMain () |
Function that has to be overwritten for execution. More... | |
![]() | |
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... | |
virtual void | onThreadException (const WException &e) |
This method is called if an exception was caught, which came from the custom thread code. 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 | |
boost::shared_ptr< WGUI > | m_gui |
The Gui. More... | |
boost::shared_ptr < WGraphicsEngine > | m_graphicsEngine |
Pointer to an initialized graphics engine. More... | |
boost::shared_ptr< WROIManager > | m_roiManager |
Pointer to a roi manager. More... | |
boost::shared_ptr < WSelectionManager > | m_selectionManager |
pointer to a selection manager More... | |
boost::shared_ptr< WModuleFactory > | m_moduleFactory |
The module factory to use. More... | |
boost::shared_ptr < WModuleContainer > | m_moduleContainer |
The container containing the modules. More... | |
![]() | |
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 Member Functions | |
void | loadModules () |
Loads all the modules it can find. More... | |
void | init () |
Initializes the graphics engine, data handler and so on. More... | |
Private Attributes | |
WTimer::SPtr | m_timer |
The ow system timer. More... | |
Static Private Attributes | |
static WKernel * | m_kernel = NULL |
Pointer to the unique instance of this singleton class. More... | |
Additional Inherited Members | |
![]() | |
typedef boost::function< void(void) > | THREADFUNCTION |
Type used for simple thread functions. More... | |
OpenWalnut kernel, managing modules and interaction between GUI, GE and DataHandler.
|
virtual |
Destructor.
Definition at line 74 of file WKernel.cpp.
References WLogger::addLogMessage(), and WLogger::getLogger().
|
protected |
Constructor is protected because this class is a singleton.
Awaits an INITIALIZED graphics engine an gui.
ge | initialized graphics engine. |
gui | initialized gui. |
Definition at line 54 of file WKernel.cpp.
References WLogger::addLogMessage(), wlog::debug(), WLogger::getLogger(), init(), m_graphicsEngine, m_gui, m_kernel, and WThreadedRunner::setThreadName().
Referenced by instance().
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.
applyOn | the module which already has to be in the container and to apply the other one on. |
prototype | the prototype of the module to apply on the other one specified. |
Definition at line 175 of file WKernel.cpp.
References getRootContainer().
void WKernel::finalize | ( | ) |
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 133 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.
Definition at line 118 of file WKernel.cpp.
References m_graphicsEngine.
Referenced by WSelectionManager::getFrontSector(), and WSelectionManager::setPaintMode().
boost::shared_ptr< WGUI > WKernel::getGui | ( | ) | const |
Getter for the associated GUI.
Definition at line 128 of file WKernel.cpp.
References m_gui.
boost::shared_ptr< WROIManager > WKernel::getRoiManager | ( | ) |
get for roi manager
Definition at line 180 of file WKernel.cpp.
References m_roiManager.
Referenced by 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.
Definition at line 123 of file WKernel.cpp.
References m_moduleContainer.
Referenced by applyModule(), finalize(), WProjectFile::load(), loadDataSets(), loadDataSetsSynchronously(), WProjectFile::onThreadException(), WModuleProjectFileCombiner::save(), and WProjectFile::threadMain().
|
static |
Returns pointer to the currently running kernel.
Definition at line 113 of file WKernel.cpp.
References m_kernel.
Referenced by WSelectionManager::getFrontSector(), WProjectFile::load(), WProjectFile::onThreadException(), WModuleProjectFileCombiner::save(), WSelectionManager::setPaintMode(), WFiberSelector::slotAddRoi(), WProjectFile::threadMain(), WFiberSelector::WFiberSelector(), and WFiberSelector::~WFiberSelector().
boost::shared_ptr< WSelectionManager > WKernel::getSelectionManager | ( | ) |
get for selection manager
Definition at line 185 of file WKernel.cpp.
References m_selectionManager.
WTimer::ConstSPtr WKernel::getTimer | ( | ) | const |
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.
Definition at line 190 of file WKernel.cpp.
References m_timer.
|
private |
Initializes the graphics engine, data handler and so on.
Definition at line 90 of file WKernel.cpp.
References WDataHandler::getDataHandler(), WModuleFactory::getModuleFactory(), m_moduleContainer, m_moduleFactory, m_roiManager, and m_selectionManager.
Referenced by WKernel().
|
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 gui of the running kernel are equivalent to the ones given as parameters.
ge | initialized graphics engine. |
gui | initialized gui. |
Definition at line 80 of file WKernel.cpp.
const WBoolFlag & WKernel::isFinishRequested | ( | ) | const |
Determines whether all threads should finish.
Definition at line 160 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.
filenames | list of filenames to load. The registered notification handler for the root container will get notified on error and success. |
suppressColormaps | if 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 |
Definition at line 165 of file WKernel.cpp.
References getRootContainer().
WBatchLoader::SPtr WKernel::loadDataSetsSynchronously | ( | std::vector< std::string > | filenames, |
bool | suppressColormaps = false |
||
) |
Loads the specified files synchronously.
filenames | list of filenames to load. The registered notification handler for the root container will get notified on error and success. |
suppressColormaps | if 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 |
Definition at line 170 of file WKernel.cpp.
References getRootContainer().
|
private |
Loads all the modules it can find.
|
protectedvirtual |
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 144 of file WKernel.cpp.
References WLogger::addLogMessage(), WLogger::getLogger(), m_graphicsEngine, m_gui, and WThreadedRunner::waitForStop().
|
protected |
Pointer to an initialized graphics engine.
Definition at line 204 of file WKernel.h.
Referenced by getGraphicsEngine(), threadMain(), and WKernel().
|
protected |
The Gui.
Definition at line 199 of file WKernel.h.
Referenced by getGui(), threadMain(), and WKernel().
|
staticprivate |
Pointer to the unique instance of this singleton class.
Used for program wide access to the kernel.
Definition at line 240 of file WKernel.h.
Referenced by getRunningKernel(), instance(), and WKernel().
|
protected |
The container containing the modules.
Definition at line 224 of file WKernel.h.
Referenced by getRootContainer(), and init().
|
protected |
|
protected |
Pointer to a roi manager.
Definition at line 209 of file WKernel.h.
Referenced by getRoiManager(), and init().
|
protected |
pointer to a selection manager
Definition at line 214 of file WKernel.h.
Referenced by getSelectionManager(), and init().
|
private |