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

ippSimpleClient.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/Server/ippEngine.h"
00012 #include "ippdme/Socket/ippSocket.h"
00013 #include "ippdme/Command/ippCommand.h"
00014 #include "ippdme/Response/ippResponse.h"
00015 
00016 class ippCommand;
00017 
00018 class IPPDME_EXT_CLASS ippSimpleClient  : public ippEngine
00019 {
00020 public:
00021    enum STATE{
00022     disconnected,
00023     trying_to_connect,
00024     connected,
00025   };
00026 
00027  ippSimpleClient();
00028   
00029   //------- Connection 
00030   
00032   void Connect(const char* hostname,int port = 1294);
00033   
00035   STATE GetState() const;
00036 
00038   void Disconnect(); 
00039 
00041   virtual void HeartBeat();
00042   
00043 
00046   bool ReadyToSend() const;
00047 
00050   bool NeedToSendClearAllErrors() const;
00051 
00052   // ----------------------------------------------------------------
00053   //   overidable Callbacks
00054   // ----------------------------------------------------------------
00055 
00057   virtual void OnConnectionLost();
00059   virtual void OnResponse(ippResponsePtr response);
00060   virtual void OnDaemonResponse(ippResponsePtr response);
00061   virtual void OnErrorResponse(ippResponsePtr response);  
00063   virtual void OnUnsollicitedEvent(ippResponsePtr response);
00065   virtual void OnComnmandCompleted(int tagNumber);
00066 
00067 
00068 
00070   void ClearAllErrors();
00071 
00075   bool InErrorState() const { return _in_error_state; }
00076 
00077 
00079   bool SendCommand(ippCommandConstPtr command);
00080 
00082   //  Warning: this string is not checked for consistency
00083   //  and is send verbatim to the server
00084   void SendCommand(const char* command_string);
00085   
00087   int NumberOfUncompletedCommandsInQueue();
00088 
00089 
00090 protected:
00091   friend class ippSimpleServerTestCase;
00092   
00093 
00094 
00095 protected:
00096   void PerformWrite();
00097 
00098   // -- overridden from ippEngine
00099   virtual void ProcessLine(const char* inputline);
00100   virtual void ProcessMisformedLine(const char* inputline);
00101 
00102 private:
00103   STATE _state;
00104 
00105   bool _ready_to_send;               
00106   int  _pending_tag;                 
00107   std::queue<int> _pending_commands; 
00108   int  _next_tag;                    
00109   bool _in_error_state;              
00110 
00111 };

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