#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::iterator entry_iterator; int nextID; int lastUpdate; map images_async_loading; // keeps track of images which are loading async ofThreadChannel images_to_load_from_disk; ofThreadChannel images_to_update; };