Drizzled Public API Documentation

listen.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2008 Sun Microsystems, Inc.
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 
20 #pragma once
21 
22 #include <boost/foreach.hpp>
23 #include <drizzled/plugin/plugin.h>
24 #include <drizzled/atomics.h>
25 #include <vector>
26 #include <drizzled/visibility.h>
27 
28 namespace drizzled {
29 namespace plugin {
30 
31 typedef std::vector<Listen *> ListenVector;
32 typedef std::pair<std::string*, drizzled::atomic<uint64_t>*> ListenCounter;
37 class DRIZZLED_API Listen : public Plugin
38 {
39 protected:
40  std::vector<ListenCounter*> counters;
41 public:
42  explicit Listen(std::string name_arg)
43  : Plugin(name_arg, "Listen")
44  {}
45 
46  virtual ~Listen()
47  {
48  BOOST_FOREACH(ListenCounter* counter, counters)
49  {
50  delete counter->first;
51  delete counter;
52  }
53  }
54 
55  static ListenVector &getListenProtocols();
56 
57  std::vector<ListenCounter*>& getListenCounters()
58  {
59  return counters;
60  }
68  virtual bool getFileDescriptors(std::vector<int> &fds)= 0;
69 
74  virtual plugin::Client *getClient(int fd)= 0;
75 
79  static bool addPlugin(Listen*);
80 
84  static void removePlugin(Listen*);
85 
89  static bool setup(void);
90 
95  static plugin::Client *getClient();
96 
101  static plugin::Client *getNullClient();
102 
106  static void shutdown();
107 
108 };
109 
110 } /* namespace plugin */
111 
112 } /* namespace drizzled */
113 
#define DRIZZLED_API
Definition: visibility.h:62
Visibility Control Macros.