~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/hello_events/hello_events.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#ifndef PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H
 
23
#define PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H
 
24
 
 
25
#include <drizzled/plugin/event_observer.h>
 
26
 
 
27
namespace drizzled
 
28
{
 
29
 
 
30
namespace plugin
 
31
{
 
32
class HelloEvents: public EventObserver
 
33
{
 
34
public:
 
35
 
 
36
  HelloEvents(std::string name_arg): EventObserver(name_arg), is_enabled(false), db_list(""), table_list(""){}
 
37
  ~HelloEvents();
 
38
 
 
39
  void registerTableEventsDo(TableShare &table_share, EventObserverList &observers);
 
40
  void registerSchemaEventsDo(const std::string &db, EventObserverList &observers);
 
41
  void registerSessionEventsDo(Session &session, EventObserverList &observers);
 
42
 
 
43
  bool observeEventDo(EventData &);
 
44
 
 
45
  // Some custom things for my plugin:
 
46
  void enable() { is_enabled= true;}
 
47
  void disable() { is_enabled= false;}
 
48
  bool isEnabled() const
 
49
  {
 
50
    return is_enabled;
 
51
  }
 
52
 
 
53
private:
 
54
  
 
55
  bool is_enabled;
 
56
  //----------------------
 
57
  std::string db_list;
 
58
  
 
59
public:
 
60
  void setDatabasesOfInterest(const char *list) 
 
61
  {
 
62
    db_list.assign(list);
 
63
  }
 
64
  
 
65
  const char *getDatabasesOfInterest() 
 
66
  {
 
67
    return db_list.c_str();
 
68
  }
 
69
  
 
70
private:
 
71
  bool isDatabaseInteresting(const std::string &db_name)
 
72
  {
 
73
    std::string list(db_list);
 
74
    list.append(",");
 
75
    
 
76
    std::string target(db_name);
 
77
    target.append(",");
 
78
    
 
79
    return (list.find(target) != std::string::npos);
 
80
  }
 
81
  
 
82
  //----------------------
 
83
  std::string table_list;
 
84
  
 
85
public:
 
86
  void setTablesOfInterest(const char *list) 
 
87
  {
 
88
    table_list.assign(list);
 
89
  }
 
90
  
 
91
  const char *getTablesOfInterest() 
 
92
  {
 
93
    return table_list.c_str();
 
94
  }
 
95
  
 
96
private:
 
97
  bool isTableInteresting(const std::string &table_name)
 
98
  {
 
99
    std::string list(table_list);
 
100
    list.append(",");
 
101
    
 
102
    std::string target(table_name);
 
103
    target.append(",");
 
104
    
 
105
    return (list.find(target) != std::string::npos);
 
106
  }
 
107
 
 
108
 
 
109
  //----------------------
 
110
  bool isSessionInteresting(Session &)
 
111
  {
 
112
    /* You could filter sessions of interest based on login
 
113
     * information.
 
114
     */
 
115
    return true;
 
116
  }
 
117
 
 
118
  
 
119
};
 
120
} /* namespace plugin */
 
121
} /* namespace drizzled */
 
122
#endif /* PLUGIN_HELLO_EVENTS_HELLO_EVENTS_H */