Kea 2.7.6
|
Embodies an update-able, searchable list of unique users This class provides the means to create and maintain a searchable list of unique users. More...
#include <user_registry.h>
Public Member Functions | |
UserRegistry () | |
Constructor. | |
~UserRegistry () | |
Destructor. | |
void | addUser (UserPtr &user) |
Adds a given user to the registry. | |
void | clearall () |
Removes all entries from the registry. | |
const UserPtr & | findUser (const isc::dhcp::DUID &duid) const |
Finds a user in the registry by DUID. | |
const UserPtr & | findUser (const isc::dhcp::HWAddr &hwaddr) const |
Finds a user in the registry by hardware address. | |
const UserPtr & | findUser (const UserId &id) const |
Finds a user in the registry by user id. | |
const UserDataSourcePtr & | getSource () |
Returns a reference to the data source. | |
void | refresh () |
Updates the registry from its data source. | |
void | removeUser (const UserId &id) |
Removes a user from the registry by user id. | |
void | setSource (UserDataSourcePtr &source) |
Sets the data source to the given value. | |
Embodies an update-able, searchable list of unique users This class provides the means to create and maintain a searchable list of unique users.
List entries are pointers to instances of User, keyed by their UserIds. Users may be added and removed from the list individually or the list may be updated by loading it from a data source, such as a file.
Definition at line 38 of file user_registry.h.
user_chk::UserRegistry::UserRegistry | ( | ) |
Constructor.
Creates a new registry with an empty list of users and no data source.
Definition at line 14 of file user_registry.cc.
user_chk::UserRegistry::~UserRegistry | ( | ) |
Destructor.
Definition at line 17 of file user_registry.cc.
void user_chk::UserRegistry::addUser | ( | UserPtr & | user | ) |
Adds a given user to the registry.
user | A pointer to the user to add |
UserRegistryError | if the user is null or if the user already exists in the registry. |
Definition at line 21 of file user_registry.cc.
References findUser(), and isc_throw.
Referenced by refresh().
void user_chk::UserRegistry::clearall | ( | ) |
Removes all entries from the registry.
Definition at line 102 of file user_registry.cc.
Referenced by refresh().
const UserPtr & user_chk::UserRegistry::findUser | ( | const isc::dhcp::DUID & | duid | ) | const |
Finds a user in the registry by DUID.
duid | The DUID for which to search |
Definition at line 63 of file user_registry.cc.
References user_chk::UserId::DUID, findUser(), and isc::dhcp::DUID::getDuid().
const UserPtr & user_chk::UserRegistry::findUser | ( | const isc::dhcp::HWAddr & | hwaddr | ) | const |
Finds a user in the registry by hardware address.
hwaddr | The hardware address for which to search |
Definition at line 57 of file user_registry.cc.
References findUser(), user_chk::UserId::HW_ADDRESS, and isc::dhcp::HWAddr::hwaddr_.
Finds a user in the registry by user id.
id | The user id for which to search |
Definition at line 36 of file user_registry.cc.
Referenced by addUser(), findUser(), and findUser().
const UserDataSourcePtr & user_chk::UserRegistry::getSource | ( | ) |
Returns a reference to the data source.
Definition at line 115 of file user_registry.cc.
void user_chk::UserRegistry::refresh | ( | ) |
Updates the registry from its data source.
This method will replace the contents of the registry with new content read from its data source. It will attempt to open the source and then add users from the source to the registry until the source is exhausted. If an error occurs accessing the source the registry contents will be restored to that of before the call to refresh.
UserRegistryError | if the data source has not been set (is null) or if an error occurs accessing the data source. |
Definition at line 68 of file user_registry.cc.
References addUser(), clearall(), and isc_throw.
void user_chk::UserRegistry::removeUser | ( | const UserId & | id | ) |
Removes a user from the registry by user id.
Removes the user entry if found, if not simply return.
id | The user id of the user to remove |
Definition at line 48 of file user_registry.cc.
void user_chk::UserRegistry::setSource | ( | UserDataSourcePtr & | source | ) |
Sets the data source to the given value.
source | reference to the data source to use. |
UserRegistryError | if new source value is null. |
Definition at line 106 of file user_registry.cc.
References isc_throw.