From 70c4cd2f34abd596e33568ebc5da058c64076253 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Mon, 4 Jan 2016 18:40:29 +0100 Subject: [PATCH] Add `SurfaceFactory` class files --- src/Surfaces/SurfaceFactory.cpp | 26 ++++++++++++++++++++++++++ src/Surfaces/SurfaceFactory.h | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/Surfaces/SurfaceFactory.cpp create mode 100644 src/Surfaces/SurfaceFactory.h diff --git a/src/Surfaces/SurfaceFactory.cpp b/src/Surfaces/SurfaceFactory.cpp new file mode 100644 index 0000000..8d8c598 --- /dev/null +++ b/src/Surfaces/SurfaceFactory.cpp @@ -0,0 +1,26 @@ +#include "SurfaceFactory.h" + +namespace ofx { +namespace piMapper { + +SurfaceFactory * SurfaceFactory::_instance = 0; + +SurfaceFactory * SurfaceFactory::instance(){ + if(_instance == 0){ + _instance = new ofx::piMapper::SurfaceFactory(); + } + return _instance; +} + +BaseSurface * SurfaceFactory::createSurface(int type){ + if(type == SurfaceType::TRIANGLE_SURFACE){ + // TODO: Create triangle surface + }else if(type == SurfaceType::QUAD_SURFACE){ + // TODO: Create quad surface + }else{ + throw runtime_error("Undefined surface type"); + } +} + +} // namespace piMapper +} // namespace ofx diff --git a/src/Surfaces/SurfaceFactory.h b/src/Surfaces/SurfaceFactory.h new file mode 100644 index 0000000..6160396 --- /dev/null +++ b/src/Surfaces/SurfaceFactory.h @@ -0,0 +1,23 @@ +#pragma once + +#include "ofMain.h" +#include "BaseSurface.h" +#include "SurfaceType.h" + +namespace ofx { +namespace piMapper { + +// The surface factory singleton +class SurfaceFactory { + public: + static SurfaceFactory * instance(); + + // Create new surface based on type + BaseSurface * createSurface(int type); + + private: + static SurfaceFactory * _instance; + }; + +} // namespace piMapper +} // namespace ofx \ No newline at end of file