41#include "ServerFunctionsList.h"
48static pthread_once_t ServerFunctionsList_instance_control = PTHREAD_ONCE_INIT;
55void ServerFunctionsList::initialize_instance() {
56 if (d_instance == 0) {
57 DBG(cerr <<
"ServerFunctionsList::initialize_instance() - Creating singleton ServerFunctionList instance." << endl);
60 atexit(delete_instance);
68void ServerFunctionsList::delete_instance() {
69 DBG(cerr <<
"ServerFunctionsList::delete_instance() - Deleting singleton ServerFunctionList instance." << endl);
78ServerFunctionsList::~ServerFunctionsList() {
80 for(fit=d_func_list.begin(); fit!=d_func_list.end() ; fit++){
82 DBG(cerr <<
"ServerFunctionsList::~ServerFunctionsList() - Deleting ServerFunction " << func->getName() <<
" from ServerFunctionsList." << endl);
89 pthread_once(&ServerFunctionsList_instance_control, initialize_instance);
90 DBG(cerr <<
"ServerFunctionsList::TheList() - Returning singleton ServerFunctionList instance." << endl);
105 DBG(cerr <<
"ServerFunctionsList::add_function() - Adding ServerFunction " << func->getName() << endl);
106 d_func_list.insert(std::make_pair(func->getName(),func));
131 if (d_func_list.empty())
134 std::pair <SFLCIter, SFLCIter> ret;
135 ret = d_func_list.equal_range(name);
136 for (SFLCIter it = ret.first; it != ret.second; ++it) {
137 if (name == it->first && it->second->get_bool_func()) {
138 *f = it->second->get_bool_func();
168 if (d_func_list.empty())
170 DBG(cerr <<
"ServerFunctionsList::find_function() - Looking for ServerFunction '" << name <<
"'" << endl);
172 std::pair <SFLCIter, SFLCIter> ret;
173 ret = d_func_list.equal_range(name);
174 for (SFLCIter it = ret.first; it != ret.second; ++it) {
175 if (name == it->first && it->second->get_btp_func()) {
176 *f = it->second->get_btp_func();
206 if (d_func_list.empty())
209 std::pair <SFLCIter, SFLCIter> ret;
210 ret = d_func_list.equal_range(name);
211 for (SFLCIter it = ret.first; it != ret.second; ++it) {
212 if (name == it->first && it->second->get_proj_func()) {
213 *f = it->second->get_proj_func();
230 if (d_func_list.empty())
233 std::pair <SFLCIter, SFLCIter> ret;
234 ret = d_func_list.equal_range(name);
235 for (SFLCIter it = ret.first; it != ret.second; ++it) {
236 if (name == it->first && it->second->get_d4_function()) {
237 *f = it->second->get_d4_function();
248 return d_func_list.begin();
254 return d_func_list.end();
268void ServerFunctionsList::getFunctionNames(vector<string> *names){
270 for(fit = d_func_list.begin(); fit != d_func_list.end(); fit++) {
272 names->push_back(func->getName());
virtual bool find_function(const std::string &name, bool_func *f) const
Find a boolean function with a given name in the function list.
virtual void add_function(ServerFunction *func)
Adds the passed ServerFunction pointer to the list of ServerFunctions.
SFLIter begin()
Returns an iterator pointing to the first key pair in the ServerFunctionList.
SFLIter end()
Returns an iterator pointing to the last key pair in the ServerFunctionList.
ServerFunction * getFunction(SFLIter it)
Returns the ServerFunction pointed to by the passed iterator.
top level DAP object to house generic methods