Browse Source

Add MediaServer initialization

master
Krisjanis Rijnieks 11 years ago
parent
commit
4d484bfb3d
  1. 33
      src/SourcesEditor.cpp
  2. 10
      src/SourcesEditor.h

33
src/SourcesEditor.cpp

@ -3,8 +3,20 @@
namespace ofx {
namespace piMapper {
SourcesEditor::SourcesEditor() {
defImgDir = DEFAULT_IMAGES_DIR;
registerAppEvents();
init();
// Create new MediaServer instance,
// we will need to clear this in the deconstr
mediaServer = new MediaServer();
isMediaServerExternal = false;
}
SourcesEditor::SourcesEditor(MediaServer* externalMediaServer) {
init();
// Assign external MediaServer instance pointer
mediaServer = externalMediaServer;
isMediaServerExternal = true;
}
SourcesEditor::~SourcesEditor() {
@ -14,6 +26,23 @@ SourcesEditor::~SourcesEditor() {
delete images.back();
images.pop_back();
}
// If mediaServer is local, clear it
if (isMediaServerExternal) {
// Clear all loaded sources
//mediaServer->clear()
// Destroy the pointer and set it to NULL pointer
delete mediaServer;
mediaServer = NULL;
}
}
// Initialize instance variables
void SourcesEditor::init() {
mediaServer = NULL;
isMediaServerExternal = false;
defImgDir = DEFAULT_IMAGES_DIR;
registerAppEvents();
}
void SourcesEditor::registerAppEvents() {

10
src/SourcesEditor.h

@ -4,6 +4,7 @@
#include "ofEvents.h"
#include "SurfaceManager.h"
#include "RadioList.h"
#include "MediaServer.h"
#define DEFAULT_IMAGES_DIR "sources/images/";
@ -11,9 +12,16 @@ namespace ofx {
namespace piMapper {
class SourcesEditor {
public:
// Default contructor that initializes media server locally,
// thus requiring to delete the media server from memory on deconstr
SourcesEditor();
// Alternative constructor that allows to assign external media server
SourcesEditor(MediaServer* externalMediaServer);
~SourcesEditor();
// Init handles variable initialization in all constructors
void init();
void registerAppEvents();
void unregisterAppEvents();
@ -29,6 +37,8 @@ class SourcesEditor {
ofTexture* getTexture(int index);
private:
MediaServer* mediaServer;
bool isMediaServerExternal;
SurfaceManager* surfaceManager;
RadioList* gui;
string defImgDir;

Loading…
Cancel
Save