40#include "BESResponseHandlerList.h"
47static std::once_flag d_euc_init_once;
49BESResponseHandlerList::BESResponseHandlerList() {}
51BESResponseHandlerList::~BESResponseHandlerList() {}
69 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
71 BESResponseHandlerList::Handler_citer i = _handler_list.find(handler_name);
72 if (i == _handler_list.end()) {
73 _handler_list[handler_name] = handler_method;
90 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
92 BESResponseHandlerList::Handler_iter i = _handler_list.find(handler_name);
93 if (i != _handler_list.end()) {
94 _handler_list.erase(i);
115 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
117 BESResponseHandlerList::Handler_citer i = _handler_list.find(handler_name);
118 if (i != _handler_list.end()) {
119 p_response_handler p = (*i).second;
121 return p(handler_name);
136 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
139 bool first_name =
true;
140 BESResponseHandlerList::Handler_citer i = _handler_list.begin();
141 for (; i != _handler_list.end(); i++) {
142 if (!first_name) ret +=
", ";
158 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
160 strm << BESIndent::LMarg <<
"BESResponseHandlerList::dump - (" << (
void *)
this <<
")" << endl;
162 if (_handler_list.size()) {
163 strm << BESIndent::LMarg <<
"registered response handlers:" << endl;
165 BESResponseHandlerList::Handler_citer i = _handler_list.begin();
166 BESResponseHandlerList::Handler_citer ie = _handler_list.end();
167 for (; i != ie; i++) {
168 strm << BESIndent::LMarg << (*i).first << endl;
170 BESIndent::UnIndent();
173 strm << BESIndent::LMarg <<
"registered response handlers: none" << endl;
175 BESIndent::UnIndent();
179BESResponseHandlerList::TheList()
181 std::call_once(d_euc_init_once,BESResponseHandlerList::initialize_instance);
185void BESResponseHandlerList::initialize_instance() {
188 atexit(delete_instance);
192void BESResponseHandlerList::delete_instance() {
List of all registered response handlers for this server.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual std::string get_handler_names()
returns the comma separated list of all response handlers currently registered with this server.
virtual BESResponseHandler * find_handler(const std::string &handler)
returns the response handler with the given name from the list
virtual bool remove_handler(const std::string &handler)
removes a response handler from the list
virtual bool add_handler(const std::string &handler, p_response_handler handler_method)
add a response handler to the list
handler object that knows how to create a specific response object