Add Client* ClientManager::get_client_ifp() that can return nullptr
This commit is contained in:
parent
3dde0b2260
commit
05d0397936
|
@ -139,14 +139,22 @@ bool ClientManager::validate_client_name(const String& name) const
|
|||
return it == m_clients.end();
|
||||
}
|
||||
|
||||
Client& ClientManager::get_client(const String& name)
|
||||
Client* ClientManager::get_client_ifp(const String& name)
|
||||
{
|
||||
for (auto& client : m_clients)
|
||||
{
|
||||
if (client->context().name() == name)
|
||||
return *client;
|
||||
return client.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Client& ClientManager::get_client(const String& name)
|
||||
{
|
||||
Client* client = get_client_ifp(name);
|
||||
if (not client)
|
||||
throw runtime_error("no client named: " + name);
|
||||
return *client;
|
||||
}
|
||||
|
||||
void ClientManager::redraw_clients() const
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
|
||||
void redraw_clients() const;
|
||||
|
||||
Client* get_client_ifp(const String& name);
|
||||
Client& get_client(const String& name);
|
||||
bool validate_client_name(const String& name) const;
|
||||
void remove_client(Client& client);
|
||||
|
|
Loading…
Reference in New Issue
Block a user