}
boost::posix_time::ptime
-SubnetAllocationState::getLastAllocatedTime(const Lease::Type& lease_type) const {
+SubnetAllocationState::getLastAllocatedTime(Lease::Type type) const {
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
- return (getLastAllocatedTimeInternal(lease_type));
+ return (getLastAllocatedTimeInternal(type));
} else {
- return (getLastAllocatedTimeInternal(lease_type));
+ return (getLastAllocatedTimeInternal(type));
}
}
boost::posix_time::ptime
-SubnetAllocationState::getLastAllocatedTimeInternal(const Lease::Type& lease_type) const {
- auto t = last_allocated_time_.find(lease_type);
+SubnetAllocationState::getLastAllocatedTimeInternal(Lease::Type type) const {
+ auto t = last_allocated_time_.find(type);
if (t != last_allocated_time_.end()) {
return (t->second);
}
}
void
-SubnetAllocationState::setCurrentAllocatedTimeInternal(const Lease::Type& lease_type) {
- last_allocated_time_[lease_type] = boost::posix_time::microsec_clock::universal_time();
+SubnetAllocationState::setCurrentAllocatedTimeInternal(Lease::Type type) {
+ last_allocated_time_[type] = boost::posix_time::microsec_clock::universal_time();
}
}
/// @brief Returns last allocation time for the specified lease type.
///
- /// @param lease_type specifies a lease type for which the last
- /// allocation time should be returned.
+ /// @param type specifies a lease type for which the last allocation
+ /// time should be returned.
/// @return Last allocation time for the lease type or
/// @c boost::posix_time::neg_infin when no leases have been allocated
/// from this subnet yet.
boost::posix_time::ptime
- getLastAllocatedTime(const Lease::Type& lease_type) const;
+ getLastAllocatedTime(Lease::Type type) const;
protected:
/// This function should be called by derived classes. It should be
/// called in the thread-safe context.
///
- /// @param lease_type specifies a lease type for which the last allocation
+ /// @param type specifies a lease type for which the last allocation
/// time should be set to the current time.
- void setCurrentAllocatedTimeInternal(const Lease::Type& lease_type);
+ void setCurrentAllocatedTimeInternal(Lease::Type type);
/// @brief Returns the last allocation time of a specified lease type.
///
/// this subnet. The negative infinity time is returned if a lease type is
/// not recognized (which is unlikely).
boost::posix_time::ptime
- getLastAllocatedTimeInternal(const Lease::Type& lease_type) const;
+ getLastAllocatedTimeInternal(Lease::Type type) const;
/// @brief Mutex used for thread-safe access to the state members.
boost::scoped_ptr<std::mutex> mutex_;
}
IOAddress
-SubnetIterativeAllocationState::getLastAllocated(const Lease::Type& lease_type) const {
+SubnetIterativeAllocationState::getLastAllocated(Lease::Type type) const {
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
- return (getLastAllocatedInternal(lease_type));
+ return (getLastAllocatedInternal(type));
} else {
- return (getLastAllocatedInternal(lease_type));
+ return (getLastAllocatedInternal(type));
}
}
void
-SubnetIterativeAllocationState::setLastAllocated(const Lease::Type& lease_type, const IOAddress& address) {
+SubnetIterativeAllocationState::setLastAllocated(Lease::Type type, const IOAddress& address) {
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
- setLastAllocatedInternal(lease_type, address);
+ setLastAllocatedInternal(type, address);
} else {
- setLastAllocatedInternal(lease_type, address);
+ setLastAllocatedInternal(type, address);
}
}
IOAddress
-SubnetIterativeAllocationState::getLastAllocatedInternal(const Lease::Type& lease_type) const {
- switch (lease_type) {
+SubnetIterativeAllocationState::getLastAllocatedInternal(Lease::Type type) const {
+ switch (type) {
case Lease::TYPE_V4:
case Lease::TYPE_NA:
return last_allocated_ia_;
case Lease::TYPE_PD:
return last_allocated_pd_;
default:
- isc_throw(BadValue, "pool type " << lease_type << " not supported");
+ isc_throw(BadValue, "pool type " << type << " not supported");
}
}
void
-SubnetIterativeAllocationState::setLastAllocatedInternal(const Lease::Type& lease_type,
+SubnetIterativeAllocationState::setLastAllocatedInternal(Lease::Type type,
const IOAddress& address) {
- switch (lease_type) {
+ switch (type) {
case Lease::TYPE_V4:
case Lease::TYPE_NA:
last_allocated_ia_ = address;
last_allocated_pd_ = address;
break;
default:
- isc_throw(BadValue, "pool type " << lease_type << " not supported");
+ isc_throw(BadValue, "pool type " << type << " not supported");
}
// Update the timestamp of last allocation.
- setCurrentAllocatedTimeInternal(lease_type);
+ setCurrentAllocatedTimeInternal(type);
}
PoolIterativeAllocationStatePtr
/// @brief Returns last allocated address or prefix.
///
- /// @param lease_type type of the last allocated lease to be returned.
+ /// @param type type of the last allocated lease to be returned.
/// @return last allocated address or prefix of a given type.
- asiolink::IOAddress getLastAllocated(const Lease::Type& lease_type) const;
+ asiolink::IOAddress getLastAllocated(Lease::Type type) const;
/// @brief Sets last alocated address or prefix.
///
- /// @param lease_type type of the last allocated lease set.
+ /// @param type type of the last allocated lease set.
/// @param address an address or prefix last allocated.
- void setLastAllocated(const Lease::Type& lease_type, const asiolink::IOAddress& address);
+ void setLastAllocated(Lease::Type type, const asiolink::IOAddress& address);
private:
///
/// It must be called in the thread-safe context.
///
- /// @param lease_type type of the last allocated lease to be returned.
+ /// @param type type of the last allocated lease to be returned.
/// @return last allocated address or prefix of a given type.
- asiolink::IOAddress getLastAllocatedInternal(const Lease::Type& lease_type) const;
+ asiolink::IOAddress getLastAllocatedInternal(Lease::Type type) const;
/// @brief Sets last alocated address or prefix.
///
/// It must be called in the thread-safe context.
///
- /// @param lease_type type of the last allocated lease set.
+ /// @param type type of the last allocated lease set.
/// @param address an address or prefix last allocated.
- void setLastAllocatedInternal(const Lease::Type& lease_type, const asiolink::IOAddress& address);
+ void setLastAllocatedInternal(Lease::Type type, const asiolink::IOAddress& address);
/// @brief Last allocated address.
///
namespace isc {
namespace dhcp {
-IterativeAllocator::IterativeAllocator(const Lease::Type& lease_type,
+IterativeAllocator::IterativeAllocator(Lease::Type type,
const WeakSubnetPtr& subnet)
- : Allocator(lease_type, subnet) {
+ : Allocator(type, subnet) {
}
isc::asiolink::IOAddress
/// @brief Constructor.
///
- /// @param lease_type specifies the type of allocated leases.
+ /// @param type specifies the type of allocated leases.
/// @param subnet weak pointer to the subnet owning the allocator.
- IterativeAllocator(const Lease::Type& lease_type, const WeakSubnetPtr& subnet);
+ IterativeAllocator(Lease::Type type, const WeakSubnetPtr& subnet);
private:
/// @brief Convenience function returning subnet allocation state instance.
///
- /// @param subnet subnet instance.
+ /// It creates a new subnet state instance and assigns it to the subnet
+ /// if it hasn't been initialized.
+ ///
/// @return allocation state instance for the subnet.
SubnetIterativeAllocationStatePtr getSubnetState() const;
/// @brief Convenience function returning pool allocation state instance.
///
+ /// It creates a new pool state instance and assigns it to the pool
+ /// if it hasn't been initialized.
+ ///
/// @param pool pool instance.
/// @return allocation state instance for the pool.
PoolIterativeAllocationStatePtr getPoolState(const PoolPtr& pool) const;