Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

simplemanager.h

Go to the documentation of this file.
00001 /********************************************************************
00002        Copyright (c) 2001, Lee Patterson & Ant Works Software
00003        http://ssobjects.sourceforge.net
00004 
00005        created  :  December 17, 2000
00006        filename :  simplemanager.h
00007        author   :  Lee Patterson (lee@antws.com)
00008        purpose  :  Abstract class that Manages SimpleServer objects.
00009                    Management is done so you can have multi threaded 
00010                    or single threaded servers.
00011 
00012 *********************************************************************/
00013 
00014 #ifndef SIMPLEMANAGER_H
00015 #define SIMPLEMANAGER_H
00016 
00017 #include "ssobjects.h"
00018 #include "simpleserver.h"
00019 #include "serversocket.h"
00020 #include "linkedlist.h"
00021 #include "simpletime.h"
00022 #include "SimpleDate.h"
00023 
00024 #ifdef _WIN32
00025 # include <time.h>
00026 #else
00027 # include <sys/time.h>
00028 # include <unistd.h>
00029 #endif
00030 
00031 namespace ssobjects
00032 {
00033 
00034 class SimpleServer;
00035 
00036 class SimpleManager : public ThreadHandler
00037 {
00038   protected:
00039     //attributes
00040     LinkedList<SimpleServer>  m_listSimpleServers;    //list of the handlers that process messages for a connection
00041     LinkedList<ServerSocket>  m_listClientSockets;    //list of the clients sockets that are connected to server
00042     SocketInstance          m_sListen;
00043     SockAddr                m_saBind;
00044     unsigned32              m_nIdleFrequency;       //how often idle will be called
00045     unsigned32              m_nMaxConnections;
00046     bool                    m_bUsingThreads;
00047     bool                    m_bPause;      
00048     CSimpleTime             m_serverStartTime;
00049     CSimpleDate             m_serverStartDate;
00050 
00051   public:
00052     //construction
00053     SimpleManager(    
00054       const SockAddr& saBind,
00055       const bool bUseThread,
00056       const unsigned32 nFreq,
00057       const unsigned32 nMaxConnections);
00058     virtual ~SimpleManager();
00059 
00060     //methods
00061     virtual void    startServer();
00062     virtual void    idle() {};         //called every frequency
00063     void            waitFinish();              //sits here till the server is finished
00064     bool            isThreaded() { return m_bUsingThreads; }
00065     unsigned32      idleFrequency() const { return m_nIdleFrequency; }
00066     unsigned32      maxConnections() const { return m_nMaxConnections; }
00067     CSimpleTime&    startTime() { return m_serverStartTime; }
00068     CSimpleDate&    startDate() { return m_serverStartDate; }
00069     SockAddr&       bindAddr() { return m_saBind; }
00070 
00071   protected:
00072     threadReturn    ThreadHandlerProc(void);
00073     void            acceptConnection();
00074 
00075     //pure virtual user overridable 
00076     virtual SimpleServer* createServerInstance(ServerSocket* const psocket) = 0;
00077 };
00078 
00079 };
00080 
00081 #endif  //SIMPLEMANAGER_H
00082 

Generated on Thu Nov 8 12:39:26 2001 for SimpleServerObjects by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001