1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "drizzled/plugin/scheduler.h"
22
#include "drizzled/plugin/registry.h"
24
#include "drizzled/gettext.h"
31
vector<plugin::Scheduler *> all_schedulers;
34
static plugin::Scheduler *scheduler= NULL;
37
class FindSchedulerByName : public unary_function<plugin::Scheduler *, bool>
41
FindSchedulerByName(const string *name_arg)
43
result_type operator() (argument_type sched)
45
return (bool)((name->compare(sched->getName()) == 0));
50
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched)
52
vector<plugin::Scheduler *>::iterator iter=
53
find_if(all_schedulers.begin(), all_schedulers.end(),
54
FindSchedulerByName(&sched->getName()));
56
if (iter != all_schedulers.end())
58
errmsg_printf(ERRMSG_LVL_ERROR,
59
_("Attempted to register a scheduler %s, but a scheduler "
60
"has already been registered with that name.\n"),
61
sched->getName().c_str());
66
all_schedulers.push_back(sched);
72
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched)
74
all_schedulers.erase(find(all_schedulers.begin(),
80
bool plugin::Scheduler::setPlugin(const string& name)
82
vector<plugin::Scheduler *>::iterator iter=
83
find_if(all_schedulers.begin(), all_schedulers.end(),
84
FindSchedulerByName(&name));
86
if (iter != all_schedulers.end())
88
if (scheduler != NULL)
89
scheduler->deactivate();
91
scheduler->activate();
95
errmsg_printf(ERRMSG_LVL_WARN,
96
_("Attempted to configure %s as the scheduler, which did "
97
"not exist.\n"), name.c_str());
102
plugin::Scheduler *plugin::Scheduler::getScheduler()
107
} /* namespace drizzled */