1 /*
2 * Copyright 2003-2006, Haiku Inc.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Ingo Weinhold, bonefish@users.sf.net
7 */
8
9
10 #include <DiskDevicePrivate.h>
11 #include <DiskDevice.h>
12 #include <Partition.h>
13
14
~PartitionFilter()15 PartitionFilter::~PartitionFilter()
16 {
17 }
18
19
20 // #pragma mark - PartitionFilterVisitor
21
22 // constructor
PartitionFilterVisitor(BDiskDeviceVisitor * visitor,PartitionFilter * filter)23 PartitionFilterVisitor::PartitionFilterVisitor(BDiskDeviceVisitor *visitor,
24 PartitionFilter *filter)
25 : BDiskDeviceVisitor(),
26 fVisitor(visitor),
27 fFilter(filter)
28 {
29 }
30
31 // Visit
32 bool
Visit(BDiskDevice * device)33 PartitionFilterVisitor::Visit(BDiskDevice *device)
34 {
35 if (fFilter->Filter(device, 0))
36 return fVisitor->Visit(device);
37 return false;
38 }
39
40 // Visit
41 bool
Visit(BPartition * partition,int32 level)42 PartitionFilterVisitor::Visit(BPartition *partition, int32 level)
43 {
44 if (fFilter->Filter(partition, level))
45 return fVisitor->Visit(partition, level);
46 return false;
47 }
48
49
50 // #pragma mark -
51
52 // IDFinderVisitor
53
54 // constructor
IDFinderVisitor(int32 id)55 IDFinderVisitor::IDFinderVisitor(int32 id)
56 : BDiskDeviceVisitor(),
57 fID(id)
58 {
59 }
60
61 // Visit
62 bool
Visit(BDiskDevice * device)63 IDFinderVisitor::Visit(BDiskDevice *device)
64 {
65 return (device->ID() == fID);
66 }
67
68 // Visit
69 bool
Visit(BPartition * partition,int32 level)70 IDFinderVisitor::Visit(BPartition *partition, int32 level)
71 {
72 return (partition->ID() == fID);
73 }
74
75