7#ifndef BINDING_VARIABLES_H
8#define BINDING_VARIABLES_H
19#include <boost/scoped_ptr.hpp>
20#include <boost/multi_index_container.hpp>
21#include <boost/multi_index/mem_fun.hpp>
22#include <boost/multi_index/hashed_index.hpp>
23#include <boost/multi_index/ordered_index.hpp>
24#include <boost/multi_index/sequenced_index.hpp>
64 const std::string& expression_str,
97 return (expression_str_);
104 return (expression_);
136 std::string expression_str_;
164typedef boost::multi_index_container<
166 boost::multi_index::indexed_by<
168 boost::multi_index::sequenced<
169 boost::multi_index::tag<VariableSequenceTag>
172 boost::multi_index::hashed_unique<
173 boost::multi_index::tag<VariableNameTag>,
179 boost::multi_index::ordered_non_unique<
180 boost::multi_index::tag<VariableSourceTag>,
245 const boost::scoped_ptr<std::mutex> mutex_;
This class represents configuration element which is associated with database identifier and the modi...
BindingVariableCache stores binding variables.
BindingVariableListPtr getBySource(const BindingVariable::Source &source)
Fetches all of the binding variables in the order they were added to the cache that use a specific so...
size_t size()
Returns number of entries in the cache.
void clear()
Delete all the entries in the cache.
BindingVariablePtr getByName(const std::string &name)
Fetches a binding variable by name.
BindingVariableListPtr getAll()
Fetches all of the binding variables in the order they were added to the cache.
boost::posix_time::ptime getLastFlushTime()
Returns the last time the cache was flushed (or the time it was created if it has never been flushed)...
BindingVariableCache()
Constructor.
bool add(BindingVariablePtr variable)
Adds (or replaces) the variable in the cache.
virtual ~BindingVariableCache()=default
Destructor.
Singleton which warehouses the configured binding variables, and evaluation of variables for a given ...
bool evaluateVariables(dhcp::PktPtr query, dhcp::PktPtr response, dhcp::LeasePtr lease)
Evaluates the binding variables for a given lease and packet pair.
BindingVariableCachePtr getCache()
Fetches the current variables cache.
BindingVariableMgr(uint32_t family)
Constructor.
~BindingVariableMgr()=default
Destructor;.
void configure(data::ConstElementPtr config)
Configures the manager based on the given configuration.
Embodies a named expression, whose output when evaluated can be stored in a lease's user-context.
static const data::SimpleKeywords CONFIG_KEYWORDS
List of valid configurable parameters for a BindingVariable.
Source
Specifies the packet that the expression should be evaluated against.
virtual ~BindingVariable()=default
Destructor.
std::string evaluate(dhcp::PktPtr packet) const
Evaluate the variable against the given packet.
virtual data::ElementPtr toElement() const
Creates an Element tree for the variable's configurable members.
uint32_t getFamily() const
Fetches the variable's protocol family.
std::string getExpressionStr() const
Fetches the variable's pre-parsed expression string.
dhcp::ExpressionPtr getExpression() const
Fetches the variable's parsed expression.
Source getSource() const
Fetches the variable's packet source.
std::string getName() const
Fetches the variable's name.
BindingVariable(const std::string &name, const std::string &expression_str, const Source &source, uint32_t family)
Constructor.
static BindingVariablePtr parse(data::ConstElementPtr config, uint16_t family)
Parses configuration elements into a BindingVarable instance.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::map< std::string, isc::data::Element::types > SimpleKeywords
This specifies all accepted keywords with their types.
boost::shared_ptr< isc::dhcp::Pkt > PktPtr
A pointer to either Pkt4 or Pkt6 packet.
boost::shared_ptr< Expression > ExpressionPtr
boost::shared_ptr< Lease > LeasePtr
Pointer to the lease object.
boost::shared_ptr< BindingVariableMgr > BindingVariableMgrPtr
Defines a shared pointer to a BindingVariableMgr.
boost::shared_ptr< BindingVariable > BindingVariablePtr
Defines a shared pointer to a BindingVariable.
std::list< BindingVariablePtr > BindingVariableList
Defines a list of BindingVariablePtr instances.
boost::multi_index_container< BindingVariablePtr, boost::multi_index::indexed_by< boost::multi_index::sequenced< boost::multi_index::tag< VariableSequenceTag > >, boost::multi_index::hashed_unique< boost::multi_index::tag< VariableNameTag >, boost::multi_index::const_mem_fun< BindingVariable, std::string, &BindingVariable::getName > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< VariableSourceTag >, boost::multi_index::const_mem_fun< BindingVariable, BindingVariable::Source, &BindingVariable::getSource > > > > BindingVariableContainer
the client class multi-index.
boost::shared_ptr< BindingVariableList > BindingVariableListPtr
Defines a pointer to a list of BindingVariablePtrs.
boost::shared_ptr< BindingVariableCache > BindingVariableCachePtr
Defines a shared pointer to a BindingVariableCache.
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.
Tag for the sequence index.
Tag for the source index.