Kea  1.5.0
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>
13 #include <exceptions/exceptions.h>
14 #include <user.h>
15 #include <user_data_source.h>
16 
17 #include <string>
18 
19 namespace user_chk {
20 
23 public:
24  UserRegistryError(const char* file, size_t line, const char* what) :
25  isc::Exception(file, line, what)
26  {}
27 };
28 
30 typedef std::map<UserId,UserPtr> UserMap;
31 
38 class UserRegistry {
39 public:
43  UserRegistry();
44 
46  ~UserRegistry();
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 
100  const UserDataSourcePtr& getSource();
101 
107  void setSource(UserDataSourcePtr& source);
108 
109 private:
111  UserMap users_;
112 
114  UserDataSourcePtr source_;
115 };
116 
118 typedef boost::shared_ptr<UserRegistry> UserRegistryPtr;
119 
120 } // namespace user_chk
121 
122 #endif
user_chk::UserRegistryError
Thrown UserRegistry encounters an error.
Definition: user_registry.h:22
user_chk::UserId
Encapsulates a unique identifier for a DHCP client.
Definition: user.h:27
user_chk::UserRegistry::~UserRegistry
~UserRegistry()
Destructor.
Definition: user_registry.cc:17
duid.h
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition: exceptions/exceptions.cc:17
isc::dhcp::HWAddr
Hardware type that represents information from DHCPv4 packet.
Definition: hwaddr.h:20
user_chk::UserRegistry::UserRegistry
UserRegistry()
Constructor.
Definition: user_registry.cc:14
user_chk::UserRegistry::getSource
const UserDataSourcePtr & getSource()
Returns a reference to the data source.
Definition: user_registry.cc:115
user_chk::UserDataSourcePtr
boost::shared_ptr< UserDataSource > UserDataSourcePtr
Defines a smart pointer to a UserDataSource.
Definition: user_data_source.h:67
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
user_chk::UserRegistry
Embodies an update-able, searchable list of unique users This class provides the means to create and ...
Definition: user_registry.h:38
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
user_data_source.h
user_chk::UserRegistryError::UserRegistryError
UserRegistryError(const char *file, size_t line, const char *what)
Definition: user_registry.h:24
user_chk::UserRegistry::removeUser
void removeUser(const UserId &id)
Removes a user from the registry by user id.
Definition: user_registry.cc:48
user_chk::UserRegistry::addUser
void addUser(UserPtr &user)
Adds a given user to the registry.
Definition: user_registry.cc:21
hwaddr.h
user_chk
Defines the logger used by the user check hooks library.
Definition: user.cc:19
user_chk::UserRegistry::findUser
const UserPtr & findUser(const UserId &id) const
Finds a user in the registry by user id.
Definition: user_registry.cc:36
user_chk::UserRegistryPtr
boost::shared_ptr< UserRegistry > UserRegistryPtr
Define a smart pointer to a UserRegistry.
Definition: user_registry.h:118
user_chk::UserRegistry::setSource
void setSource(UserDataSourcePtr &source)
Sets the data source to the given value.
Definition: user_registry.cc:106
user.h
These classes are used to describe and recognize DHCP lease clients.
exceptions.h
user_chk::UserRegistry::refresh
void refresh()
Updates the registry from its data source.
Definition: user_registry.cc:68
isc::dhcp::DUID
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:27
user_chk::UserRegistry::clearall
void clearall()
Removes all entries from the registry.
Definition: user_registry.cc:102
user_chk::UserMap
std::map< UserId, UserPtr > UserMap
Defines a map of unique Users keyed by UserId.
Definition: user_registry.h:30
user_chk::UserPtr
boost::shared_ptr< User > UserPtr
Defines a smart pointer to a User.
Definition: user.h:241