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