00001 /* Glass - a distributed computing library 00002 Copyright (C) 2003-2009 Bruno Barberi Gnecco 00003 Copyright (C) 2009-2010 Corollarium Technologies 00004 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef _GLASS_SERVER_HH_ 00022 #define _GLASS_SERVER_HH_ 00023 00024 #include <list> 00025 00026 #include "glass.h" 00027 #include "types.h" 00028 #include "exception.h" 00029 #include "thread.h" 00030 00031 namespace libglass { 00032 00033 class Protocol; 00034 00038 class LIBGLASS_API GlassServer : public Glass { 00039 protected: 00040 unsigned int clientnum; 00041 nodeId master; 00046 class GlassServerConnection : public GlassThread { 00047 private: 00048 GlassServer *s; 00049 public: 00050 GlassServerConnection(GlassServer *s) throw(Exception); 00052 void cleanup(void); 00054 void execute(void); 00055 }; 00056 friend class GlassServerConnection; 00057 00058 GlassServerConnection *sc; 00065 Protocol *getProtocol(void) const; 00066 00072 bool updateClients(void); 00073 00078 int start(void); 00079 00080 virtual bool rootPacket(Packet &p); 00081 00082 virtual bool sendPacket(Packet &p); 00083 virtual nodeId registerNode(nodeFD fd); 00084 virtual bool unregisterNode(nodeId id); 00085 virtual bool unregisterNode(nodeFD fd); 00086 00087 public: 00093 GlassServer(Protocol *p) throw(Exception); 00094 ~GlassServer(); 00095 00096 void stop(void); 00097 00107 unsigned int getTotalNodes(void); 00108 }; 00109 00110 } // namespace 00111 00112 00113 #endif // _GLASS_SERVER_HH_