#ifndef _ThreadedImageLoader_ThreadedImageLoader_h #define _ThreadedImageLoader_ThreadedImageLoader_h #include #include #include #define LAYOUTFILE #include struct ThreadedImageLoadInfo : Moveable { String filepath; ThreadedImageLoadInfo() {} ThreadedImageLoadInfo(const String& in_filepath) : filepath(in_filepath) {} }; struct ThreadedImageLoadResult : public ThreadedImageLoadInfo , Moveable { PixelArray image; bool valid; ThreadedImageLoadResult() : valid(false) {} }; class ImageLoader { public: ImageLoader(); Callback WhenImageReady; volatile bool ReadyToLoad() const { return ready_to_load_; } volatile bool NewImageAvailable() const { return new_image_ready_; } inline void Reset() { new_image_ready_ = false; } const ThreadedImageLoadResult& Result() const { return loading_info_; } void LoadNextImage( const ThreadedImageLoadInfo& info ); void Die(); String Status() const { return status_; } void LoadingThreadFunction(); protected: volatile bool ready_to_load_; volatile bool new_image_ready_; volatile bool time_to_die_; ThreadedImageLoadResult loading_info_; String status_; Event job_ready_; }; class ThreadedImageLoader : public WithThreadedImageLoaderLayout { public: typedef ThreadedImageLoader CLASSNAME; ThreadedImageLoader(); ~ThreadedImageLoader(); void OnImageLoaded(); void OnSelectDir(); void SyncTime(); public: // Menu control MenuBar menus; void SetupMainMenu(Bar& bar); protected: ImageLoader loader; Thread loader_thread; Vector remaining; }; #endif