Drizzled Public API Documentation

listen.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <boost/foreach.hpp>
00023 #include <drizzled/plugin/plugin.h>
00024 #include <drizzled/atomics.h>
00025 #include <vector>
00026 #include <drizzled/visibility.h>
00027 
00028 namespace drizzled {
00029 namespace plugin {
00030 
00031 typedef std::vector<Listen *> ListenVector;
00032 typedef std::pair<std::string*, drizzled::atomic<uint64_t>*> ListenCounter;
00037 class DRIZZLED_API Listen : public Plugin
00038 {
00039 protected:
00040   std::vector<ListenCounter*> counters;
00041 public:
00042   explicit Listen(std::string name_arg)
00043     : Plugin(name_arg, "Listen")
00044   {}
00045 
00046   virtual ~Listen()
00047   {
00048     BOOST_FOREACH(ListenCounter* counter, counters)
00049     {
00050       delete counter->first;
00051       delete counter;
00052     }
00053   }
00054 
00055   static ListenVector &getListenProtocols();
00056 
00057   std::vector<ListenCounter*>& getListenCounters()
00058   {
00059     return counters;
00060   }
00068   virtual bool getFileDescriptors(std::vector<int> &fds)= 0;
00069 
00074   virtual plugin::Client *getClient(int fd)= 0;
00075 
00079   static bool addPlugin(Listen*);
00080 
00084   static void removePlugin(Listen*);
00085 
00089   static bool setup(void);
00090 
00095   static plugin::Client *getClient();
00096 
00101   static plugin::Client *getNullClient();
00102 
00106   static void shutdown();
00107 
00108 };
00109 
00110 } /* namespace plugin */
00111 
00112 } /* namespace drizzled */
00113