520.3.2
by mark
add parser and scheduling plugin files |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
520.3.2
by mark
add parser and scheduling plugin files |
5 |
*
|
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.
|
|
9 |
*
|
|
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.
|
|
14 |
*
|
|
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
|
|
18 |
*/
|
|
19 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
20 |
#include "config.h" |
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
21 |
|
22 |
#include <algorithm> |
|
23 |
||
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
24 |
#include "drizzled/plugin/scheduler.h" |
25 |
||
26 |
#include "drizzled/gettext.h" |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
27 |
#include "drizzled/errmsg_print.h" |
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
28 |
|
1130.1.12
by Monty Taylor
Moved service stuff into plugin/ |
29 |
namespace drizzled |
30 |
{
|
|
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
31 |
|
1685.5.1
by David Shrewsbury
Fix for bug 532481: fixes OS X crash by support thread_stack option |
32 |
extern size_t my_thread_stack_size; |
33 |
||
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
34 |
std::vector<plugin::Scheduler *> all_schedulers; |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
35 |
|
36 |
/* Globals (TBK) */
|
|
37 |
static plugin::Scheduler *scheduler= NULL; |
|
38 |
||
39 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
40 |
class FindSchedulerByName : public std::unary_function<plugin::Scheduler *, bool> |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
41 |
{
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
42 |
const std::string *name; |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
43 |
public: |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
44 |
FindSchedulerByName(const std::string *name_arg) |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
45 |
: name(name_arg) {} |
46 |
result_type operator() (argument_type sched) |
|
47 |
{
|
|
1130.2.15
by Monty Taylor
Merged up with trunk. |
48 |
return (bool)((name->compare(sched->getName()) == 0)); |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
49 |
}
|
50 |
};
|
|
51 |
||
52 |
||
53 |
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched) |
|
54 |
{
|
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
55 |
std::vector<plugin::Scheduler *>::iterator iter= |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
56 |
std::find_if(all_schedulers.begin(), all_schedulers.end(), |
1130.2.15
by Monty Taylor
Merged up with trunk. |
57 |
FindSchedulerByName(&sched->getName())); |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
58 |
|
59 |
if (iter != all_schedulers.end()) |
|
994.2.2
by Monty Taylor
Store a Registry of SchedulerFactories and set one of them at startup for better error messages earlier. |
60 |
{
|
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
61 |
errmsg_printf(error::ERROR, |
994.2.2
by Monty Taylor
Store a Registry of SchedulerFactories and set one of them at startup for better error messages earlier. |
62 |
_("Attempted to register a scheduler %s, but a scheduler " |
63 |
"has already been registered with that name.\n"), |
|
1130.2.15
by Monty Taylor
Merged up with trunk. |
64 |
sched->getName().c_str()); |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
65 |
return true; |
66 |
}
|
|
67 |
||
1192.2.2
by Monty Taylor
Added type name strings to all of the plugin types. |
68 |
sched->deactivate(); |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
69 |
all_schedulers.push_back(sched); |
70 |
||
71 |
return false; |
|
72 |
}
|
|
73 |
||
74 |
||
75 |
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched) |
|
76 |
{
|
|
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
77 |
all_schedulers.erase(std::find(all_schedulers.begin(), |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
78 |
all_schedulers.end(), |
79 |
sched)); |
|
80 |
}
|
|
81 |
||
82 |
||
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
83 |
bool plugin::Scheduler::setPlugin(const std::string& name) |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
84 |
{
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
85 |
std::vector<plugin::Scheduler *>::iterator iter= |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
86 |
std::find_if(all_schedulers.begin(), all_schedulers.end(), |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
87 |
FindSchedulerByName(&name)); |
88 |
||
89 |
if (iter != all_schedulers.end()) |
|
90 |
{
|
|
1192.2.2
by Monty Taylor
Added type name strings to all of the plugin types. |
91 |
if (scheduler != NULL) |
92 |
scheduler->deactivate(); |
|
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
93 |
scheduler= *iter; |
1192.2.2
by Monty Taylor
Added type name strings to all of the plugin types. |
94 |
scheduler->activate(); |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
95 |
return false; |
96 |
}
|
|
97 |
||
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
98 |
errmsg_printf(error::WARN, |
1152.1.5
by Brian Aker
Remove Factory/make scheduler work like everything else. |
99 |
_("Attempted to configure %s as the scheduler, which did " |
100 |
"not exist.\n"), name.c_str()); |
|
101 |
return true; |
|
102 |
}
|
|
103 |
||
104 |
||
105 |
plugin::Scheduler *plugin::Scheduler::getScheduler() |
|
106 |
{
|
|
107 |
return scheduler; |
|
108 |
}
|
|
1130.3.10
by Monty Taylor
Cleaned up service namespacing. |
109 |
|
110 |
} /* namespace drizzled */ |