diff --git a/src/Commands/Command.h b/src/Commands/Command.h new file mode 100644 index 0000000..fc5510f --- /dev/null +++ b/src/Commands/Command.h @@ -0,0 +1,9 @@ +// Command base class for separating ofxPiMapper available commands from the core. +// Created by Krisjanis Rijnieks 2015-03-23 + +#pragma once + +class Command{ + public: + virtual void execute() = 0; +}; \ No newline at end of file diff --git a/src/Commands/TestCommand.cpp b/src/Commands/TestCommand.cpp new file mode 100644 index 0000000..5f6933c --- /dev/null +++ b/src/Commands/TestCommand.cpp @@ -0,0 +1,10 @@ +# include "TestCommand.h" + +TestCommand::TestCommand(ofxPiMapper * a){ + _application = a; +} + +void TestCommand::execute(){ + string name = "Hugo"; + _application->testCommand(name); +} \ No newline at end of file diff --git a/src/Commands/TestCommand.h b/src/Commands/TestCommand.h new file mode 100644 index 0000000..4797221 --- /dev/null +++ b/src/Commands/TestCommand.h @@ -0,0 +1,21 @@ +// TestCommand class, extends Command base class. Used for Command design pattern implementation +// pre-tests. Will be removed as soon as possible. +// Created by Krisjanis Rijnieks 2015-03-23 + +#pragma once + +#include "ofxPiMapper.h" +#include "Command.h" + +class ofxPiMapper; + +class TestCommand : public Command{ + public: + TestCommand(ofxPiMapper * a); + ~TestCommand(); + virtual void execute(); + + private: + ofxPiMapper * _application; + +}; \ No newline at end of file diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 546002d..26ef405 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -32,6 +32,10 @@ void ofxPiMapper::setup() { isSetUp = true; ofLogNotice("ofxPiMapper") << "Done setting up"; + + // Initialize TestCommand + ofxPiMapper * app = this; + aTestCommand = new TestCommand(app); } void ofxPiMapper::draw() { @@ -98,6 +102,10 @@ void ofxPiMapper::keyPressed(ofKeyEventArgs &args) { case OF_KEY_BACKSPACE: surfaceManager.removeSelectedSurface(); break; + // TODO: Remove the following case when Command test done. + case '0': + aTestCommand->execute(); + break; default: break; } @@ -157,4 +165,9 @@ ofx::piMapper::MediaServer& ofxPiMapper::getMediaServer() { ofx::piMapper::SurfaceManager& ofxPiMapper::getSurfaceManager() { return surfaceManager; +} + +// TODO: remove this when done testing and everything works +void ofxPiMapper::testCommand(string name){ + ofLogNotice("ofxPiMapper", name); } \ No newline at end of file diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 0a7db3d..2dbb215 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -1,3 +1,13 @@ +/* ofxPiMapper + * + * Description: + * Main ofxPiMapper class. Holds instances of all necessary parts of the tool: + * - MediaServer + * - SurfaceManager + * - SurfaceManagerGui (this asks for a different architecture) + * + * Author: Krisjanis Rijnieks */ + #pragma once #include "ofMain.h" @@ -6,22 +16,32 @@ #include "MediaServer.h" #include "FboSource.h" +#include "Command.h" +#include "TestCommand.h" // TODO: Remove this line when done testing + #define PIMAPPER_DEF_SURFACES_XML_FILE "defaultSurfaces.xml" #define PIMAPPER_USER_SURFACES_XML_FILE "surfaces.xml" class ofxPiMapper { public: + + // These are here for adding and removing listeners on + // contruction and deconstruction ofxPiMapper(); ~ofxPiMapper(); + // These are here to adapt to the openFrameworks ways void setup(); void draw(); // Called manually to make custom layering possible void keyPressed(ofKeyEventArgs& args); - + // Use this to add custom FBO source void addFboSource(ofx::piMapper::FboSource& fboSource); - // TODO: Copy/move these methods to SurfaceManager + /* Discussion: + * Maybe it makes more sense to use create prefix instead of add + * in addTriangleSurface and so on, so we get createTriangleSurface. + * TODO: Copy/move these methods to SurfaceManager (not sure) */ void addTriangleSurface(); void addQuadSurface(); @@ -29,14 +49,23 @@ public: void showInfo() { bShowInfo = true; }; void hideInfo() { bShowInfo = false; }; - // Getters + /* Discussion: + * Maybe these should be static as this would allow to access them + * from anywhere within ofxPiMapper. */ ofx::piMapper::MediaServer& getMediaServer(); ofx::piMapper::SurfaceManager& getSurfaceManager(); - + + // Test first steps of the Command design pattern implementation. + void testCommand(string name); + Command * aTestCommand; + private: bool isSetUp; bool bShowInfo; ofx::piMapper::MediaServer mediaServer; ofx::piMapper::SurfaceManager surfaceManager; + + /* Discussion: Here now the GUI points only to surface manager, + * maybe it should be as a separate layer? */ ofx::piMapper::SurfaceManagerGui gui; }; \ No newline at end of file