Browse Source

Add `SurfaceFactory` class files

master
Krisjanis Rijnieks 10 years ago
parent
commit
70c4cd2f34
  1. 26
      src/Surfaces/SurfaceFactory.cpp
  2. 23
      src/Surfaces/SurfaceFactory.h

26
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

23
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
Loading…
Cancel
Save