Instance: add method FindPartition()
This commit is contained in:
parent
a99bab935a
commit
e48ea5f23a
@ -39,6 +39,16 @@ Instance::Instance()
|
||||
{
|
||||
}
|
||||
|
||||
Partition *
|
||||
Instance::FindPartition(const char *name)
|
||||
{
|
||||
for (auto &partition : partitions)
|
||||
if (partition.name == name)
|
||||
return &partition;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
|
||||
const Database &
|
||||
|
@ -106,6 +106,13 @@ struct Instance final
|
||||
idle_monitor.OrMask(mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a #Partition with the given name. Returns nullptr if
|
||||
* no such partition was found.
|
||||
*/
|
||||
gcc_pure
|
||||
Partition *FindPartition(const char *name);
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
/**
|
||||
* Returns the global #Database instance. May return nullptr
|
||||
|
@ -58,13 +58,9 @@ IsValidPartitionName(const char *name)
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
HasPartitionNamed(const Instance &instance, const char *name)
|
||||
HasPartitionNamed(Instance &instance, const char *name)
|
||||
{
|
||||
for (const auto &partition : instance.partitions)
|
||||
if (partition.name == name)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return instance.FindPartition(name) != nullptr;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
Loading…
Reference in New Issue
Block a user