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 && (*f = it->second->get_bool_func())){
138 DBG(cerr <<
"ServerFunctionsList::find_function() - Found boolean function " << it->second->getName() << endl);
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 && (*f = it->second->get_btp_func())){
176 DBG(cerr <<
"ServerFunctionsList::find_function() - Found basetype function " << it->second->getName() << endl);
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 && (*f = it->second->get_proj_func())){
213 DBG(cerr <<
"ServerFunctionsList::find_function() - Found projection function " << it->second->getName() << endl);
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 && (*f = it->second->get_d4_function())) {
245 ServerFunctionsList::SFLIter ServerFunctionsList::begin()
247 return d_func_list.begin();
251 ServerFunctionsList::SFLIter ServerFunctionsList::end()
253 return d_func_list.end();
267 void ServerFunctionsList::getFunctionNames(vector<string> *names){
269 for(fit = d_func_list.begin(); fit != d_func_list.end(); fit++) {
271 names->push_back(func->getName());
top level DAP object to house generic methods