2012-06-13 13:42:55 +02:00
|
|
|
#ifndef CHECKTASK_H
|
|
|
|
#define CHECKTASK_H
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-06-18 17:23:48 +02:00
|
|
|
struct CheckTaskType;
|
|
|
|
|
2012-06-14 11:18:20 +02:00
|
|
|
class I2_ICINGA_API CheckTask : public Object
|
2012-06-13 13:42:55 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef shared_ptr<CheckTask> Ptr;
|
|
|
|
typedef weak_ptr<CheckTask> WeakPtr;
|
|
|
|
|
|
|
|
typedef function<CheckTask::Ptr(const Service&)> Factory;
|
2012-06-18 17:23:48 +02:00
|
|
|
typedef function<void()> QueueFlusher;
|
2012-06-13 13:42:55 +02:00
|
|
|
|
2012-06-27 23:38:50 +02:00
|
|
|
Service& GetService(void);
|
|
|
|
CheckResult& GetResult(void);
|
2012-06-17 22:46:40 +02:00
|
|
|
|
2012-06-18 17:23:48 +02:00
|
|
|
virtual void Enqueue(void) = 0;
|
2012-06-13 13:42:55 +02:00
|
|
|
|
2012-06-24 16:30:16 +02:00
|
|
|
static void RegisterType(string type, Factory factory, QueueFlusher qflusher);
|
2012-06-13 13:42:55 +02:00
|
|
|
static CheckTask::Ptr CreateTask(const Service& service);
|
2012-06-18 17:23:48 +02:00
|
|
|
static void Enqueue(const CheckTask::Ptr& task);
|
|
|
|
static void FlushQueue(void);
|
2012-06-24 16:30:16 +02:00
|
|
|
|
2012-06-28 15:43:49 +02:00
|
|
|
static int GetTaskHistogramSlots(void);
|
2012-06-24 16:30:16 +02:00
|
|
|
static void FinishTask(const CheckTask::Ptr& task);
|
2012-06-19 09:38:20 +02:00
|
|
|
static vector<CheckTask::Ptr> GetFinishedTasks(void);
|
2012-06-13 13:42:55 +02:00
|
|
|
|
2012-06-17 22:46:40 +02:00
|
|
|
protected:
|
|
|
|
CheckTask(const Service& service);
|
|
|
|
|
2012-06-13 13:42:55 +02:00
|
|
|
private:
|
2012-06-17 22:46:40 +02:00
|
|
|
Service m_Service;
|
2012-06-27 23:38:50 +02:00
|
|
|
CheckResult m_Result;
|
2012-06-17 22:46:40 +02:00
|
|
|
|
2012-06-18 17:23:48 +02:00
|
|
|
static map<string, CheckTaskType> m_Types;
|
2012-06-24 16:30:16 +02:00
|
|
|
|
|
|
|
static vector<CheckTask::Ptr> m_FinishedTasks;
|
|
|
|
static mutex m_FinishedTasksMutex;
|
2012-06-18 17:23:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CheckTaskType
|
|
|
|
{
|
|
|
|
CheckTask::Factory Factory;
|
|
|
|
CheckTask::QueueFlusher QueueFlusher;
|
2012-06-13 13:42:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CHECKTASK_H */
|