/* $Id: action_evaluation.h,v 1.4 1999/07/30 20:24:09 v2kea318 Exp $

$Log: action_evaluation.h,v $
 * Revision 1.4  1999/07/30  20:24:09  v2kea318
 * Finished converting to G++ compliant code.
 *
 * Revision 1.3  1999/07/30  17:55:48  v2kea318
 * Reformat the header file names for Standard C++ compliance.
 *
 * Revision 1.2  1999/05/07  16:17:08  v2kea318
 * Added an ostream operator for the action_failed exception.
 *
 * Revision 1.1  1999/05/05  15:06:23  v2kea318
 * Initial revision
 *
***************************************************************************

Some routines and classes to evaluate the results of actions.

***************************************************************************/

#ifndef ACTION_EVAL_H
#define ACTION_EVAL_H

#include <stdexcept>
#include "Socket.h"
#include "pointer.h"
#include "msg_codes.h"
#include <iostream>

// define a class to indicate a failed action
class action_failed : public runtime_error {
public:
  action_failed(msg_action_code c) : runtime_error("failed action"), bc(c)
    {}
  msg_action_code failure_code() const { return bc; };
private:
  msg_action_code bc;
};

// provide a convenient << operator for action_failed exceptions.
ostream& operator << (ostream& os, const action_failed& af);

/* provide a subroutine that will read the response from a socket and 
   throw an exception if it failed. */
void eval_response(const Socket& s);
inline void eval_response(const Pointer<Socket>& s) { eval_response(*s); };

#endif
