/*! \file connection.h
  This is the generic Connection class definition.

  \author Jon A. Lambert
  \date 02/15/2003
  \version 0.10

 */

#ifndef	CONNECTION_H
#define	CONNECTION_H

/*!
  The Connection class contains the minimum amount of attributes
  to reasonably maintain a socket connection with a client.

  \todo
  - Perhaps the bottomless buffer isn't such a grand idea.  After
    all it's not minimal and perhaps too naive.

 */
//##ModelId=3ED44BF1019E
class Connection {
public:
  //##ModelId=3ED44BF10253
  Connection(SOCKET sock);
  //##ModelId=3ED44BF10255
  virtual ~Connection();
  //##ModelId=3ED44BF1025E
  Connection(const Connection& r_conn);
  //##ModelId=3ED44BF10260
  virtual void HandleInput();
  //##ModelId=3ED44BF10268
  virtual void HandleOutput();
  //##ModelId=3ED44BF1026A
  virtual bool CanBeDisconnected();
  //##ModelId=3ED44BF10272
  virtual void Disconnect();
  //##ModelId=3ED44BF10274
  virtual void SendMsg(const string& r_msg);
  //##ModelId=3ED44BF1027D
  virtual string* ReadMsg();
  //##ModelId=3ED44BF10286
  virtual SOCKET GetSocket();
protected:
  //##ModelId=3ED44BF10288
  Connection& operator= (const Connection& r_conn);
  //##ModelId=3ED44BF101C6
  SOCKET mSock;             //!< network socket
  //##ModelId=3ED44BF10216
  bool mDisconnectable;     //!< flag indicating connection wishes to be disconnected
  //##ModelId=3ED44BF10220
  list<string> mInBuffer;   //!< buffered lines waiting to be processed
  //##ModelId=3ED44BF1022A
  list<string> mOutBuffer;  //!< buffered lines waiting to be output
  //##ModelId=3ED44BF1023F
  char * mpPendingOutput;   //!< pending output on socket
  //##ModelId=3ED44BF10249
  char * mpPendingInput;    //!< pending or not fully formed input on socket
};


#endif // CONNECTION_H