51 static pthread_once_t ServerFunctionsList_instance_control = PTHREAD_ONCE_INIT;
58 void ServerFunctionsList::initialize_instance() {
59 if (d_instance == 0) {
60 DBG(cerr <<
"ServerFunctionsList::initialize_instance() - Creating singleton ServerFunctionList instance." << endl);
63 atexit(delete_instance);
71 void ServerFunctionsList::delete_instance() {
72 DBG(cerr <<
"ServerFunctionsList::delete_instance() - Deleting singleton ServerFunctionList instance." << endl);
81 ServerFunctionsList::~ServerFunctionsList() {
82 std::multimap<string,libdap::ServerFunction *>::iterator fit;
83 for(fit=d_func_list.begin(); fit!=d_func_list.end() ; fit++){
85 DBG(cerr <<
"ServerFunctionsList::~ServerFunctionsList() - Deleting ServerFunction " << func->
getName() <<
" from ServerFunctionsList." << endl);
92 pthread_once(&ServerFunctionsList_instance_control, initialize_instance);
93 DBG(cerr <<
"ServerFunctionsList::TheList() - Returning singleton ServerFunctionList instance." << endl);
108 DBG(cerr <<
"ServerFunctionsList::add_function() - Adding ServerFunction " << func->
getName() << endl);
109 d_func_list.insert(std::make_pair(func->
getName(),func));
115 ServerFunctionsList::add_function(
string name, btp_func func )
117 if (d_btp_func_list[name] == 0) {
118 d_btp_func_list[name] = func;
127 ServerFunctionsList::add_function(
string name, bool_func func )
129 if (d_bool_func_list[name] == 0) {
130 d_bool_func_list[name] = func;
138 ServerFunctionsList::add_function(
string name, proj_func func )
140 if (d_proj_func_list[name] == 0) {
141 d_proj_func_list[name] = func;
152 if (d_btp_func_list.size() > 0) {
153 map<string, btp_func>::iterator i = d_btp_func_list.begin();
154 map<string, btp_func>::iterator e = d_btp_func_list.end();
156 ce.add_function((*i).first, (*i).second);
161 if (d_bool_func_list.size() > 0) {
162 map<string, bool_func>::iterator i = d_bool_func_list.begin();
163 map<string, bool_func>::iterator e = d_bool_func_list.end();
165 ce.add_function((*i).first, (*i).second);
170 if (d_proj_func_list.size() > 0) {
171 map<string, proj_func>::iterator i = d_proj_func_list.begin();
172 map<string, proj_func>::iterator e = d_proj_func_list.end();
174 ce.add_function((*i).first, (*i).second);
201 bool ServerFunctionsList::find_function(
const std::string &name, bool_func *f)
const
204 if (d_bool_func_list.empty())
207 map<string, bool_func>::const_iterator i = d_bool_func_list.begin();
208 while(i != d_bool_func_list.end()) {
209 if (name == (*i).first && (*f = (*i).second)) {
218 if (d_func_list.empty())
221 std::pair <std::multimap<std::string,libdap::ServerFunction *>::const_iterator, std::multimap<std::string,libdap::ServerFunction *>::const_iterator> ret;
222 ret = d_func_list.equal_range(name);
223 for (std::multimap<std::string,libdap::ServerFunction *>::const_iterator it=ret.first; it!=ret.second; ++it) {
224 if (name == it->first && (*f = it->second->get_bool_func())){
225 DBG(cerr <<
"ServerFunctionsList::find_function() - Found boolean function " << it->second->getName() << endl);
255 bool ServerFunctionsList::find_function(
const string &name, btp_func *f)
const
259 if (d_btp_func_list.empty())
262 map<string, btp_func>::const_iterator i = d_btp_func_list.begin();
263 while(i != d_btp_func_list.end()) {
264 if (name == (*i).first && (*f = (*i).second)) {
273 if (d_func_list.empty())
275 DBG(cerr <<
"ServerFunctionsList::find_function() - Looking for ServerFunction '" << name <<
"'" << endl);
277 std::pair <std::multimap<string,libdap::ServerFunction *>::const_iterator, std::multimap<string,libdap::ServerFunction *>::const_iterator> ret;
278 ret = d_func_list.equal_range(name);
279 for (std::multimap<string,libdap::ServerFunction *>::const_iterator it=ret.first; it!=ret.second; ++it) {
280 if (name == it->first && (*f = it->second->get_btp_func())){
281 DBG(cerr <<
"ServerFunctionsList::find_function() - Found basetype function " << it->second->getName() << endl);
312 bool ServerFunctionsList::find_function(
const string &name, proj_func *f)
const
316 if (d_proj_func_list.empty())
319 map<string, proj_func>::const_iterator i = d_proj_func_list.begin();
320 while(i != d_proj_func_list.end()) {
321 if (name == (*i).first && (*f = (*i).second)) {
330 if (d_func_list.empty())
333 std::pair <std::multimap<string,libdap::ServerFunction *>::const_iterator, std::multimap<string,libdap::ServerFunction *>::const_iterator> ret;
334 ret = d_func_list.equal_range(name);
335 for (std::multimap<string,libdap::ServerFunction *>::const_iterator it=ret.first; it!=ret.second; ++it) {
336 if (name == it->first && (*f = it->second->get_proj_func())){
337 DBG(cerr <<
"ServerFunctionsList::find_function() - Found projection function " << it->second->getName() << endl);
348 std::multimap<string,libdap::ServerFunction *>::iterator ServerFunctionsList::begin()
350 return d_func_list.begin();
354 std::multimap<string,libdap::ServerFunction *>::iterator ServerFunctionsList::end()
356 return d_func_list.end();
384 void ServerFunctionsList::dump(ostream &strm)
const
386 strm << BESIndent::LMarg <<
"ServerFunctionsList::dump - (" << (
void *)
this <<
")" << endl;
389 if (d_btp_func_list.size() > 0) {
390 strm << BESIndent::LMarg <<
"registered btp functions:" << endl;
392 map<string, btp_func>::const_iterator i = d_btp_func_list.begin();
393 map<string, btp_func>::const_iterator e = d_btp_func_list.end();
395 strm << (*i).first << endl;
398 BESIndent::UnIndent();
401 strm << BESIndent::LMarg <<
"registered btp functions: none" << endl;
404 if (d_bool_func_list.size() > 0) {
405 strm << BESIndent::LMarg <<
"registered bool functions:" << endl;
407 map<string, bool_func>::const_iterator i = d_bool_func_list.begin();
408 map<string, bool_func>::const_iterator e = d_bool_func_list.end();
410 strm << (*i).first << endl;
413 BESIndent::UnIndent();
416 strm << BESIndent::LMarg <<
"registered bool functions: none" << endl;
419 if (d_proj_func_list.size() > 0) {
420 strm << BESIndent::LMarg <<
"registered projection functions:" << endl;
422 map<string, proj_func>::const_iterator i = d_proj_func_list.begin();
423 map<string, proj_func>::const_iterator e = d_proj_func_list.end();
425 strm << (*i).first << endl;
428 BESIndent::UnIndent();
431 strm << BESIndent::LMarg <<
"registered projection functions: none" << endl;
434 BESIndent::UnIndent();
438 ServerFunctionsList::TheList()
440 if (d_instance == 0) {
448 void ServerFunctionsList::getFunctionNames(vector<string> *names){
449 std::multimap<string,libdap::ServerFunction *>::iterator fit;
450 for(fit=d_func_list.begin(); fit!=d_func_list.end() ; fit++){
452 names->push_back(func->
getName());
Evaluate a constraint expression.