/* * FragmentQueue.hpp * * Created on: Oct 19, 2011 * Author: heber */ #ifndef FRAGMENTQUEUE_HPP_ #define FRAGMENTQUEUE_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "types.hpp" #include "Jobs/FragmentJob.hpp" #include "Results/FragmentResult.hpp" class FragmentQueueTest; /** This class contains a deque for temporarily storing the FragmentJob * instances until they are received by the server. Also all results are * contained herein. */ class FragmentQueue { friend class FragmentQueueTest; public: FragmentQueue(); ~FragmentQueue(); // entering jobs into queue void pushJob(FragmentJob::ptr job); void pushJobs(std::vector &_jobs); FragmentJob::ptr popJob(); bool isJobPresent() const; // querying for results bool isResultPresent(JobId_t jobid) const; FragmentResult::ptr getResult(JobId_t jobid); void pushResult(FragmentResult::ptr &result); std::vector getAllResults(); size_t getDoneJobs() const; size_t getPresentJobs() const; private: bool isPresentResult(const FragmentResult::ptr result) const; //!> result that takes place in ResultQueue after job has arrived before it has been popped. static FragmentResult::ptr NoResult; //!> result that takes place in ResultQueue until real result has arrived. static FragmentResult::ptr NoResultQueued; //!> result that takes place in ResultQueue after real result has been delivered. static FragmentResult::ptr ResultDelivered; typedef std::deque JobQueue; typedef std::map ResultMap; //!> queue for all jobs JobQueue jobs; //!> map for all results that have been polled by the server ResultMap results; }; #endif /* FRAGMENTQUEUE_HPP_ */