Skip to content
Snippets Groups Projects
Commit d6ebd508 authored by Oliver Bock's avatar Oliver Bock
Browse files

Moved shared memory identifier from initializer to constructor

* Identifier is determined in specialized AbstractGraphicsEngine instances
* Identifier is now passed up the chain during object instantiation
* Fixes formerly hardcoded identifier in Starsphere::initialize()
* Also: removed trailing whitespaces
parent 4ac3da10
Branches
Tags
No related merge requests found
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#include "AbstractGraphicsEngine.h" #include "AbstractGraphicsEngine.h"
AbstractGraphicsEngine::AbstractGraphicsEngine() : m_BoincAdapter() AbstractGraphicsEngine::AbstractGraphicsEngine(string sharedMemoryIdentifier) :
m_BoincAdapter(sharedMemoryIdentifier)
{ {
} }
......
...@@ -21,9 +21,13 @@ ...@@ -21,9 +21,13 @@
#ifndef ABSTRACTGRAPHICSENGINE_H_ #ifndef ABSTRACTGRAPHICSENGINE_H_
#define ABSTRACTGRAPHICSENGINE_H_ #define ABSTRACTGRAPHICSENGINE_H_
#include <string>
#include "BOINCClientAdapter.h" #include "BOINCClientAdapter.h"
#include "Resource.h" #include "Resource.h"
using namespace std;
/** /**
* \addtogroup framework Framework * \addtogroup framework Framework
* @{ * @{
...@@ -169,11 +173,17 @@ public: ...@@ -169,11 +173,17 @@ public:
protected: protected:
/** /**
* \brief Default constructor * \brief Constructor
*
* The constructor is protected since this is an abstract class. It takes
* as an argument the name of the shared memory area which is propagated
* to the BOINC client adapter instance (during construction).
*
* \param sharedMemoryIdentifier The identifier of the shared memory area
* *
* The constructor is protected since this is an abstract class. * \see BOINCClientAdapter::BOINCClientAdapter()
*/ */
AbstractGraphicsEngine(); AbstractGraphicsEngine(string sharedMemoryIdentifier);
/** /**
* \brief This method has to be called in order to update the BOINC client information * \brief This method has to be called in order to update the BOINC client information
......
...@@ -20,9 +20,10 @@ ...@@ -20,9 +20,10 @@
#include "BOINCClientAdapter.h" #include "BOINCClientAdapter.h"
BOINCClientAdapter::BOINCClientAdapter() BOINCClientAdapter::BOINCClientAdapter(string sharedMemoryIdentifier)
{ {
m_Initialized = false; m_Initialized = false;
m_SharedMemoryAreaIdentifier = sharedMemoryIdentifier;
m_SharedMemoryAreaAvailable = false; m_SharedMemoryAreaAvailable = false;
} }
...@@ -30,10 +31,8 @@ BOINCClientAdapter::~BOINCClientAdapter() ...@@ -30,10 +31,8 @@ BOINCClientAdapter::~BOINCClientAdapter()
{ {
} }
void BOINCClientAdapter::initialize(string sharedMemoryIdentifier) void BOINCClientAdapter::initialize()
{ {
m_SharedMemoryAreaIdentifier = sharedMemoryIdentifier;
readUserInfo(); readUserInfo();
readSharedMemoryArea(); readSharedMemoryArea();
......
...@@ -48,8 +48,15 @@ using namespace std; ...@@ -48,8 +48,15 @@ using namespace std;
class BOINCClientAdapter class BOINCClientAdapter
{ {
public: public:
/// Default constructor /**
BOINCClientAdapter(); * \brief Constructor
*
* It takes as an argument the name of the shared memory area to be used
* for inter-process communication.
*
* \param sharedMemoryIdentifier The identifier of the shared memory area
*/
BOINCClientAdapter(string sharedMemoryAreaIdentifier);
/// Destructor /// Destructor
virtual ~BOINCClientAdapter(); virtual ~BOINCClientAdapter();
...@@ -71,7 +78,7 @@ public: ...@@ -71,7 +78,7 @@ public:
* *
* This method has to be called first, otherwise no data will be returned when requested! * This method has to be called first, otherwise no data will be returned when requested!
*/ */
void initialize(string sharedMemoryIdentifier); void initialize();
/** /**
* \brief Refreshes dynamic data (e.g. search information) * \brief Refreshes dynamic data (e.g. search information)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
WindowManager::WindowManager() WindowManager::WindowManager()
{ {
m_ScreensaverMode = false; m_ScreensaverMode = false;
m_BoincAdapter = new BOINCClientAdapter(); m_BoincAdapter = new BOINCClientAdapter("");
} }
WindowManager::~WindowManager() WindowManager::~WindowManager()
...@@ -56,7 +56,7 @@ bool WindowManager::initialize(const int width, const int height, const int fram ...@@ -56,7 +56,7 @@ bool WindowManager::initialize(const int width, const int height, const int fram
} }
// get initial non-fullscreen resolution and frame rate from project preferences // get initial non-fullscreen resolution and frame rate from project preferences
m_BoincAdapter->initialize(""); m_BoincAdapter->initialize();
int preferredWidth = m_BoincAdapter->graphicsWindowWidth(); int preferredWidth = m_BoincAdapter->graphicsWindowWidth();
int preferredHeight = m_BoincAdapter->graphicsWindowHeight(); int preferredHeight = m_BoincAdapter->graphicsWindowHeight();
int preferredFrameRate = m_BoincAdapter->graphicsFrameRate(); int preferredFrameRate = m_BoincAdapter->graphicsFrameRate();
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "Starsphere.h" #include "Starsphere.h"
Starsphere::Starsphere() : AbstractGraphicsEngine() Starsphere::Starsphere(string sharedMemoryAreaIdentifier) :
AbstractGraphicsEngine(sharedMemoryAreaIdentifier)
{ {
m_FontResource = 0; m_FontResource = 0;
m_FontLogo1 = 0; m_FontLogo1 = 0;
...@@ -621,7 +622,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f ...@@ -621,7 +622,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
if(font) m_FontResource = font; if(font) m_FontResource = font;
// initialize the BOINC client adapter // initialize the BOINC client adapter
m_BoincAdapter.initialize(EinsteinS5R3Adapter::SharedMemoryIdentifier); m_BoincAdapter.initialize();
// inital HUD offset setup // inital HUD offset setup
m_XStartPosLeft = 5; m_XStartPosLeft = 5;
......
...@@ -119,11 +119,18 @@ public: ...@@ -119,11 +119,18 @@ public:
protected: protected:
/** /**
* \brief Default contructor * \brief Constructor
* *
* The constructor is protected since this an abstract class. * The constructor is protected since this is an abstract class. It takes
* as an argument the name of the shared memory area which is propagated
* to the BOINC client adapter instance (during construction).
*
* \param sharedMemoryIdentifier The identifier of the shared memory area
*
* \see AbstractGraphicsEngine::AbstractGraphicsEngine()
* \see BOINCClientAdapter::BOINCClientAdapter()
*/ */
Starsphere(); Starsphere(string sharedMemoryIdentifier);
/** /**
* \brief Render science run specific search information * \brief Render science run specific search information
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "StarsphereS5R3.h" #include "StarsphereS5R3.h"
StarsphereS5R3::StarsphereS5R3() : Starsphere(), m_EinsteinAdapter(&m_BoincAdapter) StarsphereS5R3::StarsphereS5R3() :
Starsphere(EinsteinS5R3Adapter::SharedMemoryIdentifier),
m_EinsteinAdapter(&m_BoincAdapter)
{ {
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment