Browse Source

Remove `std::` prefix everywhere in `src`

master
Krisjanis Rijnieks 10 years ago
parent
commit
0fbfe7174b
  1. 2
      src/Commands/CmdManager.h
  2. 6
      src/MediaServer/DirectoryWatcher.cpp
  3. 6
      src/MediaServer/DirectoryWatcher.h
  4. 80
      src/MediaServer/MediaServer.cpp
  5. 50
      src/MediaServer/MediaServer.h
  6. 8
      src/Sources/BaseSource.cpp
  7. 10
      src/Sources/BaseSource.h
  8. 4
      src/Sources/ImageSource.cpp
  9. 4
      src/Sources/ImageSource.h
  10. 12
      src/Sources/SourceType.h
  11. 2
      src/Sources/VideoSource.cpp
  12. 4
      src/Sources/VideoSource.h
  13. 4
      src/Surfaces/QuadSurface.cpp
  14. 34
      src/Surfaces/SurfaceManager.cpp
  15. 2
      src/Surfaces/SurfaceManager.h
  16. 2
      src/Surfaces/SurfaceManagerGui.cpp
  17. 4
      src/Surfaces/TriangleSurface.cpp
  18. 2
      src/UserInterface/RadioList.cpp
  19. 2
      src/UserInterface/RadioList.h
  20. 26
      src/UserInterface/SourcesEditor.cpp
  21. 22
      src/UserInterface/SourcesEditor.h

2
src/Commands/CmdManager.h

@ -14,7 +14,7 @@ class CmdManager {
void undo(); void undo();
private: private:
std::vector <BaseUndoCmd *> cmdStack; vector <BaseUndoCmd *> cmdStack;
}; };

6
src/MediaServer/DirectoryWatcher.cpp

@ -11,7 +11,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){ DirectoryWatcher::DirectoryWatcher(string path, int watcherMediaType){
mediaType = watcherMediaType; mediaType = watcherMediaType;
// Decide what filter we need depending on media type // Decide what filter we need depending on media type
if(mediaType == SourceType::SOURCE_TYPE_VIDEO){ if(mediaType == SourceType::SOURCE_TYPE_VIDEO){
@ -20,7 +20,7 @@ DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){
filter = new ImagePathFilter(); filter = new ImagePathFilter();
}else{ }else{
ofLogFatalError("DirectoryWatcher::DirectoryWatcher", "Unkonwn media type"); ofLogFatalError("DirectoryWatcher::DirectoryWatcher", "Unkonwn media type");
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
dirWatcher.registerAllEvents(this); dirWatcher.registerAllEvents(this);
// For some reason the filters are not working, // For some reason the filters are not working,
@ -35,7 +35,7 @@ DirectoryWatcher::~DirectoryWatcher(){
filter = 0; filter = 0;
} }
std::vector <std::string> & DirectoryWatcher::getFilePaths(){ vector <string> & DirectoryWatcher::getFilePaths(){
return filePaths; return filePaths;
} }

6
src/MediaServer/DirectoryWatcher.h

@ -52,7 +52,7 @@ class ImagePathFilter : public BasePathFilter {
class DirectoryWatcher { class DirectoryWatcher {
public: public:
DirectoryWatcher(std::string path, int watcherMediaType); DirectoryWatcher(string path, int watcherMediaType);
~DirectoryWatcher(); ~DirectoryWatcher();
// TODO make useful stuff with onDirectoryWatcher* // TODO make useful stuff with onDirectoryWatcher*
@ -119,7 +119,7 @@ class DirectoryWatcher {
} }
// Getters // Getters
std::vector <std::string> & getFilePaths(); vector <string> & getFilePaths();
int getMediaType(); int getMediaType();
// Custom events // Custom events
@ -132,7 +132,7 @@ class DirectoryWatcher {
private: private:
ofx::IO::DirectoryWatcherManager dirWatcher; ofx::IO::DirectoryWatcherManager dirWatcher;
BasePathFilter * filter; BasePathFilter * filter;
std::vector <std::string> filePaths; vector <string> filePaths;
int mediaType; int mediaType;
}; };

80
src/MediaServer/MediaServer.cpp

@ -31,41 +31,41 @@ int MediaServer::getNumFboSources(){
return fboSources.size(); return fboSources.size();
} }
std::vector <std::string> & MediaServer::getImagePaths(){ vector <string> & MediaServer::getImagePaths(){
return imageWatcher.getFilePaths(); return imageWatcher.getFilePaths();
} }
std::vector <std::string> MediaServer::getImageNames(){ vector <string> MediaServer::getImageNames(){
std::vector <std::string> imageNames; vector <string> imageNames;
for(int i = 0; i < getNumImages(); i++){ for(int i = 0; i < getNumImages(); i++){
// Split image path // Split image path
std::vector <std::string> pathParts = ofSplitString(getImagePaths()[i], "/"); vector <string> pathParts = ofSplitString(getImagePaths()[i], "/");
// And get only the last piece // And get only the last piece
std::string name = pathParts[pathParts.size() - 1]; string name = pathParts[pathParts.size() - 1];
imageNames.push_back(name); imageNames.push_back(name);
} }
return imageNames; return imageNames;
} }
std::vector <std::string> MediaServer::getFboSourceNames(){ vector <string> MediaServer::getFboSourceNames(){
std::vector <std::string> fboSourceNames; vector <string> fboSourceNames;
for(int i = 0; i < fboSources.size(); i++){ for(int i = 0; i < fboSources.size(); i++){
fboSourceNames.push_back(fboSources[i]->getName()); fboSourceNames.push_back(fboSources[i]->getName());
} }
return fboSourceNames; return fboSourceNames;
} }
std::vector <std::string> & MediaServer::getVideoPaths(){ vector <string> & MediaServer::getVideoPaths(){
return videoWatcher.getFilePaths(); return videoWatcher.getFilePaths();
} }
std::vector <std::string> MediaServer::getVideoNames(){ vector <string> MediaServer::getVideoNames(){
std::vector <std::string> videoNames; vector <string> videoNames;
for(int i = 0; i < getNumVideos(); i++){ for(int i = 0; i < getNumVideos(); i++){
// Split video path // Split video path
std::vector <std::string> pathParts = ofSplitString(getVideoPaths()[i], "/"); vector <string> pathParts = ofSplitString(getVideoPaths()[i], "/");
// And get only the last piece // And get only the last piece
std::string name = pathParts[pathParts.size() - 1]; string name = pathParts[pathParts.size() - 1];
videoNames.push_back(name); videoNames.push_back(name);
} }
return videoNames; return videoNames;
@ -80,10 +80,10 @@ BaseSource * MediaServer::loadMedia(string & path, int mediaType){
}else if(mediaType == SourceType::SOURCE_TYPE_FBO){ }else if(mediaType == SourceType::SOURCE_TYPE_FBO){
return loadFboSource(path); return loadFboSource(path);
}else{ }else{
std::stringstream ss; stringstream ss;
ss << "Can not load media of unknown type: " << mediaType; ss << "Can not load media of unknown type: " << mediaType;
ofLogFatalError("MediaServer") << ss.str(); ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return 0; return 0;
} }
@ -101,11 +101,11 @@ BaseSource * MediaServer::loadImage(string & path){
// Increase reference count of this source // Increase reference count of this source
//referenceCount[path]++; //referenceCount[path]++;
imageSource->referenceCount++; imageSource->referenceCount++;
std::stringstream refss; stringstream refss;
refss << "Current reference count for " << path << " = " << imageSource->referenceCount; refss << "Current reference count for " << path << " = " << imageSource->referenceCount;
ofLogNotice("MediaServer") << refss.str(); ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event // Notify objects registered to onImageLoaded event
std::stringstream ss; stringstream ss;
ss << "Image " << path << " already loaded"; ss << "Image " << path << " already loaded";
ofLogNotice("MediaServer") << ss.str(); ofLogNotice("MediaServer") << ss.str();
ofNotifyEvent(onImageLoaded, path, this); ofNotifyEvent(onImageLoaded, path, this);
@ -117,7 +117,7 @@ BaseSource * MediaServer::loadImage(string & path){
loadedSources[path] = imageSource; loadedSources[path] = imageSource;
// Set reference count of this image path to 1 // Set reference count of this image path to 1
//referenceCount[path] = 1; //referenceCount[path] = 1;
std::stringstream refss; stringstream refss;
refss << "Initialized reference count of " << path << " to " << imageSource->referenceCount; refss << "Initialized reference count of " << path << " to " << imageSource->referenceCount;
ofLogNotice("MediaServer") << refss.str(); ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event // Notify objects registered to onImageLoaded event
@ -136,14 +136,14 @@ void MediaServer::unloadImage(string & path){
return; return;
} }
// Reference count 0 or less, unload image // Reference count 0 or less, unload image
std::stringstream ss; stringstream ss;
ss << "Removing image " << path; ss << "Removing image " << path;
ofLogNotice("MediaServer") << ss.str(); ofLogNotice("MediaServer") << ss.str();
// Destroy image source // Destroy image source
if(loadedSources.count(path)){ if(loadedSources.count(path)){
ofLogNotice("MediaServer") << "Source count BEFORE image removal: " << loadedSources.size() << endl; ofLogNotice("MediaServer") << "Source count BEFORE image removal: " << loadedSources.size() << endl;
loadedSources[path]->clear(); loadedSources[path]->clear();
std::map <std::string, BaseSource *>::iterator it = loadedSources.find(path); map <string, BaseSource *>::iterator it = loadedSources.find(path);
delete it->second; delete it->second;
loadedSources.erase(it); loadedSources.erase(it);
ofLogNotice("MediaServer") << "Source count AFTER image removal: " << loadedSources.size() << endl; ofLogNotice("MediaServer") << "Source count AFTER image removal: " << loadedSources.size() << endl;
@ -151,10 +151,10 @@ void MediaServer::unloadImage(string & path){
return; return;
} }
// Something wrong here, we should be out of the routine by now // Something wrong here, we should be out of the routine by now
std::stringstream failss; stringstream failss;
failss << "Failed to remove image source: " << path; failss << "Failed to remove image source: " << path;
ofLogFatalError("MediaServer") << failss.str(); ofLogFatalError("MediaServer") << failss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
BaseSource * MediaServer::loadVideo(string & path){ BaseSource * MediaServer::loadVideo(string & path){
@ -169,11 +169,11 @@ BaseSource * MediaServer::loadVideo(string & path){
if(isVideoLoaded){ if(isVideoLoaded){
// Increase reference count of this source // Increase reference count of this source
videoSource->referenceCount++; videoSource->referenceCount++;
std::stringstream refss; stringstream refss;
refss << "Current reference count for " << path << " = " << videoSource->referenceCount; refss << "Current reference count for " << path << " = " << videoSource->referenceCount;
ofLogNotice("MediaServer") << refss.str(); ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event // Notify objects registered to onImageLoaded event
std::stringstream ss; stringstream ss;
ss << "Video " << path << " already loaded"; ss << "Video " << path << " already loaded";
ofLogNotice("MediaServer") << ss.str(); ofLogNotice("MediaServer") << ss.str();
ofNotifyEvent(onVideoLoaded, path, this); ofNotifyEvent(onVideoLoaded, path, this);
@ -185,7 +185,7 @@ BaseSource * MediaServer::loadVideo(string & path){
loadedSources[path] = videoSource; loadedSources[path] = videoSource;
// Set reference count of this image path to 1 // Set reference count of this image path to 1
//referenceCount[path] = 1; //referenceCount[path] = 1;
std::stringstream refss; stringstream refss;
refss << "Initialized reference count of " << path << " to " << videoSource->referenceCount; refss << "Initialized reference count of " << path << " to " << videoSource->referenceCount;
ofLogNotice("MediaServer") << refss.str(); ofLogNotice("MediaServer") << refss.str();
ofNotifyEvent(onVideoLoaded, path, this); ofNotifyEvent(onVideoLoaded, path, this);
@ -208,7 +208,7 @@ void MediaServer::unloadVideo(string & path){
if(loadedSources.count(path)){ if(loadedSources.count(path)){
ofLogNotice("MediaServer") << "Source count before video removal: " << loadedSources.size() << endl; ofLogNotice("MediaServer") << "Source count before video removal: " << loadedSources.size() << endl;
videoSource->clear(); videoSource->clear();
std::map <std::string, BaseSource *>::iterator it = loadedSources.find(path); map <string, BaseSource *>::iterator it = loadedSources.find(path);
delete it->second; delete it->second;
loadedSources.erase(it); loadedSources.erase(it);
ofLogNotice("MediaServer") << "Source count after video removal: " << loadedSources.size() << endl; ofLogNotice("MediaServer") << "Source count after video removal: " << loadedSources.size() << endl;
@ -216,10 +216,10 @@ void MediaServer::unloadVideo(string & path){
return; return;
} }
// Something wrong here, we should be out of the routine by now // Something wrong here, we should be out of the routine by now
std::stringstream failss; stringstream failss;
failss << "Failed to remove video source: " << path; failss << "Failed to remove video source: " << path;
ofLogFatalError("MediaServer") << failss.str(); ofLogFatalError("MediaServer") << failss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
void MediaServer::unloadMedia(string & path){ void MediaServer::unloadMedia(string & path){
@ -234,7 +234,7 @@ void MediaServer::unloadMedia(string & path){
}else{ }else{
// Oh my god, what to do!? Relax and exit. // Oh my god, what to do!? Relax and exit.
ofLogFatalError("MediaServer") << "Attempt to unload media of unknown type"; ofLogFatalError("MediaServer") << "Attempt to unload media of unknown type";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
}else{ }else{
ofLogNotice("MediaServer") << "Nothing to unload"; ofLogNotice("MediaServer") << "Nothing to unload";
@ -243,7 +243,7 @@ void MediaServer::unloadMedia(string & path){
// Clear all loaded media // Clear all loaded media
void MediaServer::clear(){ void MediaServer::clear(){
typedef std::map <std::string, BaseSource *>::iterator it_type; typedef map <string, BaseSource *>::iterator it_type;
for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){ for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){
// Do not delete FBO source pointers as they are (and should be) initialized elsewhere // Do not delete FBO source pointers as they are (and should be) initialized elsewhere
if(i->second->getType() != SourceType::SOURCE_TYPE_FBO){ if(i->second->getType() != SourceType::SOURCE_TYPE_FBO){
@ -254,35 +254,35 @@ void MediaServer::clear(){
} }
// TODO: getLoadedSourceByPath // TODO: getLoadedSourceByPath
BaseSource * MediaServer::getSourceByPath(std::string & mediaPath){ BaseSource * MediaServer::getSourceByPath(string & mediaPath){
if(loadedSources.count(mediaPath)){ if(loadedSources.count(mediaPath)){
return loadedSources[mediaPath]; return loadedSources[mediaPath];
} }
// Source not found, exit with error // Source not found, exit with error
std::stringstream ss; stringstream ss;
ss << "Could not find source by path: " << mediaPath; ss << "Could not find source by path: " << mediaPath;
ofLogFatalError("MediaServer") << ss.str(); ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
std::string MediaServer::getDefaultImageDir(){ string MediaServer::getDefaultImageDir(){
return DEFAULT_IMAGES_DIR; return DEFAULT_IMAGES_DIR;
} }
std::string MediaServer::getDefaultVideoDir(){ string MediaServer::getDefaultVideoDir(){
return DEFAULT_VIDEOS_DIR; return DEFAULT_VIDEOS_DIR;
} }
std::string MediaServer::getDefaultMediaDir(int sourceType){ string MediaServer::getDefaultMediaDir(int sourceType){
if(sourceType == SourceType::SOURCE_TYPE_IMAGE){ if(sourceType == SourceType::SOURCE_TYPE_IMAGE){
return getDefaultImageDir(); return getDefaultImageDir();
}else if(sourceType == SourceType::SOURCE_TYPE_VIDEO){ }else if(sourceType == SourceType::SOURCE_TYPE_VIDEO){
return getDefaultVideoDir(); return getDefaultVideoDir();
}else{ }else{
std::stringstream ss; stringstream ss;
ss << "Could not get default media dir. Unknown source type: " << sourceType; ss << "Could not get default media dir. Unknown source type: " << sourceType;
ofLogFatalError("MediaServer") << ss.str(); ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -299,7 +299,7 @@ void MediaServer::addFboSource(ofx::piMapper::FboSource & fboSource){
fboSources.push_back(&fboSource); fboSources.push_back(&fboSource);
} // addFboSource } // addFboSource
BaseSource * MediaServer::loadFboSource(std::string & fboSourceName){ BaseSource * MediaServer::loadFboSource(string & fboSourceName){
ofLogNotice("MediaServer") << "Attempting to load FBO source with name " << fboSourceName; ofLogNotice("MediaServer") << "Attempting to load FBO source with name " << fboSourceName;
// Search for FBO source name in our storage // Search for FBO source name in our storage
FboSource * source = 0; FboSource * source = 0;
@ -331,7 +331,7 @@ BaseSource * MediaServer::loadFboSource(std::string & fboSourceName){
return loadedSources[fboSourceName]; return loadedSources[fboSourceName];
} // loadFboSource } // loadFboSource
void MediaServer::unloadFboSource(std::string & fboSourceName){ void MediaServer::unloadFboSource(string & fboSourceName){
ofLogNotice("MediaServer") << "Attempt to unload FBO source " << fboSourceName; ofLogNotice("MediaServer") << "Attempt to unload FBO source " << fboSourceName;
// Check if loaded at all // Check if loaded at all
if(!loadedSources.count(fboSourceName)){ if(!loadedSources.count(fboSourceName)){
@ -349,7 +349,7 @@ void MediaServer::unloadFboSource(std::string & fboSourceName){
ofLogNotice("MediaServer") << fboSourceName << " reference count <= 0, removing from loaded sources"; ofLogNotice("MediaServer") << fboSourceName << " reference count <= 0, removing from loaded sources";
source->referenceCount = 0; source->referenceCount = 0;
source->removeAppListeners(); source->removeAppListeners();
std::map <std::string, BaseSource *>::iterator it = loadedSources.find(fboSourceName); map <string, BaseSource *>::iterator it = loadedSources.find(fboSourceName);
loadedSources.erase(it); loadedSources.erase(it);
ofLogNotice("MediaServer") << "Source count after FBO source removal: " << loadedSources.size() << endl; ofLogNotice("MediaServer") << "Source count after FBO source removal: " << loadedSources.size() << endl;
ofNotifyEvent(onFboSourceUnloaded, fboSourceName, this); ofNotifyEvent(onFboSourceUnloaded, fboSourceName, this);

50
src/MediaServer/MediaServer.h

@ -37,11 +37,11 @@ class MediaServer {
int getNumVideos(); int getNumVideos();
int getNumImages(); int getNumImages();
int getNumFboSources(); // new int getNumFboSources(); // new
std::vector <std::string> & getVideoPaths(); vector <string> & getVideoPaths();
std::vector <std::string> getVideoNames(); vector <string> getVideoNames();
std::vector <std::string> & getImagePaths(); vector <string> & getImagePaths();
std::vector <std::string> getImageNames(); vector <string> getImageNames();
std::vector <std::string> getFboSourceNames(); // new vector <string> getFboSourceNames(); // new
BaseSource * loadMedia(string & path, int mediaType); BaseSource * loadMedia(string & path, int mediaType);
BaseSource * loadImage(string & path); BaseSource * loadImage(string & path);
@ -50,36 +50,36 @@ class MediaServer {
void unloadVideo(string & path); void unloadVideo(string & path);
void unloadMedia(string & path); void unloadMedia(string & path);
void clear(); // Force all loaded source unload void clear(); // Force all loaded source unload
BaseSource * getSourceByPath(std::string & mediaPath); BaseSource * getSourceByPath(string & mediaPath);
std::string getDefaultImageDir(); string getDefaultImageDir();
std::string getDefaultVideoDir(); string getDefaultVideoDir();
std::string getDefaultMediaDir(int sourceType); string getDefaultMediaDir(int sourceType);
// Do things with FBO sources // Do things with FBO sources
void addFboSource(FboSource & fboSource); // could be called also as register FBO source void addFboSource(FboSource & fboSource); // could be called also as register FBO source
BaseSource * loadFboSource(std::string & fboSourceName); BaseSource * loadFboSource(string & fboSourceName);
void unloadFboSource(std::string & fboSourceName); void unloadFboSource(string & fboSourceName);
// Custom events, add/remove // Custom events, add/remove
ofEvent <std::string> onImageAdded; ofEvent <string> onImageAdded;
ofEvent <std::string> onImageRemoved; ofEvent <string> onImageRemoved;
ofEvent <std::string> onVideoAdded; ofEvent <string> onVideoAdded;
ofEvent <std::string> onVideoRemoved; ofEvent <string> onVideoRemoved;
ofEvent <std::string> onFboSourceAdded; ofEvent <string> onFboSourceAdded;
ofEvent <std::string> onFboSourceRemoved; ofEvent <string> onFboSourceRemoved;
// load/unload // load/unload
ofEvent <std::string> onImageLoaded; ofEvent <string> onImageLoaded;
ofEvent <std::string> onImageUnloaded; ofEvent <string> onImageUnloaded;
ofEvent <std::string> onVideoLoaded; ofEvent <string> onVideoLoaded;
ofEvent <std::string> onVideoUnloaded; ofEvent <string> onVideoUnloaded;
ofEvent <std::string> onFboSourceLoaded; ofEvent <string> onFboSourceLoaded;
ofEvent <std::string> onFboSourceUnloaded; ofEvent <string> onFboSourceUnloaded;
private: private:
// Directory Watchers // Directory Watchers
ofx::piMapper::DirectoryWatcher videoWatcher; ofx::piMapper::DirectoryWatcher videoWatcher;
ofx::piMapper::DirectoryWatcher imageWatcher; ofx::piMapper::DirectoryWatcher imageWatcher;
std::map <std::string, BaseSource *> loadedSources; map <string, BaseSource *> loadedSources;
// imageWatcher event listeners // imageWatcher event listeners
void handleImageAdded(string & path); void handleImageAdded(string & path);
void handleImageRemoved(string & path); void handleImageRemoved(string & path);
@ -108,7 +108,7 @@ class MediaServer {
void removeWatcherListeners(); void removeWatcherListeners();
// FBO source storage before they go to loadedSources // FBO source storage before they go to loadedSources
std::vector <FboSource *> fboSources; // FBO source storage vector <FboSource *> fboSources; // FBO source storage
}; };
} // namespace piMapper } // namespace piMapper

8
src/Sources/BaseSource.cpp

@ -19,7 +19,7 @@ ofTexture * BaseSource::getTexture(){
return texture; return texture;
} }
std::string & BaseSource::getName(){ string & BaseSource::getName(){
return name; return name;
} }
@ -35,7 +35,7 @@ int BaseSource::getType(){
return type; return type;
} }
std::string & BaseSource::getPath(){ string & BaseSource::getPath(){
return path; return path;
} }
@ -49,8 +49,8 @@ void BaseSource::init(){
referenceCount = 1; // We have one instance on init referenceCount = 1; // We have one instance on init
} }
void BaseSource::setNameFromPath(std::string & fullPath){ void BaseSource::setNameFromPath(string & fullPath){
std::vector <string> pathParts; vector <string> pathParts;
//cout << "fullPath: " << fullPath << endl; //cout << "fullPath: " << fullPath << endl;
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl; //cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;

10
src/Sources/BaseSource.h

@ -14,11 +14,11 @@ class BaseSource {
BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture
~BaseSource(); ~BaseSource();
ofTexture * getTexture(); ofTexture * getTexture();
std::string & getName(); string & getName();
bool isLoadable(); // Maybe the loading features shoud go to a derrived class bool isLoadable(); // Maybe the loading features shoud go to a derrived class
bool isLoaded(); // as BaseSourceLoadable bool isLoaded(); // as BaseSourceLoadable
int getType(); int getType();
std::string & getPath(); string & getPath();
virtual void clear(){} virtual void clear(){}
// TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods // TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods
@ -29,10 +29,10 @@ class BaseSource {
void init(); void init();
protected: protected:
void setNameFromPath(std::string & fullPath); void setNameFromPath(string & fullPath);
ofTexture * texture; ofTexture * texture;
std::string name; string name;
std::string path; // This is set only if loadable is true string path; // This is set only if loadable is true
bool loadable; // If the source can be loaded from disk like image and video bool loadable; // If the source can be loaded from disk like image and video
bool loaded; // Is the source loaded? bool loaded; // Is the source loaded?
int type; int type;

4
src/Sources/ImageSource.cpp

@ -12,7 +12,7 @@ ImageSource::ImageSource(){
ImageSource::~ImageSource(){} ImageSource::~ImageSource(){}
void ImageSource::loadImage(std::string & filePath){ void ImageSource::loadImage(string & filePath){
path = filePath; path = filePath;
//cout << "loading image: " << filePath << endl; //cout << "loading image: " << filePath << endl;
setNameFromPath(filePath); setNameFromPath(filePath);
@ -24,7 +24,7 @@ void ImageSource::loadImage(std::string & filePath){
if(!image->loadImage(filePath)){ if(!image->loadImage(filePath)){
#endif #endif
ofLogWarning("ImageSource") << "Could not load image"; ofLogWarning("ImageSource") << "Could not load image";
//std::exit(EXIT_FAILURE); //exit(EXIT_FAILURE);
} }
#if (OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR >= 9) || OF_VERSION_MAJOR > 0 #if (OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR >= 9) || OF_VERSION_MAJOR > 0
texture = &image->getTexture(); texture = &image->getTexture();

4
src/Sources/ImageSource.h

@ -10,8 +10,8 @@ class ImageSource : public BaseSource {
public: public:
ImageSource(); ImageSource();
~ImageSource(); ~ImageSource();
std::string & getPath(); string & getPath();
void loadImage(std::string & filePath); void loadImage(string & filePath);
void clear(); void clear();
private: private:
ofImage * image; ofImage * image;

12
src/Sources/SourceType.h

@ -17,7 +17,7 @@ class SourceType {
SOURCE_TYPE_NONE, SOURCE_TYPE_IMAGE, SOURCE_TYPE_VIDEO, SOURCE_TYPE_FBO SOURCE_TYPE_NONE, SOURCE_TYPE_IMAGE, SOURCE_TYPE_VIDEO, SOURCE_TYPE_FBO
}; };
static std::string GetSourceTypeName(int sourceTypeEnum){ static string GetSourceTypeName(int sourceTypeEnum){
if(sourceTypeEnum == SOURCE_TYPE_IMAGE){ if(sourceTypeEnum == SOURCE_TYPE_IMAGE){
return SOURCE_TYPE_NAME_IMAGE; return SOURCE_TYPE_NAME_IMAGE;
}else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){ }else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){
@ -27,14 +27,14 @@ class SourceType {
}else if(sourceTypeEnum == SOURCE_TYPE_FBO){ }else if(sourceTypeEnum == SOURCE_TYPE_FBO){
return SOURCE_TYPE_NAME_FBO; return SOURCE_TYPE_NAME_FBO;
}else{ }else{
std::stringstream ss; stringstream ss;
ss << "Invalid source type: " << sourceTypeEnum; ss << "Invalid source type: " << sourceTypeEnum;
ofLogFatalError("SourceType") << ss.str(); ofLogFatalError("SourceType") << ss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
static int GetSourceTypeEnum(std::string sourceTypeName){ static int GetSourceTypeEnum(string sourceTypeName){
if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){ if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){
return SOURCE_TYPE_IMAGE; return SOURCE_TYPE_IMAGE;
}else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){ }else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){
@ -44,10 +44,10 @@ class SourceType {
}else if(sourceTypeName == SOURCE_TYPE_NAME_FBO){ }else if(sourceTypeName == SOURCE_TYPE_NAME_FBO){
return SOURCE_TYPE_FBO; return SOURCE_TYPE_FBO;
}else{ }else{
std::stringstream ss; stringstream ss;
ss << "Invalid source type name: " << sourceTypeName; ss << "Invalid source type name: " << sourceTypeName;
ofLogFatalError("SourceType") << ss.str(); ofLogFatalError("SourceType") << ss.str();
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }

2
src/Sources/VideoSource.cpp

@ -18,7 +18,7 @@ VideoSource::VideoSource(){
VideoSource::~VideoSource(){} VideoSource::~VideoSource(){}
void VideoSource::loadVideo(std::string & filePath){ void VideoSource::loadVideo(string & filePath){
path = filePath; path = filePath;
setNameFromPath(filePath); setNameFromPath(filePath);
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI

4
src/Sources/VideoSource.h

@ -21,8 +21,8 @@ class VideoSource : public BaseSource {
VideoSource(); VideoSource();
~VideoSource(); ~VideoSource();
std::string & getPath(); string & getPath();
void loadVideo(std::string & path); void loadVideo(string & path);
void clear(); void clear();
#ifndef TARGET_RASPBERRY_PI #ifndef TARGET_RASPBERRY_PI

4
src/Surfaces/QuadSurface.cpp

@ -141,7 +141,7 @@ bool QuadSurface::hitTest(ofVec2f p){
ofVec2f QuadSurface::getVertex(int index){ ofVec2f QuadSurface::getVertex(int index){
if(index > 3){ if(index > 3){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << endl;
throw std::runtime_error("Vertex index out of bounds."); throw runtime_error("Vertex index out of bounds.");
} }
ofVec3f vert = mesh.getVertex(index); ofVec3f vert = mesh.getVertex(index);
@ -150,7 +150,7 @@ ofVec2f QuadSurface::getVertex(int index){
ofVec2f QuadSurface::getTexCoord(int index){ ofVec2f QuadSurface::getTexCoord(int index){
if(index > 3){ if(index > 3){
throw std::runtime_error("Texture coordinate index out of bounds."); throw runtime_error("Texture coordinate index out of bounds.");
} }
return mesh.getTexCoord(index); return mesh.getTexCoord(index);

34
src/Surfaces/SurfaceManager.cpp

@ -25,7 +25,7 @@ void SurfaceManager::addSurface(int surfaceType){
surfaces.push_back(new QuadSurface()); surfaces.push_back(new QuadSurface());
}else{ }else{
ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type"; ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -38,7 +38,7 @@ void SurfaceManager::addSurface(int surfaceType, BaseSource * newSource){
surfaces.back()->setSource(newSource); surfaces.back()->setSource(newSource);
}else{ }else{
ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type"; ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -46,10 +46,10 @@ void SurfaceManager::addSurface(int surfaceType, vector <ofVec2f> vertices,
vector <ofVec2f> texCoords){ vector <ofVec2f> texCoords){
if(surfaceType == SurfaceType::TRIANGLE_SURFACE){ if(surfaceType == SurfaceType::TRIANGLE_SURFACE){
if(vertices.size() < 3){ if(vertices.size() < 3){
throw std::runtime_error( throw runtime_error(
"There must be 3 vertices for a triangle surface."); "There must be 3 vertices for a triangle surface.");
}else if(texCoords.size() < 3){ }else if(texCoords.size() < 3){
throw std::runtime_error( throw runtime_error(
"There must be 3 texture coordinates for a triangle surface."); "There must be 3 texture coordinates for a triangle surface.");
} }
@ -62,9 +62,9 @@ void SurfaceManager::addSurface(int surfaceType, vector <ofVec2f> vertices,
}else if(surfaceType == SurfaceType::QUAD_SURFACE){ }else if(surfaceType == SurfaceType::QUAD_SURFACE){
if(vertices.size() < 4){ if(vertices.size() < 4){
throw std::runtime_error("There must be 4 vertices for a quad surface."); throw runtime_error("There must be 4 vertices for a quad surface.");
}else if(texCoords.size() < 4){ }else if(texCoords.size() < 4){
throw std::runtime_error( throw runtime_error(
"There must be 4 texture coordinates for a quad surface."); "There must be 4 texture coordinates for a quad surface.");
} }
@ -76,7 +76,7 @@ void SurfaceManager::addSurface(int surfaceType, vector <ofVec2f> vertices,
} }
}else{ }else{
ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type"; ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -85,10 +85,10 @@ void SurfaceManager::addSurface(int surfaceType, BaseSource * newSource,
vector <ofVec2f> texCoords){ vector <ofVec2f> texCoords){
if(surfaceType == SurfaceType::TRIANGLE_SURFACE){ if(surfaceType == SurfaceType::TRIANGLE_SURFACE){
if(vertices.size() < 3){ if(vertices.size() < 3){
throw std::runtime_error( throw runtime_error(
"There must be 3 vertices for a triangle surface."); "There must be 3 vertices for a triangle surface.");
}else if(texCoords.size() < 3){ }else if(texCoords.size() < 3){
throw std::runtime_error( throw runtime_error(
"Thre must be 3 texture coordinates for a triangle surface."); "Thre must be 3 texture coordinates for a triangle surface.");
} }
@ -102,9 +102,9 @@ void SurfaceManager::addSurface(int surfaceType, BaseSource * newSource,
}else if(surfaceType == SurfaceType::QUAD_SURFACE){ }else if(surfaceType == SurfaceType::QUAD_SURFACE){
if(vertices.size() < 4){ if(vertices.size() < 4){
throw std::runtime_error("There must be 4 vertices for a quad surface."); throw runtime_error("There must be 4 vertices for a quad surface.");
}else if(texCoords.size() < 4){ }else if(texCoords.size() < 4){
throw std::runtime_error( throw runtime_error(
"Thre must be 4 texture coordinates for a quad surface."); "Thre must be 4 texture coordinates for a quad surface.");
} }
@ -117,7 +117,7 @@ void SurfaceManager::addSurface(int surfaceType, BaseSource * newSource,
} }
}else{ }else{
ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type"; ofLogFatalError("SurfaceManager") << "Attempt to add non-existing surface type";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -162,7 +162,7 @@ void SurfaceManager::saveXmlSettings(string fileName){
// Exit if mediaServer not set // Exit if mediaServer not set
if(mediaServer == 0){ if(mediaServer == 0){
ofLogFatalError("SurfaceManager") << "Media server not set"; ofLogFatalError("SurfaceManager") << "Media server not set";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// We need a fresh copy of the xml settings object // We need a fresh copy of the xml settings object
xmlSettings.clear(); xmlSettings.clear();
@ -219,7 +219,7 @@ void SurfaceManager::loadXmlSettings(string fileName){
// Exit if there is no media server // Exit if there is no media server
if(mediaServer == 0){ if(mediaServer == 0){
ofLogFatalError("SurfaceManager") << "Media server not set"; ofLogFatalError("SurfaceManager") << "Media server not set";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if(!xmlSettings.loadFile(fileName)){ if(!xmlSettings.loadFile(fileName)){
ofLogWarning("SurfaceManager") << "Could not load XML settings"; ofLogWarning("SurfaceManager") << "Could not load XML settings";
@ -249,7 +249,7 @@ void SurfaceManager::loadXmlSettings(string fileName){
}else{ }else{
// Construct full path // Construct full path
string dir = mediaServer->getDefaultMediaDir(typeEnum); string dir = mediaServer->getDefaultMediaDir(typeEnum);
std::stringstream pathss; stringstream pathss;
pathss << ofToDataPath(dir, true) << sourceName; pathss << ofToDataPath(dir, true) << sourceName;
string sourcePath = pathss.str(); string sourcePath = pathss.str();
// Load media by using full path // Load media by using full path
@ -383,7 +383,7 @@ void SurfaceManager::setMediaServer(MediaServer * newMediaServer){
BaseSurface * SurfaceManager::selectSurface(int index){ BaseSurface * SurfaceManager::selectSurface(int index){
if(index >= surfaces.size()){ if(index >= surfaces.size()){
throw std::runtime_error("Surface index out of bounds."); throw runtime_error("Surface index out of bounds.");
} }
selectedSurface = surfaces[index]; selectedSurface = surfaces[index];
@ -414,7 +414,7 @@ void SurfaceManager::deselectSurface(){
BaseSurface * SurfaceManager::getSurface(int index){ BaseSurface * SurfaceManager::getSurface(int index){
if(index >= surfaces.size()){ if(index >= surfaces.size()){
throw std::runtime_error("Surface index out of bounds."); throw runtime_error("Surface index out of bounds.");
return 0; return 0;
} }

2
src/Surfaces/SurfaceManager.h

@ -52,7 +52,7 @@ class SurfaceManager {
void deselectSurface(); void deselectSurface();
private: private:
std::vector <BaseSurface *> surfaces; vector <BaseSurface *> surfaces;
BaseSurface * selectedSurface; BaseSurface * selectedSurface;
ofxXmlSettings xmlSettings; ofxXmlSettings xmlSettings;
MediaServer * mediaServer; MediaServer * mediaServer;

2
src/Surfaces/SurfaceManagerGui.cpp

@ -248,7 +248,7 @@ void SurfaceManagerGui::setMode(int newGuiMode){
if(newGuiMode != GuiMode::NONE && newGuiMode != GuiMode::TEXTURE_MAPPING && if(newGuiMode != GuiMode::NONE && newGuiMode != GuiMode::TEXTURE_MAPPING &&
newGuiMode != GuiMode::PROJECTION_MAPPING && newGuiMode != GuiMode::PROJECTION_MAPPING &&
newGuiMode != GuiMode::SOURCE_SELECTION){ newGuiMode != GuiMode::SOURCE_SELECTION){
throw std::runtime_error("Trying to set invalid mode."); throw runtime_error("Trying to set invalid mode.");
} }
if(newGuiMode == GuiMode::NONE){ if(newGuiMode == GuiMode::NONE){

4
src/Surfaces/TriangleSurface.cpp

@ -98,7 +98,7 @@ bool TriangleSurface::hitTest(ofVec2f p){
ofVec2f TriangleSurface::getVertex(int index){ ofVec2f TriangleSurface::getVertex(int index){
if(index > 2){ if(index > 2){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << endl;
throw std::runtime_error("Vertex index out of bounds."); throw runtime_error("Vertex index out of bounds.");
} }
ofVec3f vert = mesh.getVertex(index); ofVec3f vert = mesh.getVertex(index);
@ -107,7 +107,7 @@ ofVec2f TriangleSurface::getVertex(int index){
ofVec2f TriangleSurface::getTexCoord(int index){ ofVec2f TriangleSurface::getTexCoord(int index){
if(index > 2){ if(index > 2){
throw std::runtime_error("Texture coordinate index out of bounds."); throw runtime_error("Texture coordinate index out of bounds.");
} }
return mesh.getTexCoord(index); return mesh.getTexCoord(index);

2
src/UserInterface/RadioList.cpp

@ -85,7 +85,7 @@ void RadioList::selectItem(int index){
storedSelectedItem = index; storedSelectedItem = index;
} }
bool RadioList::selectItemByValue(std::string itemValue){ bool RadioList::selectItemByValue(string itemValue){
if(itemValue == ""){ if(itemValue == ""){
ofLogNotice("RadioList") << "Item value empty"; ofLogNotice("RadioList") << "Item value empty";
return false; return false;

2
src/UserInterface/RadioList.h

@ -22,7 +22,7 @@ class RadioList {
void setPosition(ofPoint p); void setPosition(ofPoint p);
void setPosition(float x, float y); void setPosition(float x, float y);
void selectItem(int index); void selectItem(int index);
bool selectItemByValue(std::string itemValue); bool selectItemByValue(string itemValue);
void enable(); void enable();
void disable(); void disable();
void clear(); void clear();

26
src/UserInterface/SourcesEditor.cpp

@ -66,7 +66,7 @@ void SourcesEditor::setup(ofEventArgs & args){
ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditor::handleVideoSelected); ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditor::handleVideoSelected);
} }
if(numFbos){ if(numFbos){
std::vector <std::string> fboNames = mediaServer->getFboSourceNames(); vector <string> fboNames = mediaServer->getFboSourceNames();
fboSelector->setup("FBOs", fboNames, fboNames); fboSelector->setup("FBOs", fboNames, fboNames);
ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditor::handleFboSelected); ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditor::handleFboSelected);
} }
@ -157,7 +157,7 @@ void SourcesEditor::setMediaServer(MediaServer * newMediaServer){
if(newMediaServer == 0){ if(newMediaServer == 0){
// Log an error and return from the routine // Log an error and return from the routine
ofLogFatalError("SourcesEditor") << "New media server is 0"; ofLogFatalError("SourcesEditor") << "New media server is 0";
std::exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// Attempt to clear existing media server and assign new one // Attempt to clear existing media server and assign new one
clearMediaServer(); clearMediaServer();
@ -167,7 +167,7 @@ void SourcesEditor::setMediaServer(MediaServer * newMediaServer){
isMediaServerExternal = true; isMediaServerExternal = true;
} }
void SourcesEditor::selectSourceRadioButton(std::string & sourcePath){ void SourcesEditor::selectSourceRadioButton(string & sourcePath){
if(sourcePath == ""){ if(sourcePath == ""){
ofLogNotice("SourcesEditor") << "Path is empty"; ofLogNotice("SourcesEditor") << "Path is empty";
if(imageSelector->size()){ if(imageSelector->size()){
@ -358,16 +358,16 @@ void SourcesEditor::clearMediaServer(){
} }
} }
void SourcesEditor::handleImageAdded(std::string & path){} void SourcesEditor::handleImageAdded(string & path){}
void SourcesEditor::handleImageRemoved(std::string & path){} void SourcesEditor::handleImageRemoved(string & path){}
void SourcesEditor::handleVideoAdded(std::string & path){} void SourcesEditor::handleVideoAdded(string & path){}
void SourcesEditor::handleVideoRemoved(std::string & path){} void SourcesEditor::handleVideoRemoved(string & path){}
void SourcesEditor::handleImageLoaded(std::string & path){} void SourcesEditor::handleImageLoaded(string & path){}
void SourcesEditor::handleImageUnloaded(std::string & path){} void SourcesEditor::handleImageUnloaded(string & path){}
void SourcesEditor::handleFboSourceAdded(std::string & name){} void SourcesEditor::handleFboSourceAdded(string & name){}
void SourcesEditor::handleFboSourceRemoved(std::string & name){} void SourcesEditor::handleFboSourceRemoved(string & name){}
void SourcesEditor::handleFboSourceLoaded(std::string & name){} void SourcesEditor::handleFboSourceLoaded(string & name){}
void SourcesEditor::handleFboSourceUnloaded(std::string & name){} void SourcesEditor::handleFboSourceUnloaded(string & name){}
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

22
src/UserInterface/SourcesEditor.h

@ -35,7 +35,7 @@ class SourcesEditor {
// Sets external MediaServer // Sets external MediaServer
void setMediaServer(MediaServer * newMediaServer); void setMediaServer(MediaServer * newMediaServer);
//void selectImageSourceRadioButton(string name); //void selectImageSourceRadioButton(string name);
void selectSourceRadioButton(std::string & sourcePath); void selectSourceRadioButton(string & sourcePath);
int getLoadedTexCount(); int getLoadedTexCount();
ofTexture * getTexture(int index); ofTexture * getTexture(int index);
@ -74,16 +74,16 @@ class SourcesEditor {
void clearMediaServer(); void clearMediaServer();
// MediaServer event handlers // MediaServer event handlers
void handleImageAdded(std::string & path); void handleImageAdded(string & path);
void handleImageRemoved(std::string & path); void handleImageRemoved(string & path);
void handleVideoAdded(std::string & path); void handleVideoAdded(string & path);
void handleVideoRemoved(std::string & path); void handleVideoRemoved(string & path);
void handleImageLoaded(std::string & path); void handleImageLoaded(string & path);
void handleImageUnloaded(std::string & path); void handleImageUnloaded(string & path);
void handleFboSourceAdded(std::string & name); void handleFboSourceAdded(string & name);
void handleFboSourceRemoved(std::string & name); void handleFboSourceRemoved(string & name);
void handleFboSourceLoaded(std::string & name); void handleFboSourceLoaded(string & name);
void handleFboSourceUnloaded(std::string & name); void handleFboSourceUnloaded(string & name);
}; };

Loading…
Cancel
Save