xref: /haiku/src/kits/storage/disk_device/DiskDevicePrivate.cpp (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
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 
15 PartitionFilter::~PartitionFilter()
16 {
17 }
18 
19 
20 //	#pragma mark - PartitionFilterVisitor
21 
22 // constructor
23 PartitionFilterVisitor::PartitionFilterVisitor(BDiskDeviceVisitor *visitor,
24 											   PartitionFilter *filter)
25 	: BDiskDeviceVisitor(),
26 	  fVisitor(visitor),
27 	  fFilter(filter)
28 {
29 }
30 
31 // Visit
32 bool
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
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
55 IDFinderVisitor::IDFinderVisitor(int32 id)
56 	: BDiskDeviceVisitor(),
57 	  fID(id)
58 {
59 }
60 
61 // Visit
62 bool
63 IDFinderVisitor::Visit(BDiskDevice *device)
64 {
65 	return (device->ID() == fID);
66 }
67 
68 // Visit
69 bool
70 IDFinderVisitor::Visit(BPartition *partition, int32 level)
71 {
72 	return (partition->ID() == fID);
73 }
74 
75