2007-07-27 20:32:47 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
|
|
|
* Lubos Kulic
|
|
|
|
*/
|
2003-06-10 03:04:54 +04:00
|
|
|
#ifndef _K_DISK_DEVICE_JOB_H
|
|
|
|
#define _K_DISK_DEVICE_JOB_H
|
|
|
|
|
|
|
|
#include "disk_device_manager.h"
|
2007-07-27 16:12:35 +04:00
|
|
|
#include <KPartitionVisitor.h>
|
2003-06-10 03:04:54 +04:00
|
|
|
|
|
|
|
struct user_disk_device_job_info;
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
namespace DiskDevice {
|
|
|
|
|
2003-07-30 04:12:39 +04:00
|
|
|
class KDiskDeviceJobQueue;
|
|
|
|
|
2007-07-27 16:12:35 +04:00
|
|
|
/**
|
|
|
|
* Represents some action executed on the disk device.
|
|
|
|
*/
|
2003-06-10 03:04:54 +04:00
|
|
|
class KDiskDeviceJob {
|
|
|
|
public:
|
2003-07-30 04:12:39 +04:00
|
|
|
KDiskDeviceJob(uint32 type, partition_id partitionID,
|
|
|
|
partition_id scopeID = -1);
|
2003-06-10 03:04:54 +04:00
|
|
|
virtual ~KDiskDeviceJob();
|
|
|
|
|
|
|
|
disk_job_id ID() const;
|
|
|
|
|
2003-07-30 04:12:39 +04:00
|
|
|
void SetJobQueue(KDiskDeviceJobQueue *queue);
|
|
|
|
KDiskDeviceJobQueue *JobQueue() const;
|
|
|
|
|
|
|
|
uint32 Type() const;
|
2007-07-27 16:12:35 +04:00
|
|
|
|
2003-06-10 03:04:54 +04:00
|
|
|
void SetStatus(uint32 status);
|
|
|
|
uint32 Status() const;
|
|
|
|
|
2003-07-30 04:12:39 +04:00
|
|
|
status_t SetDescription(const char *description);
|
2003-06-10 03:04:54 +04:00
|
|
|
const char *Description() const;
|
|
|
|
|
|
|
|
partition_id PartitionID() const;
|
|
|
|
partition_id ScopeID() const;
|
|
|
|
|
2003-09-28 23:28:27 +04:00
|
|
|
status_t SetErrorMessage(const char *message);
|
|
|
|
const char *ErrorMessage() const;
|
|
|
|
|
2003-07-30 04:12:39 +04:00
|
|
|
void SetTaskCount(int32 count);
|
|
|
|
int32 TaskCount() const;
|
|
|
|
|
|
|
|
void SetCompletedTasks(int32 count);
|
|
|
|
int32 CompletedTasks() const;
|
|
|
|
|
|
|
|
void SetInterruptProperties(uint32 properties);
|
|
|
|
uint32 InterruptProperties() const;
|
|
|
|
|
|
|
|
virtual void GetTaskDescription(char *description);
|
|
|
|
|
|
|
|
void UpdateProgress(float progress);
|
2003-06-10 03:04:54 +04:00
|
|
|
// may trigger a notification
|
|
|
|
void UpdateExtraProgress(const char *info);
|
|
|
|
// triggers a notification
|
|
|
|
float Progress() const;
|
|
|
|
|
2007-07-27 16:12:35 +04:00
|
|
|
|
2003-06-10 03:04:54 +04:00
|
|
|
status_t GetInfo(user_disk_device_job_info *info);
|
2003-07-30 04:12:39 +04:00
|
|
|
status_t GetProgressInfo(disk_device_job_progress_info *info);
|
|
|
|
|
|
|
|
virtual status_t Do() = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static disk_job_id _NextID();
|
|
|
|
|
|
|
|
disk_job_id fID;
|
|
|
|
KDiskDeviceJobQueue *fJobQueue;
|
|
|
|
uint32 fType;
|
|
|
|
uint32 fStatus;
|
|
|
|
partition_id fPartitionID;
|
|
|
|
partition_id fScopeID;
|
|
|
|
char *fDescription;
|
2003-09-28 23:28:27 +04:00
|
|
|
char *fErrorMessage;
|
2003-07-30 04:12:39 +04:00
|
|
|
int32 fTaskCount;
|
|
|
|
int32 fCompletedTasks;
|
|
|
|
uint32 fInterruptProperties;
|
|
|
|
float fProgress;
|
|
|
|
|
|
|
|
static disk_job_id fNextID;
|
2007-07-27 16:12:35 +04:00
|
|
|
|
|
|
|
protected:
|
2007-07-27 20:32:47 +04:00
|
|
|
// some stuff useful for all descendants
|
2007-07-27 16:12:35 +04:00
|
|
|
|
2007-07-27 20:32:47 +04:00
|
|
|
bool IsPartitionNotBusy(KPartition* partition);
|
2007-07-27 16:12:35 +04:00
|
|
|
|
2003-06-10 03:04:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DiskDevice
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
using BPrivate::DiskDevice::KDiskDeviceJob;
|
|
|
|
|
|
|
|
#endif // _DISK_DEVICE_JOB_H
|