Kea 2.5.8
user_registry.h
Go to the documentation of this file.
1// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6#ifndef _USER_REGISTRY_H
7#define _USER_REGISTRY_H
8
10
11#include <dhcp/hwaddr.h>
12#include <dhcp/duid.h>
14#include <user.h>
15#include <user_data_source.h>
16
17#include <string>
18
19namespace user_chk {
20
23public:
24 UserRegistryError(const char* file, size_t line, const char* what) :
25 isc::Exception(file, line, what)
26 {}
27};
28
30typedef std::map<UserId,UserPtr> UserMap;
31
39public:
44
47
54 void addUser(UserPtr& user);
55
61 const UserPtr& findUser(const UserId& id) const;
62
68 void removeUser(const UserId& id);
69
75 const UserPtr& findUser(const isc::dhcp::HWAddr& hwaddr) const;
76
82 const UserPtr& findUser(const isc::dhcp::DUID& duid) const;
83
94 void refresh();
95
97 void clearall();
98
101
107 void setSource(UserDataSourcePtr& source);
108
109private:
111 UserMap users_;
112
114 UserDataSourcePtr source_;
115};
116
118typedef boost::shared_ptr<UserRegistry> UserRegistryPtr;
119
120} // namespace user_chk
121
122#endif
This is a base class for exceptions thrown from the DNS library module.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:142
Encapsulates a unique identifier for a DHCP client.
Definition: user.h:27
Thrown UserRegistry encounters an error.
Definition: user_registry.h:22
UserRegistryError(const char *file, size_t line, const char *what)
Definition: user_registry.h:24
Embodies an update-able, searchable list of unique users This class provides the means to create and ...
Definition: user_registry.h:38
~UserRegistry()
Destructor.
const UserPtr & findUser(const UserId &id) const
Finds a user in the registry by user id.
void clearall()
Removes all entries from the registry.
void setSource(UserDataSourcePtr &source)
Sets the data source to the given value.
UserRegistry()
Constructor.
void refresh()
Updates the registry from its data source.
void removeUser(const UserId &id)
Removes a user from the registry by user id.
void addUser(UserPtr &user)
Adds a given user to the registry.
const UserDataSourcePtr & getSource()
Returns a reference to the data source.
Defines the logger used by the top-level component of kea-lfc.
Defines the logger used by the user check hooks library.
Definition: user.cc:19
boost::shared_ptr< UserRegistry > UserRegistryPtr
Define a smart pointer to a UserRegistry.
boost::shared_ptr< User > UserPtr
Defines a smart pointer to a User.
Definition: user.h:241
boost::shared_ptr< UserDataSource > UserDataSourcePtr
Defines a smart pointer to a UserDataSource.
std::map< UserId, UserPtr > UserMap
Defines a map of unique Users keyed by UserId.
Definition: user_registry.h:30
Hardware type that represents information from DHCPv4 packet.
Definition: hwaddr.h:20
This file defines classes: UserId and User.
Defines the base class, UserDataSource.