1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef ABSTRACT_MODEL_LOADER_H 6#define ABSTRACT_MODEL_LOADER_H 7 8#include <Locker.h> 9#include <Messenger.h> 10 11 12class AbstractModelLoader { 13public: 14 AbstractModelLoader(const BMessenger& target, 15 void* targetCookie); 16 17protected: 18 virtual ~AbstractModelLoader(); 19 20public: 21 virtual status_t StartLoading(); 22 virtual void Abort(bool wait); 23 virtual void Delete(); 24 25protected: 26 virtual status_t PrepareForLoading(); 27 virtual status_t Load(); 28 virtual void FinishLoading(bool success); 29 30 void NotifyTarget(bool success); 31 32private: 33 static status_t _LoaderEntry(void* data); 34 status_t _Loader(); 35 36protected: 37 BLocker fLock; 38 BMessenger fTarget; 39 void* fTargetCookie; 40 thread_id fLoaderThread; 41 bool fLoading; 42 bool fAborted; 43}; 44 45 46#endif // ABSTRACT_MODEL_LOADER_H 47