contrib/gel/gevd/gevd_status_mixin.h
Go to the documentation of this file.
00001 // <begin copyright notice>
00002 // ---------------------------------------------------------------------------
00003 //
00004 //                   Copyright (c) 1997 TargetJr Consortium
00005 //               GE Corporate Research and Development (GE CRD)
00006 //                             1 Research Circle
00007 //                            Niskayuna, NY 12309
00008 //                            All Rights Reserved
00009 //              Reproduction rights limited as described below.
00010 //
00011 //      Permission to use, copy, modify, distribute, and sell this software
00012 //      and its documentation for any purpose is hereby granted without fee,
00013 //      provided that (i) the above copyright notice and this permission
00014 //      notice appear in all copies of the software and related documentation,
00015 //      (ii) the name TargetJr Consortium (represented by GE CRD), may not be
00016 //      used in any advertising or publicity relating to the software without
00017 //      the specific, prior written permission of GE CRD, and (iii) any
00018 //      modifications are clearly marked and summarized in a change history
00019 //      log.
00020 //
00021 //      THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
00022 //      EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
00023 //      WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00024 //      IN NO EVENT SHALL THE TARGETJR CONSORTIUM BE LIABLE FOR ANY SPECIAL,
00025 //      INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND OR ANY
00026 //      DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00027 //      WHETHER OR NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR ON
00028 //      ANY THEORY OF LIABILITY ARISING OUT OF OR IN CONNECTION WITH THE
00029 //      USE OR PERFORMANCE OF THIS SOFTWARE.
00030 //
00031 // ---------------------------------------------------------------------------
00032 // <end copyright notice>
00033 
00034 #ifndef gevd_status_mixin_h
00035 #define gevd_status_mixin_h
00036 
00037 //=========================== Basics ====================================
00038 //
00039 // .NAME    gevd_status_mixin
00040 // .HEADER  gel Package
00041 // .LIBRARY gevd
00042 // .INCLUDE gevd/gevd_status_mixin.h
00043 // .FILE    gevd_status_mixin.cxx
00044 //
00045 // .SECTION Description
00046 //      This mixin adds a status word and methods to control the status
00047 // word.  The interpretation of the status word depends on the context
00048 // of the usage.  However, in all cases a status of zero is defined as
00049 // good.
00050 //
00051 // Modified by:      Brian DeCleene
00052 // Date:             June 17, 1991
00053 // Description:      Combined M&DSO status and CR&D status into a
00054 //                   single object.
00055 //
00056 //
00057 //======================================================================
00058 
00059 /* ------------------------------------ */
00060 /*       DEFINE A STATUS TYPE           */
00061 typedef int StatusCode;
00062 
00063 
00064 class gevd_status_mixin
00065 {
00066  private:
00067    int status;
00068 
00069  public:
00070    inline void ClearStatus()            { status = 0;   }
00071    inline void ClearStatus(int x)       { status &= ~x; }
00072    inline void SetStatus(int x = 0)     { status |= x;  }
00073 
00074    inline void SetStatusGood()          { status = 0; }
00075    inline void SetStatusBad(int c =-1)  { status = c; }
00076 
00077    gevd_status_mixin() { ClearStatus(); }
00078 
00079  public:
00080    inline StatusCode Stat()          const { return status; }     // XXX
00081    inline bool       StatusGood()    const { return status == 0; }
00082    inline bool       StatusBad()     const { return status != 0; }
00083    inline StatusCode GetStatusCode() const { return status; }
00084 };
00085 
00086 #endif // gevd_status_mixin_h