7 #ifndef CALLOUT_HANDLE_H 8 #define CALLOUT_HANDLE_H 15 #include <boost/any.hpp> 16 #include <boost/shared_ptr.hpp> 87 NEXT_STEP_CONTINUE = 0,
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);
180 std::vector<std::string> getArgumentNames()
const;
192 static_cast<void>(arguments_.erase(name));
252 template <
typename T>
254 getContextForLibrary()[name] = value;
270 template <
typename T>
272 const ElementCollection& lib_context = getContextForLibrary();
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);
291 std::vector<std::string> getContextNames()
const;
304 static_cast<void>(getContextForLibrary().erase(name));
314 getContextForLibrary().clear();
324 std::string getHookName()
const;
335 return (current_library_);
342 current_library_ = library_index;
349 return (current_hook_);
356 current_hook_ = hook_index;
370 int getLibraryIndex()
const;
383 ElementCollection& getContextForLibrary();
396 const ElementCollection& getContextForLibrary()
const;
402 boost::shared_ptr<LibraryManagerCollection> lm_collection_;
405 ElementCollection arguments_;
408 ContextCollection context_collection_;
411 boost::shared_ptr<CalloutManager> manager_;
423 int current_library_;
505 CalloutHandlePtr callout_handle_;
512 #endif // CALLOUT_HANDLE_H void setStatus(const CalloutNextStep next)
Sets the next processing step.
Library manager collection.
int getCurrentHook() const
Get current hook index.
CalloutNextStep getStatus() const
Returns the next processing step.
void getContext(const std::string &name, T &value) const
Get context.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::function< void()> on_completion_
Continuation callback.
Per-packet callout handle.
NoSuchCalloutContext(const char *file, size_t line, const char *what)
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.
void deleteAllContext()
Delete all context items.
std::map< int, ElementCollection > ContextCollection
Typedef to allow abbreviations in specifications when accessing context.
int getCurrentLibrary() const
Get current library index.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
void getArgument(const std::string &name, T &value) const
Get argument.
boost::shared_ptr< CalloutHandle > CalloutHandlePtr
A shared pointer to a CalloutHandle object.
void setContext(const std::string &name, T value)
Set context.
void deleteArgument(const std::string &name)
Delete argument.
void setCurrentLibrary(int library_index)
Set current library index.
No such callout context item.
boost::shared_ptr< ParkingLotHandle > ParkingLotHandlePtr
Pointer to the parking lot handle.
NoSuchArgument(const char *file, size_t line, const char *what)
void deleteAllArguments()
Delete all arguments.