summaryrefslogtreecommitdiff
path: root/gui/src/threadedChainImageLoader.h
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/threadedChainImageLoader.h')
-rw-r--r--gui/src/threadedChainImageLoader.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/gui/src/threadedChainImageLoader.h b/gui/src/threadedChainImageLoader.h
new file mode 100644
index 0000000..01f0d03
--- /dev/null
+++ b/gui/src/threadedChainImageLoader.h
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "ofThread.h"
+#include "chainImage.h"
+#include "ofURLFileLoader.h"
+#include "ofTypes.h"
+#include "ofThreadChannel.h"
+
+
+using namespace std;
+
+class threadedChainImageLoader : public ofThread {
+public:
+ threadedChainImageLoader();
+ ~threadedChainImageLoader();
+
+ void loadFromDisk(chainImage& image, string file);
+ void loadFromURL(chainImage& image, string url);
+
+
+
+private:
+ void update(ofEventArgs & a);
+ virtual void threadedFunction();
+ void urlResponse(ofHttpResponse & response);
+
+ // Entry to load.
+ struct chainImageLoaderEntry {
+ chainImageLoaderEntry() {
+ image = NULL;
+ }
+
+ chainImageLoaderEntry(chainImage & pImage) {
+ image = &pImage;
+ }
+ chainImage* image;
+ string filename;
+ string url;
+ string name;
+ };
+
+
+ typedef map<string, chainImageLoaderEntry>::iterator entry_iterator;
+
+ int nextID;
+ int lastUpdate;
+
+ map<string,chainImageLoaderEntry> images_async_loading; // keeps track of images which are loading async
+ ofThreadChannel<chainImageLoaderEntry> images_to_load_from_disk;
+ ofThreadChannel<chainImageLoaderEntry> images_to_update;
+};
+
+