outcome.h

Go to the documentation of this file.
00001 #ifndef OUTCOME_CLASS
00002 #define OUTCOME_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : outcome                                                           *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1990-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 // forward.
00019 class byte_array;
00020 
00022 
00029 class outcome
00030 {
00031 public:
00032   inline outcome(int value = 0) : _o_value(value) {}
00034 
00040   inline ~outcome() { _o_value = 0; }  
00041 
00042   inline bool operator == (const outcome &to_compare) const
00043       { return _o_value == to_compare._o_value; }
00045 
00047   inline bool operator != (const outcome &to_compare) const
00048       { return _o_value != to_compare._o_value; }
00050 
00051   inline bool operator == (int to_compare) const
00052       { return _o_value == to_compare; }
00054   inline bool operator != (int to_compare) const
00055       { return _o_value != to_compare; }
00057 
00058   inline int value() const { return _o_value; }
00059     //<! returns the numerical value for the outcome.
00060 
00061   void pack(byte_array &packed_form) const;
00062     //<! creates a packed form of the outcome in "packed_form".
00063 
00064   bool unpack(byte_array &packed_form);
00065     //<! restores the outcome from the "packed_form".
00066 
00067   int packed_size() const { return sizeof(_o_value); }
00068     //<! the size in bytes of an outcome when packed.
00069 
00070 private:
00071   int _o_value;  //<! the numerical id for the outcome.
00072 };
00073 
00075 
00077 #define PROMOTE_OUTCOME(outc) \
00078   if (outc != common::OKAY) return outc
00079 
00081 
00083 
00089 #define DEFINE_OUTCOME(NAME, CURRENT_VALUE, INFO_STRING) \
00090   NAME = CURRENT_VALUE
00091 
00093 
00099 #define DEFINE_API_OUTCOME(NAME, CURRENT_VALUE, INFO_STRING) \
00100   NAME = CURRENT_VALUE
00101 
00103 
00104 #endif
00105 

Generated on Sat Oct 11 04:28:39 2008 for HOOPLE Libraries by  doxygen 1.5.1