Browse Source

Add `registerFboSource` overload method with pointer

master
Krisjanis Rijnieks 9 years ago
parent
commit
8c723d6746
  1. 4
      src/Application/Application.cpp
  2. 1
      src/Application/Application.h
  3. 17
      src/MediaServer/MediaServer.cpp
  4. 2
      src/MediaServer/MediaServer.h
  5. 4
      src/ofxPiMapper.cpp
  6. 1
      src/ofxPiMapper.h

4
src/Application/Application.cpp

@ -143,6 +143,10 @@ void Application::addFboSource(FboSource & fboSource){
_mediaServer.addFboSource(fboSource);
}
void Application::addFboSource(FboSource * fboSource){
_mediaServer.addFboSource(fboSource);
}
void Application::setState(ApplicationBaseState * st){
_state = st;
}

1
src/Application/Application.h

@ -52,6 +52,7 @@ class Application : public KeyListener {
// Every state should have it's own GUI layer
void addFboSource(FboSource & fboSource);
void addFboSource(FboSource * fboSource);
bool loadXmlSettings(string fileName);
bool isShiftKeyDown();

17
src/MediaServer/MediaServer.cpp

@ -315,20 +315,27 @@ string MediaServer::getDefaultMediaDir(int sourceType){
}
void MediaServer::addFboSource(ofx::piMapper::FboSource & fboSource){
ofLogNotice("MediaServer") << "Attempting to add FBO source with name " << fboSource.getName();
addFboSource(&fboSource);
}
void MediaServer::addFboSource(FboSource * fboSource){
ofLogNotice("MediaServer") << "Attempting to add FBO source with name " << fboSource->getName();
// FBO source has to be with unique name
for(int i = 0; i < fboSources.size(); i++){
if(fboSources[i]->getName() == fboSource.getName()){
for(int i = 0; i < fboSources.size(); ++i){
if(fboSources[i]->getName() == fboSource->getName()){
ofLogWarning("MediaServer") << "Attempt to add FBO source with duplicate name";
ofExit(EXIT_FAILURE); // Here we definitely need to fail to avoid confusion
std::exit(EXIT_FAILURE); // In case the openFrameworks function fails
}
}
ofLogNotice("MediaServer") << "Source new, adding";
fboSources.push_back(&fboSource);
fboSources.push_back(fboSource);
// It is important to run the setup of the FBO
// source from outside as we can see here.
fboSource.setup();
fboSource->setup();
}
BaseSource * MediaServer::loadFboSource(string & fboSourceName){

2
src/MediaServer/MediaServer.h

@ -62,6 +62,8 @@ class MediaServer {
// Do things with FBO sources
void addFboSource(FboSource & fboSource); // could be called also as register FBO source
void addFboSource(FboSource * fboSource);
BaseSource * loadFboSource(string & fboSourceName);
void unloadFboSource(string & fboSourceName);

4
src/ofxPiMapper.cpp

@ -14,6 +14,10 @@ void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){
_application.addFboSource(fboSource);
}
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource * fboSource){
_application.addFboSource(fboSource);
}
bool ofxPiMapper::loadXmlSettings(string fileName){
return _application.loadXmlSettings(fileName);
}

1
src/ofxPiMapper.h

@ -26,6 +26,7 @@ class ofxPiMapper {
void draw();
void registerFboSource(ofx::piMapper::FboSource & fboSource);
void registerFboSource(ofx::piMapper::FboSource * fboSource);
bool loadXmlSettings(string fileName);
private:

Loading…
Cancel
Save