CoCoALib-0.9905 date: 23 May 2007


bool3.H

Go to the documentation of this file.
00001 #ifndef CoCoA_bool3_H
00002 #define CoCoA_bool3_H
00003 
00004 //   Copyright (c)  2005  John Abbott
00005 
00006 //   This file is part of the source of CoCoALib, the CoCoA Library.
00007 
00008 //   CoCoALib is free software; you can redistribute it and/or modify
00009 //   it under the terms of the GNU General Public License (version 2)
00010 //   as published by the Free Software Foundation.  A copy of the full
00011 //   licence may be found in the file COPYING in this directory.
00012 
00013 //   CoCoALib is distributed in the hope that it will be useful,
00014 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //   GNU General Public License for more details.
00017 
00018 //   You should have received a copy of the GNU General Public License
00019 //   along with CoCoA; if not, write to the Free Software
00020 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 
00023 #include <iosfwd>
00024 //using std::ostream;
00025 
00026 namespace CoCoA
00027 {
00028 
00029   class OpenMathOutput; // forward declaration -- defined in OpenMath.H
00030 
00031   /*-----------------------------------------------------------------*/
00032   /**
00033   \brief Class for three way "booleans": DefinitelyFalse, uncertain, and DefinitelyTrue.
00034 
00035   \include bool3.txt
00036   */
00037   /*-----------------------------------------------------------------*/
00038   class bool3
00039   {
00040   public:
00041     enum TruthValueSet { DefinitelyFalse, uncertain, DefinitelyTrue };
00042     bool3();
00043     // Default dtor, copy ctor, and assignment are fine.
00044     bool3& operator=(TruthValueSet TruthValue);
00045     bool3& operator=(bool TruthValue);
00046 
00047     friend bool IsDefinitelyFalse(bool3 flag);
00048     friend bool IsUncertain(bool3 flag);
00049     friend bool IsDefinitelyTrue(bool3 flag);
00050   private:
00051     TruthValueSet myTruthValue;
00052   };
00053 
00054 
00055   std::ostream& operator<<(std::ostream& out, bool3 flag);
00056   OpenMathOutput& operator<<(OpenMathOutput& out, bool3 flag);
00057 
00058   //---------------------------------------------------------------------------
00059   // inline functions
00060 
00061   inline bool3::bool3():
00062       myTruthValue(uncertain)
00063   {}
00064 
00065 
00066   inline bool3& bool3::operator=(TruthValueSet TruthValue)
00067   { myTruthValue = TruthValue; return *this; }
00068 
00069 
00070   inline bool3& bool3::operator=(bool TruthValue)
00071   { myTruthValue = TruthValue?DefinitelyTrue:DefinitelyFalse; return *this; }
00072 
00073 
00074   inline bool IsDefinitelyFalse(bool3 flag)
00075   { return flag.myTruthValue == bool3::DefinitelyFalse; }
00076 
00077 
00078   inline bool IsUncertain(bool3 flag)
00079   { return flag.myTruthValue == bool3::uncertain; }
00080 
00081 
00082   inline bool IsDefinitelyTrue(bool3 flag)
00083   { return flag.myTruthValue == bool3::DefinitelyTrue; }
00084 
00085 
00086 } // end of namespace CoCoA
00087 
00088 
00089 
00090 // RCS header/log in the next few lines.
00091 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/bool3.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00092 // $Log: bool3.H,v $
00093 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00094 // Imported files
00095 //
00096 // Revision 1.6  2007/03/08 18:42:05  cocoa
00097 // Cleaned up whitespace.
00098 //
00099 // Revision 1.5  2006/12/06 17:17:44  cocoa
00100 // -- removed #include "config.H"
00101 //
00102 // Revision 1.4  2006/11/24 17:22:05  cocoa
00103 // -- removed OpenMathFwd.H
00104 //
00105 // Revision 1.3  2006/11/02 13:25:44  cocoa
00106 // Simplification of header files: the OpenMath classes have been renamed.
00107 // Many minor consequential changes.
00108 //
00109 // Revision 1.2  2006/10/06 14:04:15  cocoa
00110 // Corrected position of #ifndef in header files.
00111 // Separated CoCoA_ASSERT into assert.H from config.H;
00112 // many minor consequential changes (have to #include assert.H).
00113 // A little tidying of #include directives (esp. in Max's code).
00114 //
00115 // Revision 1.1.1.1  2006/05/30 11:39:36  cocoa
00116 // Imported files
00117 //
00118 // Revision 1.3  2006/05/12 16:10:58  cocoa
00119 // Added OpenMathFwd.H, and tidied OpenMath.H.
00120 // Many consequential but trivial changes.
00121 //
00122 // Revision 1.2  2006/03/12 21:28:34  cocoa
00123 // Major check in after many changes
00124 //
00125 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00126 // Imported files
00127 //
00128 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00129 // Imported files
00130 //
00131 // Revision 1.2  2005/04/19 14:06:04  cocoa
00132 // Added GPL and GFDL licence stuff.
00133 //
00134 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00135 // Imported files
00136 //
00137 // Revision 1.6  2004/11/12 15:49:29  cocoa
00138 // Tidying prior to 0.90 release.
00139 // (a) documentation improved (or marked as poor)
00140 // (b) sundry minor improvements to the code
00141 //
00142 // Revision 1.4  2004/06/29 15:34:29  cocoa
00143 // Tidied the functions dealing with bool3 values.
00144 //
00145 // Revision 1.3  2004/05/27 16:14:02  cocoa
00146 // Minor revision for new coding conventions.
00147 //
00148 // Revision 1.2  2003/10/09 12:16:38  cocoa
00149 // New coding convention for rings.
00150 //
00151 // Revision 1.3  2003/06/23 16:17:57  abbott
00152 // Minor cleaning prior to public release.
00153 // Slightly changed order in a few places.
00154 //
00155 // Revision 1.2  2003/05/14 17:11:03  abbott
00156 // Added missing keyword "inline" -- omitting it was a silly mistake.
00157 //
00158 // Revision 1.1  2003/04/24 15:56:45  abbott
00159 // Initial revision
00160 //
00161 
00162 #endif

Generated on Wed May 23 13:45:22 2007 for CoCoALib by  doxygen 1.4.6