include/tumbler.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  * Copyright 2002 Jeff Rush <jrush@taupro.com>
00003  * Original Copyright 1979-2002 Udanax.com
00004  *
00005  * This file is part of the Udanax xanalogical storage system.
00006  *
00007  * Udanax is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Udanax is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with Udanax; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  **********************************************************************/
00021 
00030 /* Modification History:
00031  * $Log: tumbler.h,v $
00032  * Revision 1.7  2002/05/28 03:51:13  jrush
00033  * Updated sources to comply with a GPL licensing.
00034  *
00035  * Revision 1.6  2002/04/16 22:38:21  jrush
00036  * Added but then commented out new methods for tumblers acting as a C type.
00037  * Need to remove unions throughout system first, due to compiler errors.
00038  *
00039  * Revision 1.5  2002/04/09 21:45:46  jrush
00040  * Renamed class 'tumbler' to 'Tumbler', for consistency with Python sources,
00041  * and changed typeisa from typedef to a subclass, in preparation for cleaning
00042  * up the type/class tree.
00043  *
00044  * Revision 1.4  2002/04/06 17:05:57  jrush
00045  * Switched from referring to 'task' for a client connection to 'session',
00046  * and converted the typetask typedef/struct into a Session C++ class.
00047  *
00048  * Revision 1.3  2002/04/06 15:22:53  jrush
00049  * Broke out tumbler struct/typedef as a C++ class.
00050  *
00051  * Revision 1.5  2002/04/06 15:00:34  jrush
00052  * Changed INT to just 'int'.
00053  *
00054  * Revision 1.4  2002/02/14 05:40:42  jrush
00055  * Cleaned up source:
00056  *
00057  * 1. ran thru the indent tool to achieve a standard look,
00058  * 2. added structured comments at top for use with DOxygen reporting
00059  *    as well as CVS keywords,
00060  * 3. added #ifndef/#defines to prevent duplicate inclusions,
00061  * 4. insured all struct/union defs have names,
00062  * 5. centralized prototypes in protos.h, removing incomplete ones,
00063  * 6. cleaned up use of bool/BOOLEAN type to suit C++ type,
00064  * 7. fixed initializer nesting in tumbler constants.
00065  *
00066  */
00067 
00068 #ifndef __UDANAX_TUMBLER_H__
00069 #define __UDANAX_TUMBLER_H__
00070 
00071 /*
00072  * humber
00073  */
00074 
00075 typedef unsigned char *humber;
00076 #define SIZEOFZEROHUMBER 3
00077 
00078 /*
00079  * tumbler
00080  */
00081 
00082 #define NPLACES 11                     /* places in mantissa of tumbler */
00083 
00084 #define TUMBLERMINUS 129
00085 typedef unsigned int tdigit;
00086 
00087 class Tumbler {
00088 public:
00089     humber  xvartumbler;
00090     char    varandnotfixed;
00091     char    sign;      /* 1 if negative, otherwise 0 */
00092     short   exp;
00093     tdigit  mantissa[NPLACES];
00094 
00095 //    Tumbler() {}             // Default Constructor
00096 //    Tumbler(const Tumbler&); // Copy Constructor
00097 //    Tumbler& operator=(const Tumbler&);
00098 //    Tumbler& operator=(int);
00099 };
00100 
00101 #define ZEROTUMBLER  {0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0}  /* 0.0.0.0.0.0 */
00102 
00103 extern Tumbler ZEROTUMBLERvar;  /* EXTERNAL BEWARE */
00104 
00105 #define tumblerclear(tumblerptr) ((*(tumblerptr)) = ZEROTUMBLERvar)
00106 #define iszerotumbler(tumblerptr) (!((tumblerptr) -> mantissa[0]))
00107 #define movetumbler(A,B) (*((Tumbler *)(B)) = *((Tumbler *)(A)))
00108 /* #define movetumbler(A,B) tumblercopy((A),(B)) */
00109 
00110     /* relationship between tumblers:
00111      *
00112      * "<" and ">" type comparisons are allowed, so don't change
00113      */
00114 
00115 #define GREATER  1
00116 #define EQUAL    0
00117 #define LESS    -1
00118 
00119     /* relationship between tumbler interval and address:
00120      *
00121      * "<" and ">" type comparisons are allowed, so don't change
00122      */
00123 
00124 #define TOMYLEFT        -2
00125 #define ONMYLEFTBORDER  -1
00126 #define THRUME           0
00127 #define ONMYRIGHTBORDER  1
00128 #define TOMYRIGHT        2
00129 
00130 #define macrotumblermax(a,b,c) ((*(Tumbler*)(c))=(tumblercmp((a),(b))==GREATER)?( (*(Tumbler *)(a))) :((*(Tumbler *)(b))) )
00131 #define macrotumblermin(a,b,c) ((*(Tumbler*)(c))=(tumblercmp((a),(b))==LESS)?( (*(Tumbler *)(a))) :((*(Tumbler *)(b))) )
00132 
00133 /* not needed #define macrotumblermax(a,b,c) tumblermax(a,b,c) #define macrotumblermin(a,b,c) tumblermin(a,b,c) */
00134 
00135 #define lengthoftumbler(x) intof((x))
00136 
00137 /* tumble.cxx */
00138 
00139 extern bool tumblereq(Tumbler *a, Tumbler *b);
00140 extern bool tumbleraccounteq(Tumbler *aptr, Tumbler *bptr);
00141 extern int tumblercmp(Tumbler *aptr, Tumbler *bptr);
00142 extern int intervalcmp(Tumbler *left, Tumbler *right, Tumbler *address);
00143 extern bool is1story(Tumbler *tumblerptr);
00144 extern bool tumblercheckptr(Tumbler *ptr, int /* typecrum */  *crumptr);
00145 
00146 #define intof(x) ((unsigned int)((unsigned)((humber)(x))[0]<=127)?((humber)(x))[0]:functionintof(x))
00147 
00148 #define lengthof(x) ((unsigned int)((unsigned)((humber)(x))[0]<=127)?(unsigned int)1:functionlengthof(x))
00149 /* #define tumbleradd(x,y,z) if(iszerotumbler(y)){movetumbler(x,z);}else{functiontumbleradd(x,y,z);} */
00150 #define tumbleradd(x,y,z) functiontumbleradd(x,y,z)
00151 
00152 #endif /* !__UDANAX_TUMBLER_H__*/

Generated on Sun Aug 21 04:18:13 2005 for Udanax-Green by doxygen1.3.4