7 #ifndef RESOURCE_HANDLER_H
8 #define RESOURCE_HANDLER_H
13 #include <boost/noncopyable.hpp>
14 #include <boost/multi_index_container.hpp>
15 #include <boost/multi_index/composite_key.hpp>
16 #include <boost/multi_index/hashed_index.hpp>
17 #include <boost/multi_index/member.hpp>
18 #include <boost/multi_index/mem_fun.hpp>
19 #include <boost/shared_ptr.hpp>
77 : type_(type), addr_(addr) {
87 std::vector<uint8_t> toBytes()
const {
93 typedef boost::shared_ptr<Resource> ResourcePtr;
96 typedef boost::multi_index_container<
102 boost::multi_index::indexed_by<
105 boost::multi_index::hashed_unique<
106 boost::multi_index::composite_key<
109 boost::multi_index::member<
113 boost::multi_index::const_mem_fun<
114 Resource, std::vector<uint8_t>, &Resource::toBytes
127 static ResourceContainer resources_;
130 static std::mutex mutex_;
166 ResourceContainer owned_;
214 #endif // RESOURCE_HANDLER_H
virtual ~ResourceHandler()
Destructor.
ResourceHandler()
Constructor.
Resource race avoidance RAII handler for DHCPv4.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
Resource race avoidance RAII handler.
bool tryLock(Lease::Type type, const asiolink::IOAddress &addr)
Tries to acquires a resource.
void unLock(Lease::Type type, const asiolink::IOAddress &addr)
Releases a resource.
virtual ~ResourceHandler4()
Destructor.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Type
Type of lease or pool.
bool isLocked4(const asiolink::IOAddress &addr)
Checks if a resource is owned by this handler.
void unLock4(const asiolink::IOAddress &addr)
Releases a resource.
The IOAddress class represents an IP addresses (version agnostic)
bool isLocked(Lease::Type type, const asiolink::IOAddress &addr)
Checks if a resource is owned by this handler.
bool tryLock4(const asiolink::IOAddress &addr)
Tries to acquires a resource.