7 #ifndef CALLOUT_HANDLE_H
8 #define CALLOUT_HANDLE_H
14 #include <boost/any.hpp>
15 #include <boost/shared_ptr.hpp>
51 class LibraryManagerCollection;
128 CalloutHandle(
const boost::shared_ptr<CalloutManager>& manager,
129 const boost::shared_ptr<LibraryManagerCollection>& lmcoll =
130 boost::shared_ptr<LibraryManagerCollection>());
145 template <
typename T>
147 arguments_[name] = value;
162 template <
typename T>
164 ElementCollection::const_iterator element_ptr = arguments_.find(name);
165 if (element_ptr == arguments_.end()) {
170 value = boost::any_cast<T>(element_ptr->second);
191 static_cast<void>(arguments_.erase(name));
251 template <
typename T>
253 getContextForLibrary()[name] = value;
269 template <
typename T>
271 const ElementCollection& lib_context = getContextForLibrary();
273 ElementCollection::const_iterator element_ptr = lib_context.find(name);
274 if (element_ptr == lib_context.end()) {
276 "item " << name <<
" in the context associated with "
280 value = boost::any_cast<T>(element_ptr->second);
303 static_cast<void>(getContextForLibrary().erase(name));
313 getContextForLibrary().clear();
334 return (current_library_);
341 current_library_ = library_index;
348 return (current_hook_);
355 current_hook_ = hook_index;
369 int getLibraryIndex()
const;
382 ElementCollection& getContextForLibrary();
395 const ElementCollection& getContextForLibrary()
const;
401 boost::shared_ptr<LibraryManagerCollection> lm_collection_;
404 ElementCollection arguments_;
407 ContextCollection context_collection_;
410 boost::shared_ptr<CalloutManager> manager_;
422 int current_library_;
501 CalloutHandlePtr callout_handle_;
508 #endif // CALLOUT_HANDLE_H
void setStatus(const CalloutNextStep next)
Sets the next processing step.
std::string getHookName() const
Get hook name.
int getCurrentHook() const
Get current hook index.
int getCurrentLibrary() const
Get current library index.
~ScopedCalloutHandleState()
Destructor.
ParkingLotHandlePtr getParkingLotHandlePtr() const
Returns pointer to the parking lot handle for this hook point.
ScopedCalloutHandleState(const CalloutHandlePtr &callout_handle)
Constructor.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Per-packet callout handle.
NoSuchCalloutContext(const char *file, size_t line, const char *what)
~CalloutHandle()
Destructor.
Wrapper class around callout handle which automatically resets handle's state.
CalloutNextStep
Specifies allowed next steps.
void setArgument(const std::string &name, T value)
Set argument.
std::map< std::string, boost::any > ElementCollection
Typedef to allow abbreviation of iterator specification in methods.
void deleteContext(const std::string &name)
Delete context element.
void setCurrentHook(int hook_index)
Set current hook index.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void deleteAllContext()
Delete all context items.
std::map< int, ElementCollection > ContextCollection
Typedef to allow abbreviations in specifications when accessing context.
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.
CalloutHandle(const boost::shared_ptr< CalloutManager > &manager, const boost::shared_ptr< LibraryManagerCollection > &lmcoll=boost::shared_ptr< LibraryManagerCollection >())
Constructor.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
void setContext(const std::string &name, T value)
Set context.
std::vector< std::string > getArgumentNames() const
Get argument names.
void deleteArgument(const std::string &name)
Delete argument.
void setCurrentLibrary(int library_index)
Set current library index.
No such callout context item.
void getArgument(const std::string &name, T &value) const
Get argument.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
NoSuchArgument(const char *file, size_t line, const char *what)
skip the next processing step
void deleteAllArguments()
Delete all arguments.
void getContext(const std::string &name, T &value) const
Get context.
CalloutNextStep getStatus() const
Returns the next processing step.
std::vector< std::string > getContextNames() const
Get context names.