* Made _CountDescendants() public.
* Added private _ChildAt() and _CountChildren(), which don't ask the delegate, thus reflecting the hierarchy as it was before changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22610 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,6 +24,10 @@ class BVolume;
|
|||||||
struct user_partition_data;
|
struct user_partition_data;
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
class DiskDeviceJobGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
class BPartition {
|
class BPartition {
|
||||||
public:
|
public:
|
||||||
// Partition Info
|
// Partition Info
|
||||||
@@ -71,6 +75,7 @@ public:
|
|||||||
BPartition* Parent() const;
|
BPartition* Parent() const;
|
||||||
BPartition* ChildAt(int32 index) const;
|
BPartition* ChildAt(int32 index) const;
|
||||||
int32 CountChildren() const;
|
int32 CountChildren() const;
|
||||||
|
int32 CountDescendants() const;
|
||||||
BPartition* FindDescendant(partition_id id) const;
|
BPartition* FindDescendant(partition_id id) const;
|
||||||
|
|
||||||
status_t GetPartitioningInfo(
|
status_t GetPartitioningInfo(
|
||||||
@@ -187,7 +192,9 @@ private:
|
|||||||
bool* updated);
|
bool* updated);
|
||||||
void _RemoveChild(int32 index);
|
void _RemoveChild(int32 index);
|
||||||
|
|
||||||
int32 _CountDescendants() const;
|
BPartition* _ChildAt(int32 index) const;
|
||||||
|
int32 _CountChildren() const;
|
||||||
|
|
||||||
int32 _Level() const;
|
int32 _Level() const;
|
||||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
|
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
|
||||||
int32 level);
|
int32 level);
|
||||||
@@ -212,6 +219,7 @@ private:
|
|||||||
friend class BDiskDevice;
|
friend class BDiskDevice;
|
||||||
friend class BDiskSystem;
|
friend class BDiskSystem;
|
||||||
friend class BMutablePartition;
|
friend class BMutablePartition;
|
||||||
|
friend class BPrivate::DiskDeviceJobGenerator;
|
||||||
|
|
||||||
BDiskDevice* fDevice;
|
BDiskDevice* fDevice;
|
||||||
BPartition* fParent;
|
BPartition* fParent;
|
||||||
|
|||||||
@@ -602,9 +602,7 @@ BPartition::ChildAt(int32 index) const
|
|||||||
return child ? child->Partition() : NULL;
|
return child ? child->Partition() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 0 || index >= fPartitionData->child_count)
|
return _ChildAt(index);
|
||||||
return NULL;
|
|
||||||
return (BPartition*)fPartitionData->children[index]->user_data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -615,7 +613,18 @@ BPartition::CountChildren() const
|
|||||||
if (fDelegate)
|
if (fDelegate)
|
||||||
return fDelegate->CountChildren();
|
return fDelegate->CountChildren();
|
||||||
|
|
||||||
return fPartitionData->child_count;
|
return _CountChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CountDescendants
|
||||||
|
int32
|
||||||
|
BPartition::CountDescendants() const
|
||||||
|
{
|
||||||
|
int32 count = 1;
|
||||||
|
for (int32 i = 0; BPartition* child = ChildAt(i); i++)
|
||||||
|
count += child->CountDescendants();
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -624,7 +633,7 @@ BPartition*
|
|||||||
BPartition::FindDescendant(partition_id id) const
|
BPartition::FindDescendant(partition_id id) const
|
||||||
{
|
{
|
||||||
IDFinderVisitor visitor(id);
|
IDFinderVisitor visitor(id);
|
||||||
return const_cast<BPartition*>(this)->VisitEachDescendant(&visitor);
|
return VisitEachDescendant(&visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1283,6 +1292,7 @@ BPartition::_Unset()
|
|||||||
fDevice = NULL;
|
fDevice = NULL;
|
||||||
fParent = NULL;
|
fParent = NULL;
|
||||||
fPartitionData = NULL;
|
fPartitionData = NULL;
|
||||||
|
fDelegate = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1397,14 +1407,21 @@ BPartition::_RemoveChild(int32 index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _CountDescendants
|
// _ChildAt
|
||||||
int32
|
BPartition*
|
||||||
BPartition::_CountDescendants() const
|
BPartition::_ChildAt(int32 index) const
|
||||||
{
|
{
|
||||||
int32 count = 1;
|
if (index < 0 || index >= fPartitionData->child_count)
|
||||||
for (int32 i = 0; BPartition* child = ChildAt(i); i++)
|
return NULL;
|
||||||
count += child->_CountDescendants();
|
return (BPartition*)fPartitionData->children[index]->user_data;
|
||||||
return count;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// _CountChildren
|
||||||
|
int32
|
||||||
|
BPartition::_CountChildren() const
|
||||||
|
{
|
||||||
|
return fPartitionData->child_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1511,9 +1528,9 @@ BPartition::_CreateDelegates()
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
// create child delegates
|
// create child delegates
|
||||||
int32 count = fPartitionData->child_count;
|
int32 count = _CountChildren();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
BPartition* child = (BPartition*)fPartitionData->children[i]->user_data;
|
BPartition* child = _ChildAt(i);
|
||||||
error = child->_CreateDelegates();
|
error = child->_CreateDelegates();
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
Reference in New Issue
Block a user