NoisyArithmetic.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/calculator/NoisyArithmetic.h#2 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2009-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program 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 this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 //
00022 // ---
00023 //
00024 // Arithmetic function on various types but raises exceptions on various
00025 // error conditions (overflow, divide-by-zero etc.)
00026 //
00027 */
00028 #ifndef NoisyArithmetic_Included
00029 #define NoisyArithmetic_Included
00030 
00031 #include <stdexcept>
00032 #include "CalcMessage.h"
00033 
00034 FENNEL_BEGIN_NAMESPACE
00035 
00036 /* ---
00037 Struct for notification that an exception is forthcoming, allows
00038 the callee to take some exception specific action with its opaque
00039 element pData (such as cast it to a RegisterReference and call
00040 toNull()).
00041 
00042 Assumptions: if this structure exists the fnCB must not
00043 be NULL.
00044  --- */
00045 struct TExceptionCBData
00046 {
00047     void (* fnCB)(const char *, void *);
00048     void *pData;
00049     TExceptionCBData(
00050         void (* fnTheCB)(const char *, void *),
00051         void *pTheData)
00052     :   fnCB(fnTheCB),
00053         pData(pTheData)
00054     {}
00055 };
00056 
00057 /* --- */
00058 template <typename TMPL>
00059     struct Noisy {
00060         static TMPL add(
00061             TProgramCounter pc, const TMPL left, const TMPL right,
00062             TExceptionCBData *pExData)
00063             throw(CalcMessage);
00064         static TMPL sub(
00065             TProgramCounter pc, const TMPL left, const TMPL right,
00066             TExceptionCBData *pExData)
00067             throw(CalcMessage);
00068         static TMPL mul(
00069             TProgramCounter pc, const TMPL left, const TMPL right,
00070             TExceptionCBData *pExData) throw(CalcMessage);
00071         static TMPL div(
00072             TProgramCounter pc, const TMPL left, const TMPL right,
00073             TExceptionCBData *pExData)
00074             throw(CalcMessage);
00075         static TMPL neg(
00076             TProgramCounter pc, const TMPL right,
00077             TExceptionCBData *pExData)
00078             throw(CalcMessage);
00079     };
00080 
00081 FENNEL_END_NAMESPACE
00082 
00083 #endif
00084 
00085 // End NoisyArithmetic.h
00086 

Generated on Mon Jun 22 04:00:17 2009 for Fennel by  doxygen 1.5.1