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."
61 atexit(delete_instance);
69void ServerFunctionsList::delete_instance() {
70 DBG(cerr <<
"ServerFunctionsList::delete_instance() - Deleting singleton ServerFunctionList instance." << endl);
79ServerFunctionsList::~ServerFunctionsList() {
81 for (fit = d_func_list.begin(); fit != d_func_list.end(); fit++) {
82 ServerFunction *func = fit->second;
83 DBG(cerr <<
"ServerFunctionsList::~ServerFunctionsList() - Deleting ServerFunction " << func->
getName()
84 <<
" from ServerFunctionsList." << endl);
91 pthread_once(&ServerFunctionsList_instance_control, initialize_instance);
92 DBG(cerr <<
"ServerFunctionsList::TheList() - Returning singleton ServerFunctionList instance." << endl);
106 DBG(cerr <<
"ServerFunctionsList::add_function() - Adding ServerFunction " << func->
getName() << endl);
107 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();
167 if (d_func_list.empty())
169 DBG(cerr <<
"ServerFunctionsList::find_function() - Looking for ServerFunction '" << name <<
"'" << endl);
171 std::pair<SFLCIter, SFLCIter> ret;
172 ret = d_func_list.equal_range(name);
173 for (
SFLCIter it = ret.first; it != ret.second; ++it) {
174 if (name == it->first && it->second->get_btp_func()) {
175 *f = it->second->get_btp_func();
204 if (d_func_list.empty())
207 std::pair<SFLCIter, SFLCIter> ret;
208 ret = d_func_list.equal_range(name);
209 for (
SFLCIter it = ret.first; it != ret.second; ++it) {
210 if (name == it->first && it->second->get_proj_func()) {
211 *f = it->second->get_proj_func();
227 if (d_func_list.empty())
230 std::pair<SFLCIter, SFLCIter> ret;
231 ret = d_func_list.equal_range(name);
232 for (
SFLCIter it = ret.first; it != ret.second; ++it) {
233 if (name == it->first && it->second->get_d4_function()) {
234 *f = it->second->get_d4_function();
258 for (fit = d_func_list.begin(); fit != d_func_list.end(); fit++) {
260 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 getFunctionNames(std::vector< std::string > *names)
std::multimap< std::string, ServerFunction * >::iterator SFLIter
virtual void add_function(ServerFunction *func)
Adds the passed ServerFunction pointer to the list of ServerFunctions.
static ServerFunctionsList * TheList()
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.
std::multimap< std::string, ServerFunction * >::const_iterator SFLCIter
top level DAP object to house generic methods
BaseType *(* D4Function)(D4RValueList *, DMR &)