Kea  1.9.9-git
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
void setSource(UserDataSourcePtr &source)
Sets the data source to the given value.
void refresh()
Updates the registry from its data source.
const UserDataSourcePtr & getSource()
Returns a reference to the data source.
Encapsulates a unique identifier for a DHCP client.
Definition: user.h:27
const UserPtr & findUser(const UserId &id) const
Finds a user in the registry by user id.
void addUser(UserPtr &user)
Adds a given user to the registry.
boost::shared_ptr< User > UserPtr
Defines a smart pointer to a User.
Definition: user.h:241
Holds DUID (DHCPv6 Unique Identifier)
Definition: duid.h:27
Defines the logger used by the user check hooks library.
Definition: user.cc:19
This file defines classes: UserId and User.
UserRegistry()
Constructor.
void clearall()
Removes all entries from the registry.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
std::map< UserId, UserPtr > UserMap
Defines a map of unique Users keyed by UserId.
Definition: user_registry.h:30
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
UserRegistryError(const char *file, size_t line, const char *what)
Definition: user_registry.h:24
~UserRegistry()
Destructor.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void removeUser(const UserId &id)
Removes a user from the registry by user id.
boost::shared_ptr< UserDataSource > UserDataSourcePtr
Defines a smart pointer to a UserDataSource.
Embodies an update-able, searchable list of unique users This class provides the means to create and ...
Definition: user_registry.h:38
Hardware type that represents information from DHCPv4 packet.
Definition: hwaddr.h:20
Defines the base class, UserDataSource.
boost::shared_ptr< UserRegistry > UserRegistryPtr
Define a smart pointer to a UserRegistry.
Thrown UserRegistry encounters an error.
Definition: user_registry.h:22