Commit c9181c42 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - changed some flags to use WFlag

parent 57b6672b
......@@ -29,18 +29,20 @@
#include "WQtGLWidget.h"
#include "../../graphicsEngine/WGEViewer.h"
#include "../../common/WFlag.hpp"
#include "../../common/WConditionOneShot.h"
#include "../../kernel/WKernel.h"
WQtGLWidget::WQtGLWidget( QWidget* parent, WGECamera::ProjectionMode projectionMode )
: QGLWidget( parent ),
m_recommendedSize()
m_recommendedSize(),
m_isInitialized( new WConditionOneShot(), false )
{
m_recommendedSize.setWidth( 200 );
m_recommendedSize.setHeight( 200 );
m_initialProjectionMode = projectionMode;
m_isInitialized = false;
// required
setAttribute( Qt::WA_PaintOnScreen );
......@@ -51,7 +53,7 @@ WQtGLWidget::WQtGLWidget( QWidget* parent, WGECamera::ProjectionMode projectionM
WQtGLWidget::~WQtGLWidget()
{
// cleanup
if ( isInitialized() )
if ( m_isInitialized() )
{
m_Viewer.reset();
}
......@@ -59,7 +61,7 @@ WQtGLWidget::~WQtGLWidget()
void WQtGLWidget::initialize()
{
if ( m_isInitialized )
if ( m_isInitialized() )
return;
// initialize OpenGL context and OpenSceneGraph
......@@ -80,10 +82,10 @@ void WQtGLWidget::initialize()
// create viewer
m_Viewer = WKernel::getRunningKernel()->getGraphicsEngine()->createViewer( wdata, x(), y(), width(), height(), m_initialProjectionMode );
m_isInitialized = true;
m_isInitialized( true );
}
bool WQtGLWidget::isInitialized() const
const WBoolFlag& WQtGLWidget::isInitialized() const
{
return m_isInitialized;
}
......
......@@ -32,6 +32,7 @@
#include <boost/shared_ptr.hpp>
#include "../../graphicsEngine/WGECamera.h"
#include "../../common/WFlag.hpp"
class WGEViewer;
......@@ -94,9 +95,9 @@ public:
/**
* Determines whether the widget is properly initialized.
*
* \return true when initialized.
* \return flag - initialized.
*/
bool isInitialized() const;
const WBoolFlag& isInitialized() const;
protected:
/**
......@@ -212,7 +213,7 @@ private:
/**
* True when initialized.
*/
bool m_isInitialized;
WBoolFlag m_isInitialized;
};
#endif // WQTGLWIDGET_H
......@@ -37,6 +37,8 @@
#include "WModuleFactory.h"
#include "../common/WException.h"
#include "../common/WCondition.h"
#include "../common/WConditionOneShot.h"
#include "../common/WFlag.hpp"
#include "../graphicsEngine/WGraphicsEngine.h"
......@@ -47,8 +49,9 @@
*/
WKernel* kernel = NULL;
WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui )
:WThreadedRunner()
WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui ):
WThreadedRunner(),
m_FinishRequested( new WConditionOneShot, false )
{
WLogger::getLogger()->addLogMessage( "Initializing Kernel", "Kernel", LL_DEBUG );
......@@ -56,8 +59,6 @@ WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WG
kernel = this;
// initialize members
m_FinishRequested = false;
m_gui = gui;
m_graphicsEngine = ge;
......@@ -118,6 +119,8 @@ void WKernel::stop()
WLogger::getLogger()->addLogMessage( "Stopping Kernel", "Kernel", LL_DEBUG );
// stop everybody
m_FinishRequested( true );
// NOTE: stopping a container erases all modules inside.
getRootContainer()->stop();
}
......@@ -212,7 +215,7 @@ bool WKernel::findAppPath()
return false;
}
bool WKernel::isFinishRequested() const
const WBoolFlag& WKernel::isFinishRequested() const
{
return m_FinishRequested;
}
......
......@@ -36,6 +36,7 @@
#include "WModuleContainer.h"
#include "../common/WLogger.h"
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.hpp"
#include "../graphicsEngine/WGraphicsEngine.h"
#include "../dataHandler/WDataHandler.h"
#include "../gui/WGUI.h"
......@@ -102,7 +103,7 @@ public:
*
* \return true if so.
*/
bool isFinishRequested() const;
const WBoolFlag& isFinishRequested() const;
/**
* function to call the datahandler load method
......@@ -184,7 +185,7 @@ private:
/**
* true if threads should finish.
*/
bool m_FinishRequested;
WBoolFlag m_FinishRequested;
/**
* the location of the openwalnut executable
......
......@@ -44,7 +44,9 @@
WModule::WModule():
WThreadedRunner(),
m_initialized( false )
m_initialized( new WCondition(), false ),
m_isAssociated( new WCondition(), false ),
m_isUsable( new WCondition(), false )
{
// initialize members
m_properties = boost::shared_ptr< WProperties >( new WProperties() );
......@@ -86,7 +88,8 @@ void WModule::disconnectAll()
void WModule::removeConnectors()
{
m_initialized = false;
m_initialized( false );
m_isUsable( m_initialized() && m_isAssociated() );
// remove connections and their signals
disconnectAll();
......@@ -108,7 +111,7 @@ void WModule::properties()
void WModule::initialize()
{
// doing it twice is not allowed
if ( isInitialized() )
if ( isInitialized()() )
{
throw WModuleConnectorInitFailed( "Could not initialize connectors for Module " + getName() + ". Reason: already initialized." );
}
......@@ -116,7 +119,8 @@ void WModule::initialize()
connectors();
properties();
m_initialized = true;
m_initialized( true );
m_isUsable( m_initialized() && m_isAssociated() );
}
void WModule::cleanup()
......@@ -133,6 +137,10 @@ boost::shared_ptr< WModuleContainer > WModule::getAssociatedContainer() const
void WModule::setAssociatedContainer( boost::shared_ptr< WModuleContainer > container )
{
m_container = container;
// true if the pointer is set
m_isAssociated( m_container != boost::shared_ptr< WModuleContainer >() );
m_isUsable( m_initialized() && m_isAssociated() );
}
const std::set<boost::shared_ptr< WModuleInputConnector > >& WModule::getInputConnectors() const
......@@ -196,20 +204,20 @@ std::set< boost::shared_ptr< WModule > > WModule::getCompatibles()
return WModuleFactory::getModuleFactory()->getCompatiblePrototypes( shared_from_this() );
}
bool WModule::isInitialized() const
const WBoolFlag& WModule::isInitialized() const
{
return m_initialized;
}
bool WModule::isAssociated() const
const WBoolFlag& WModule::isAssociated() const
{
// true if the pointer is set
return ( m_container != boost::shared_ptr< WModuleContainer >() );
return m_isAssociated;
}
bool WModule::isUseable() const
const WBoolFlag& WModule::isUseable() const
{
return isInitialized() && isAssociated();
return m_isUsable;
//return isInitialized() && isAssociated();
}
void WModule::notifyConnectionEstablished( boost::shared_ptr< WModuleConnector > /*here*/,
......
......@@ -35,6 +35,7 @@
#include <boost/function.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.hpp"
#include "WModuleConnectorSignals.h"
#include "WModuleSignals.h"
......@@ -110,21 +111,21 @@ public:
*
* \return true if properly initialized.
*/
bool isInitialized() const;
const WBoolFlag& isInitialized() const;
/**
* Checks whether the module instance is ready to be used. This is the case if isInitialized && isAssociated.
*
* \return isInitialized && isAssociated
*/
bool isUseable() const;
const WBoolFlag& isUseable() const;
/**
* Checks whether this module is associated with an container.
*
* \return true if associated.
*/
bool isAssociated() const;
const WBoolFlag& isAssociated() const;
/**
* The container this module is associated with.
......@@ -303,7 +304,17 @@ protected:
/**
* True if everything is initialized and ready to be used.
*/
bool m_initialized;
WBoolFlag m_initialized;
/**
* True if container got associated with this flag.
*/
WBoolFlag m_isAssociated;
/**
* True if associated && initialized.
*/
WBoolFlag m_isUsable;
/**
* The container this module belongs to.
......
......@@ -53,7 +53,7 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
{
WLogger::getLogger()->addLogMessage( "Adding module \"" + module->getName() + "\" to container." , "ModuleContainer (" + m_name + ")", LL_DEBUG );
if ( !module->isInitialized() )
if ( !module->isInitialized()() )
{
std::ostringstream s;
s << "Could not add module \"" << module->getName() << "\" to container \"" + m_name + "\". Reason: module not initialized.";
......@@ -68,7 +68,7 @@ void WModuleContainer::add( boost::shared_ptr< WModule > module, bool run )
}
// is this module already associated?
if ( module->isAssociated() )
if ( module->isAssociated()() )
{
module->getAssociatedContainer()->remove( module );
}
......
......@@ -245,9 +245,9 @@ public:
TS_ASSERT( m3->m_outputConnectors.size() == 1 );
// now we have 3 properly initialized modules?
TS_ASSERT( m1->isInitialized() );
TS_ASSERT( m2->isInitialized() );
TS_ASSERT( m3->isInitialized() );
TS_ASSERT( m1->isInitialized()() );
TS_ASSERT( m2->isInitialized()() );
TS_ASSERT( m3->isInitialized()() );
}
/**
......@@ -262,7 +262,7 @@ public:
// try initializing twice
TS_ASSERT_THROWS( m1->initialize(), WModuleConnectorInitFailed );
TS_ASSERT( m1->isInitialized() );
TS_ASSERT( m1->isInitialized()() );
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment