Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ippSimpleServer.h

Go to the documentation of this file.
00001 // 
00002 // DISCLAIMER: 
00003 //  This software was produced by the National Institute of Standards 
00004 //  and Technology (NIST), an agency of the U.S. government, and by statute is 
00005 //  not subject to copyright in the United States.  Recipients of this 
00006 //  software assume all responsibility associated with its operation,
00007 //  modification,maintenance, and subsequent redistribution. 
00008 //
00009 //  See NIST Administration Manual 4.09.07 b and Appendix I. 
00010 #pragma once
00011 #include "ippdme/ippdme.h"
00012 
00013 #include "ippdme/Socket/ippSocket.h"
00014 
00015 #include "ippdme/Response/ippErrorResponse.h"
00016 #include "ippdme/Server/ippServerQueues.h"
00017 #include "ippdme/Server/ippEngine.h"
00018 #include "ippdme/Command/ippCommand.h"
00019 #include "ippdme/ippDaemon.h"
00020 
00021 #include <map>
00022 
00023 class IPPDME_EXT_CLASS ippExecutor;
00024 class IPPDME_EXT_CLASS ippCommandChecker;
00025 class IPPDME_EXT_CLASS ippDaemon;
00026 
00027 
00028 class IPPDME_EXT_CLASS ippSimpleServer : public ippEngine
00029 {
00030 public:
00031   enum STATE
00032   {
00033      uninitialized,
00034      listening,
00035      connected, 
00036   };
00037   // constructors
00038   ippSimpleServer(ippExecutor* _executor=0);
00039 
00040   virtual ~ippSimpleServer();
00041 
00042   // pulse
00043   virtual void HeartBeat();
00044 
00045 
00046   // --- action on the server
00047   virtual bool PowerOn(int portNumber = 1294);  
00048   virtual bool PowerOff();
00049 
00050   // call backs
00051   virtual void OnClientConnected();
00052   virtual void OnClientDisconnected();
00053 
00054 
00055   STATE GetState() const {return _state; }
00056 
00057   bool InSession() const;
00058   
00059   bool IsProcessingSlowCommand() const;
00060 
00061 protected:
00062   virtual void ExecuteCommand(ippCommandPtr aCommand);
00063   ippCommandChecker* _checker;
00064   ippExecutor*       _executor;
00065 private:
00066   ippSocket   _listenSocket;
00067   ippServerQueues    _serverQueues;
00068         short _portNumber;
00069   STATE _state;
00070   bool _inSession;
00071   int _tagBeingExecuted; // tag of the command being executed (not yet completed)
00072   bool _inErrorState;
00073   
00074   // prohibited copy constructors
00075   ippSimpleServer(const ippSimpleServer&);
00076   void operator=(const ippSimpleServer&);
00077 
00078   void PerformWrite();
00079   void PerformExecute();
00080   void PerformListening();
00081   
00082   void AbortPendingCommands();
00083   
00084   void ExecuteAbortE(const ippTag&);
00085 
00086   void StopAllDaemons();
00087   int  DaemonCount() const;
00088 
00089   void ClearAllErrors();
00090 
00091   void SendError(
00092     ippErrorResponsePtr errResponse,
00093     const char* rich_error
00094   );
00095 
00096   // send a response to the client
00097   void SendResponse(ippResponsePtr response);
00098   
00099   // send the acknowledge response for the command  (&)
00100   void SendAcknowledge(const ippTag& tag);
00101   
00102   // send the completion response for the command  (%)
00103   void SendComplete(const ippTag& tag);
00104 
00105   void ProcessCommand(const char* commandbuffer);
00106 
00107   bool GetLogDetails() const;
00108 
00109   void ProcessResponseList(const ippResponseList& aCommand);
00110   void WriteToSocket(const char* line);
00111 
00112 
00113   // -- overridden from ippEngine
00114   virtual void ProcessLine(const char* inputline);
00115   virtual void ProcessMisformedLine(const char* inputline);
00116   virtual void OnConnectionLost();
00117 
00118 };

Generated on Wed Nov 8 00:20:00 2006 for IPPDME by  doxygen 1.4.1