7#ifndef CALLOUT_HANDLE_H 
    8#define CALLOUT_HANDLE_H 
   15#include <boost/any.hpp> 
   16#include <boost/shared_ptr.hpp> 
   52class LibraryManagerCollection;
 
  129    CalloutHandle(
const boost::shared_ptr<CalloutManager>& manager,
 
  130                  const boost::shared_ptr<LibraryManagerCollection>& lmcoll =
 
  131                        boost::shared_ptr<LibraryManagerCollection>());
 
  146    template <
typename T>
 
  148        arguments_[name] = value;
 
 
  163    template <
typename T>
 
  165        ElementCollection::const_iterator element_ptr = arguments_.find(name);
 
  166        if (element_ptr == arguments_.end()) {
 
  171        value = boost::any_cast<T>(element_ptr->second);
 
 
  192        static_cast<void>(arguments_.erase(name));
 
 
  252    template <
typename T>
 
  254        getContextForLibrary()[name] = value;
 
 
  270    template <
typename T>
 
  274        ElementCollection::const_iterator element_ptr = lib_context.find(name);
 
  275        if (element_ptr == lib_context.end()) {
 
  277                      "item " << name << 
" in the context associated with " 
  281        value = boost::any_cast<T>(element_ptr->second);
 
 
  299    template <
typename T>
 
  301        const auto context_iter = context_collection_.find(current_library_);
 
  302        if (context_iter == context_collection_.end()) {
 
  307        auto lib_context = context_iter->second;
 
  308        ElementCollection::const_iterator element_ptr = lib_context.find(name);
 
  309        if (element_ptr == lib_context.end()) {
 
  313        value = boost::any_cast<T>(element_ptr->second);
 
 
  337        static_cast<void>(getContextForLibrary().erase(name));
 
 
  347        getContextForLibrary().clear();
 
 
  368        return (current_library_);
 
 
  375        current_library_ = library_index;
 
 
  382        return (current_hook_);
 
 
  389        current_hook_ = hook_index;
 
 
  403    int getLibraryIndex() 
const;
 
  435    boost::shared_ptr<LibraryManagerCollection> lm_collection_;
 
  444    boost::shared_ptr<CalloutManager> manager_;
 
  456    int current_library_;
 
 
CalloutHandle(const boost::shared_ptr< CalloutManager > &manager, const boost::shared_ptr< LibraryManagerCollection > &lmcoll=boost::shared_ptr< LibraryManagerCollection >())
Constructor.
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void setCurrentLibrary(int library_index)
Set current library index.
void deleteContext(const std::string &name)
Delete context element.
void getContext(const std::string &name, T &value) const
Get context.
CalloutNextStep
Specifies allowed next steps.
@ NEXT_STEP_PARK
park the packet
@ NEXT_STEP_CONTINUE
continue normally
@ NEXT_STEP_DROP
drop the packet
@ NEXT_STEP_SKIP
skip the next processing step
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
void setContext(const std::string &name, T value)
Set context.
CalloutNextStep getStatus() const
Returns the next processing step.
std::string getHookName() const
Get hook name.
void deleteAllArguments()
Delete all arguments.
std::map< std::string, boost::any > ElementCollection
Typedef to allow abbreviation of iterator specification in methods.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
~CalloutHandle()
Destructor.
void setCurrentHook(int hook_index)
Set current hook index.
void deleteArgument(const std::string &name)
Delete argument.
void getArgument(const std::string &name, T &value) const
Get argument.
void deleteAllContext()
Delete all context items.
int getCurrentHook() const
Get current hook index.
int getCurrentLibrary() const
Get current library index.
std::vector< std::string > getContextNames() const
Get context names.
void setArgument(const std::string &name, T value)
Set argument.
CalloutHandle(const boost::shared_ptr< CalloutManager > &manager, const boost::shared_ptr< LibraryManagerCollection > &lmcoll=boost::shared_ptr< LibraryManagerCollection >())
Constructor.
std::vector< std::string > getArgumentNames() const
Get argument names.
bool getOptionalContext(const std::string &name, T &value) const
Fetch an optional named element from the current library context.
std::map< int, ElementCollection > ContextCollection
Typedef to allow abbreviations in specifications when accessing context.
NoSuchArgument(const char *file, size_t line, const char *what)
No such callout context item.
NoSuchCalloutContext(const char *file, size_t line, const char *what)
ScopedCalloutHandleState(const CalloutHandlePtr &callout_handle)
Constructor.
std::function< void()> on_completion_
Continuation callback.
~ScopedCalloutHandleState()
Destructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
Defines the logger used by the top-level component of kea-lfc.