1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
1 |
/*
|
1502.5.9
by Barry.Leslie at PrimeBase
- Cleaned up some style points. |
2 |
* Copyright (C) 2010 PrimeBase Technologies GmbH, Germany
|
3 |
*
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
6 |
* the Free Software Foundation; version 2 of the License.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful,
|
|
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
* GNU General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU General Public License
|
|
14 |
* along with this program; if not, write to the Free Software
|
|
15 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
*
|
|
17 |
* Barry Leslie
|
|
18 |
*
|
|
19 |
* 2010-05-12
|
|
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
20 |
*/
|
21 |
||
1502.5.12
by Barry.Leslie at PrimeBase
Fixed header guard to comply with naming convention. |
22 |
#ifndef PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H
|
23 |
#define PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H
|
|
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
24 |
|
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
25 |
#include <drizzled/plugin/event_observer.h> |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
26 |
|
27 |
namespace drizzled |
|
28 |
{
|
|
29 |
||
30 |
namespace plugin |
|
31 |
{
|
|
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
32 |
class HelloEvents: public EventObserver |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
33 |
{
|
34 |
public: |
|
35 |
||
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
36 |
HelloEvents(std::string name_arg): EventObserver(name_arg), is_enabled(false), db_list(""), table_list(""){} |
37 |
||
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
38 |
void registerTableEventsDo(TableShare &table_share, EventObserverList &observers); |
39 |
void registerSchemaEventsDo(const std::string &db, EventObserverList &observers); |
|
40 |
void registerSessionEventsDo(Session &session, EventObserverList &observers); |
|
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
41 |
|
1502.5.8
by Barry.Leslie at PrimeBase
- Changed names to match the drizzle naming convention. |
42 |
bool observeEventDo(EventData &); |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
43 |
|
44 |
// Some custom things for my plugin:
|
|
45 |
void enable() { is_enabled= true;} |
|
46 |
void disable() { is_enabled= false;} |
|
47 |
bool isEnabled() const |
|
48 |
{
|
|
49 |
return is_enabled; |
|
50 |
}
|
|
51 |
||
1502.5.6
by Barry.Leslie at PrimeBase
Fixed a compiler error due to an uninitialized variavble and cleaned up some coding standard stuff. |
52 |
private: |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
53 |
|
54 |
bool is_enabled; |
|
55 |
//----------------------
|
|
56 |
std::string db_list; |
|
57 |
||
1502.5.6
by Barry.Leslie at PrimeBase
Fixed a compiler error due to an uninitialized variavble and cleaned up some coding standard stuff. |
58 |
public: |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
59 |
void setDatabasesOfInterest(const char *list) |
60 |
{
|
|
61 |
db_list.assign(list); |
|
62 |
}
|
|
63 |
||
64 |
const char *getDatabasesOfInterest() |
|
65 |
{
|
|
66 |
return db_list.c_str(); |
|
67 |
}
|
|
68 |
||
1502.5.6
by Barry.Leslie at PrimeBase
Fixed a compiler error due to an uninitialized variavble and cleaned up some coding standard stuff. |
69 |
private: |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
70 |
bool isDatabaseInteresting(const std::string &db_name) |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
71 |
{
|
72 |
std::string list(db_list); |
|
73 |
list.append(","); |
|
74 |
||
75 |
std::string target(db_name); |
|
76 |
target.append(","); |
|
77 |
||
78 |
return (list.find(target) != std::string::npos); |
|
79 |
}
|
|
80 |
||
81 |
//----------------------
|
|
82 |
std::string table_list; |
|
83 |
||
1502.5.6
by Barry.Leslie at PrimeBase
Fixed a compiler error due to an uninitialized variavble and cleaned up some coding standard stuff. |
84 |
public: |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
85 |
void setTablesOfInterest(const char *list) |
86 |
{
|
|
87 |
table_list.assign(list); |
|
88 |
}
|
|
89 |
||
90 |
const char *getTablesOfInterest() |
|
91 |
{
|
|
92 |
return table_list.c_str(); |
|
93 |
}
|
|
94 |
||
1502.5.6
by Barry.Leslie at PrimeBase
Fixed a compiler error due to an uninitialized variavble and cleaned up some coding standard stuff. |
95 |
private: |
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
96 |
bool isTableInteresting(const std::string &table_name) |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
97 |
{
|
98 |
std::string list(table_list); |
|
99 |
list.append(","); |
|
100 |
||
101 |
std::string target(table_name); |
|
102 |
target.append(","); |
|
103 |
||
104 |
return (list.find(target) != std::string::npos); |
|
105 |
}
|
|
106 |
||
107 |
||
108 |
//----------------------
|
|
1502.5.7
by Barry.Leslie at PrimeBase
Renamed the 'Event' plugin to 'EventObserver' plugin along with some internal class renames to make things clearer. |
109 |
bool isSessionInteresting(Session &) |
1502.5.4
by Barry.Leslie at PrimeBase
Added a demo plugin based on the the events plugin API. |
110 |
{
|
111 |
/* You could filter sessions of interest based on login
|
|
112 |
* information.
|
|
113 |
*/
|
|
114 |
return true; |
|
115 |
}
|
|
116 |
||
117 |
||
118 |
};
|
|
119 |
} /* namespace plugin */ |
|
120 |
} /* namespace drizzled */ |
|
1502.5.12
by Barry.Leslie at PrimeBase
Fixed header guard to comply with naming convention. |
121 |
#endif /* PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H */ |