drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
hello_events.h
1/*
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
20 */
21
22#pragma once
23
24#include <drizzled/plugin/event_observer.h>
25
26namespace drizzled
27{
28
29namespace plugin
30{
31class HelloEvents: public EventObserver
32{
33public:
34
35 HelloEvents(std::string name_arg): EventObserver(name_arg), is_enabled(false), db_list(""), table_list(""){}
36 ~HelloEvents();
37
38 void registerTableEventsDo(TableShare &table_share, EventObserverList &observers);
39 void registerSchemaEventsDo(const std::string &db, EventObserverList &observers);
40 void registerSessionEventsDo(Session &session, EventObserverList &observers);
41
42 bool observeEventDo(EventData &);
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
52private:
53
54 bool is_enabled;
55 //----------------------
56 std::string db_list;
57
58public:
59 void setDatabasesOfInterest(const char *list)
60 {
61 db_list= list;
62 }
63
64 const char *getDatabasesOfInterest()
65 {
66 return db_list.c_str();
67 }
68
69private:
70 bool isDatabaseInteresting(const std::string &db_name)
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
84public:
85 void setTablesOfInterest(const char *list)
86 {
87 table_list= list;
88 }
89
90 const char *getTablesOfInterest()
91 {
92 return table_list.c_str();
93 }
94
95private:
96 bool isTableInteresting(const std::string &table_name)
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 //----------------------
109 bool isSessionInteresting(Session &)
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 */
TODO: Rename this file - func.h is stupid.