41 #include "ServerFunctionsList.h"
48 static pthread_once_t ServerFunctionsList_instance_control = PTHREAD_ONCE_INIT;
55 void ServerFunctionsList::initialize_instance() {
56 if (d_instance == 0) {
57 DBG(cerr <<
"ServerFunctionsList::initialize_instance() - Creating singleton ServerFunctionList instance." << endl);
60 atexit(delete_instance);
68 void ServerFunctionsList::delete_instance() {
69 DBG(cerr <<
"ServerFunctionsList::delete_instance() - Deleting singleton ServerFunctionList instance." << endl);
78 ServerFunctionsList::~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));
129 bool ServerFunctionsList::find_function(
const std::string &name, bool_func *f)
const
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();
166 bool ServerFunctionsList::find_function(
const string &name, btp_func *f)
const
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();
204 bool ServerFunctionsList::find_function(
const string &name, proj_func *f)
const
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();
228 bool ServerFunctionsList::find_function(
const string &name, D4Function *f)
const
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();
246 ServerFunctionsList::SFLIter ServerFunctionsList::begin()
248 return d_func_list.begin();
252 ServerFunctionsList::SFLIter ServerFunctionsList::end()
254 return d_func_list.end();
268 void ServerFunctionsList::getFunctionNames(vector<string> *names){
270 for(fit = d_func_list.begin(); fit != d_func_list.end(); fit++) {
272 names->push_back(func->getName());
top level DAP object to house generic methods