Kea 2.7.1
user_chk::UserRegistry Class Reference

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 UserPtrfindUser (const isc::dhcp::DUID &duid) const
 Finds a user in the registry by DUID.
 
const UserPtrfindUser (const isc::dhcp::HWAddr &hwaddr) const
 Finds a user in the registry by hardware address.
 
const UserPtrfindUser (const UserId &id) const
 Finds a user in the registry by user id.
 
const UserDataSourcePtrgetSource ()
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ UserRegistry()

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.

◆ ~UserRegistry()

user_chk::UserRegistry::~UserRegistry ( )

Destructor.

Definition at line 17 of file user_registry.cc.

Member Function Documentation

◆ addUser()

void user_chk::UserRegistry::addUser ( UserPtr & user)

Adds a given user to the registry.

Parameters
userA pointer to the user to add
Exceptions
UserRegistryErrorif 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().

+ Here is the call graph for this function:

◆ clearall()

void user_chk::UserRegistry::clearall ( )

Removes all entries from the registry.

Definition at line 102 of file user_registry.cc.

Referenced by refresh().

◆ findUser() [1/3]

const UserPtr & user_chk::UserRegistry::findUser ( const isc::dhcp::DUID & duid) const

Finds a user in the registry by DUID.

Parameters
duidThe DUID for which to search
Returns
A pointer to the user if found or an null pointer if not.

Definition at line 63 of file user_registry.cc.

References user_chk::UserId::DUID, findUser(), and isc::dhcp::DUID::getDuid().

+ Here is the call graph for this function:

◆ findUser() [2/3]

const UserPtr & user_chk::UserRegistry::findUser ( const isc::dhcp::HWAddr & hwaddr) const

Finds a user in the registry by hardware address.

Parameters
hwaddrThe hardware address for which to search
Returns
A pointer to the user if found or an null pointer if not.

Definition at line 57 of file user_registry.cc.

References findUser(), user_chk::UserId::HW_ADDRESS, and isc::dhcp::HWAddr::hwaddr_.

+ Here is the call graph for this function:

◆ findUser() [3/3]

const UserPtr & user_chk::UserRegistry::findUser ( const UserId & id) const

Finds a user in the registry by user id.

Parameters
idThe user id for which to search
Returns
A pointer to the user if found or an null pointer if not.

Definition at line 36 of file user_registry.cc.

Referenced by addUser(), findUser(), and findUser().

◆ getSource()

const UserDataSourcePtr & user_chk::UserRegistry::getSource ( )

Returns a reference to the data source.

Definition at line 115 of file user_registry.cc.

◆ refresh()

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.

Exceptions
UserRegistryErrorif 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(), isc_throw, and isc::Exception::what().

+ Here is the call graph for this function:

◆ removeUser()

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.

Parameters
idThe user id of the user to remove

Definition at line 48 of file user_registry.cc.

◆ setSource()

void user_chk::UserRegistry::setSource ( UserDataSourcePtr & source)

Sets the data source to the given value.

Parameters
sourcereference to the data source to use.
Exceptions
UserRegistryErrorif new source value is null.

Definition at line 106 of file user_registry.cc.

References isc_throw.


The documentation for this class was generated from the following files: