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 <drizzled/plugin/plugin.h>
00023 #include <drizzled/atomics.h>
00024 #include <vector>
00025 
00026 #include <drizzled/visibility.h>
00027 
00028 namespace drizzled
00029 {
00030 namespace plugin
00031 {
00032 
00033 class Client;
00034 class Listen;
00035 typedef std::vector<Listen *> ListenVector;
00036 typedef std::pair<std::string*, drizzled::atomic<uint64_t>*> ListenCounter;
00041 class DRIZZLED_API Listen : public Plugin
00042 {
00043   Listen();
00044   Listen(const Listen&);
00045   Listen& operator=(const Listen&);
00046 protected:
00047   std::vector<ListenCounter*> counters;
00048 public:
00049   explicit Listen(std::string name_arg)
00050     : Plugin(name_arg, "Listen")
00051   {}
00052   virtual ~Listen()
00053   {
00054     std::vector<ListenCounter*>::iterator it;
00055     for (it= counters.begin(); it < counters.end(); ++it)
00056     {
00057       ListenCounter* counter= *it;
00058       delete counter->first;
00059       delete counter;
00060     }
00061   }
00062 
00063   static ListenVector &getListenProtocols();
00064 
00065   std::vector<ListenCounter*>& getListenCounters()
00066   {
00067     return counters;
00068   }
00076   virtual bool getFileDescriptors(std::vector<int> &fds)= 0;
00077 
00082   virtual plugin::Client *getClient(int fd)= 0;
00083 
00087   static bool addPlugin(Listen *listen_obj);
00088 
00092   static void removePlugin(Listen *listen_obj);
00093 
00097   static bool setup(void);
00098 
00103   static plugin::Client *getClient(void);
00104 
00109   static plugin::Client *getNullClient(void);
00110 
00114   static void shutdown(void);
00115 
00116 };
00117 
00118 } /* namespace plugin */
00119 
00120 } /* namespace drizzled */
00121