Added DiskDevicePrivate.{h,cpp}, which contains the internally used iteration support classes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2665 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,55 @@
|
|||||||
|
//----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _DISK_DEVICE_PRIVATE_H
|
||||||
|
#define _DISK_DEVICE_PRIVATE_H
|
||||||
|
|
||||||
|
#include <DiskDeviceVisitor.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
// PartitionFilter
|
||||||
|
class PartitionFilter {
|
||||||
|
public:
|
||||||
|
virtual bool Filter(BPartition *partition) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// PartitionFilterVisitor
|
||||||
|
class PartitionFilterVisitor : public BDiskDeviceVisitor {
|
||||||
|
public:
|
||||||
|
PartitionFilterVisitor(BDiskDeviceVisitor *visitor,
|
||||||
|
PartitionFilter *filter);
|
||||||
|
|
||||||
|
virtual bool Visit(BDiskDevice *device);
|
||||||
|
virtual bool Visit(BSession *session);
|
||||||
|
virtual bool Visit(BPartition *partition);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BDiskDeviceVisitor *fVisitor;
|
||||||
|
PartitionFilter *fFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
// IDFinderVisitor
|
||||||
|
class IDFinderVisitor : public BDiskDeviceVisitor {
|
||||||
|
public:
|
||||||
|
IDFinderVisitor(int32 id);
|
||||||
|
|
||||||
|
virtual bool Visit(BDiskDevice *device);
|
||||||
|
virtual bool Visit(BSession *session);
|
||||||
|
virtual bool Visit(BPartition *partition);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fID;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
using BPrivate::PartitionFilter;
|
||||||
|
using BPrivate::PartitionFilterVisitor;
|
||||||
|
using BPrivate::IDFinderVisitor;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _DISK_DEVICE_PRIVATE_H
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//----------------------------------------------------------------------
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <DiskDevicePrivate.h>
|
||||||
|
#include <DiskDevice.h>
|
||||||
|
#include <Partition.h>
|
||||||
|
#include <Session.h>
|
||||||
|
|
||||||
|
// PartitionFilterVisitor
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
PartitionFilterVisitor::PartitionFilterVisitor(BDiskDeviceVisitor *visitor,
|
||||||
|
PartitionFilter *filter)
|
||||||
|
: BDiskDeviceVisitor(),
|
||||||
|
fVisitor(visitor),
|
||||||
|
fFilter(filter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
PartitionFilterVisitor::Visit(BDiskDevice *device)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
PartitionFilterVisitor::Visit(BSession *session)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
PartitionFilterVisitor::Visit(BPartition *partition)
|
||||||
|
{
|
||||||
|
if (fFilter->Filter(partition))
|
||||||
|
return fVisitor->Visit(partition);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// IDFinderVisitor
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
IDFinderVisitor::IDFinderVisitor(int32 id)
|
||||||
|
: BDiskDeviceVisitor(),
|
||||||
|
fID(id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
IDFinderVisitor::Visit(BDiskDevice *device)
|
||||||
|
{
|
||||||
|
return (device->UniqueID() == fID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
IDFinderVisitor::Visit(BSession *session)
|
||||||
|
{
|
||||||
|
return (session->UniqueID() == fID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visit
|
||||||
|
bool
|
||||||
|
IDFinderVisitor::Visit(BPartition *partition)
|
||||||
|
{
|
||||||
|
return (partition->UniqueID() == fID);
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user