Browse Source

Add event handlers for the image and video directory watcher events

master
Krisjanis Rijnieks 11 years ago
parent
commit
98d65a3c50
  1. 30
      src/MediaServer/MediaServer.cpp
  2. 13
      src/MediaServer/MediaServer.h

30
src/MediaServer/MediaServer.cpp

@ -31,32 +31,38 @@ namespace piMapper {
return videoWatcher.getFilePaths();
}
void MediaServer::onImageAdded(string& path) {
void MediaServer::handleImageAdded(string& path) {
cout << "onImageAdded: " << path << endl;
cout << "numImages: " << getNumImages() << endl;
ofNotifyEvent(onImageAdded, path, this);
}
void MediaServer::onImageRemoved(string& path) {
void MediaServer::handleImageRemoved(string& path) {
cout << "onImageRemoved: " << path << endl;
cout << "numImages: " << getNumImages() << endl;
ofNotifyEvent(onImageRemoved, path, this);
}
void MediaServer::onVideoAdded(string& path) {
void MediaServer::handleVideoAdded(string& path) {
cout << "onVideoAdded: " << path << endl;
ofNotifyEvent(onVideoAdded, path, this);
}
void MediaServer::onVideoRemoved(string& path) {
void MediaServer::handleVideoRemoved(string& path) {
cout << "onVideoRemoved: " << path << endl;
ofNotifyEvent(onVideoRemoved, path, this);
}
void MediaServer::addWatcherListeners() {
ofAddListener(imageWatcher.onItemAdded, this, &MediaServer::onImageAdded);
ofAddListener(imageWatcher.onItemRemoved, this, &MediaServer::onImageRemoved);
ofAddListener(videoWatcher.onItemAdded, this, &MediaServer::onVideoAdded);
ofAddListener(videoWatcher.onItemRemoved, this, &MediaServer::onVideoRemoved);
ofAddListener(imageWatcher.onItemAdded, this, &MediaServer::handleImageAdded);
ofAddListener(imageWatcher.onItemRemoved, this, &MediaServer::handleImageRemoved);
ofAddListener(videoWatcher.onItemAdded, this, &MediaServer::handleVideoAdded);
ofAddListener(videoWatcher.onItemRemoved, this, &MediaServer::handleVideoRemoved);
}
void MediaServer::removeWatcherListeners() {
ofRemoveListener(imageWatcher.onItemAdded, this, &MediaServer::onImageAdded);
ofRemoveListener(imageWatcher.onItemRemoved, this, &MediaServer::onImageRemoved);
ofRemoveListener(videoWatcher.onItemAdded, this, &MediaServer::onVideoAdded);
ofRemoveListener(videoWatcher.onItemRemoved, this, &MediaServer::onVideoRemoved);
ofRemoveListener(imageWatcher.onItemAdded, this, &MediaServer::handleImageAdded);
ofRemoveListener(imageWatcher.onItemRemoved, this, &MediaServer::handleImageRemoved);
ofRemoveListener(videoWatcher.onItemAdded, this, &MediaServer::handleVideoAdded);
ofRemoveListener(videoWatcher.onItemRemoved, this, &MediaServer::handleVideoRemoved);
}
} // namespace piMapper

13
src/MediaServer/MediaServer.h

@ -28,7 +28,10 @@ class MediaServer {
std::vector<string>& getImagePaths();
// Custom events
//ofEvent<string> on
ofEvent<string> onImageAdded;
ofEvent<string> onImageRemoved;
ofEvent<string> onVideoAdded;
ofEvent<string> onVideoRemoved;
private:
// Directory Watchers
@ -36,8 +39,8 @@ class MediaServer {
ofx::piMapper::DirectoryWatcher imageWatcher;
// imageWatcher event listeners
void onImageAdded(string& path);
void onImageRemoved(string& path);
void handleImageAdded(string& path);
void handleImageRemoved(string& path);
// TODO rest of listeners
/*
void onImageModified();
@ -46,8 +49,8 @@ class MediaServer {
*/
// videoWatcher event listeners
void onVideoAdded(string& path);
void onVideoRemoved(string& path);
void handleVideoAdded(string& path);
void handleVideoRemoved(string& path);
// TODO rest of listeners
/*
void onVideoModified();

Loading…
Cancel
Save