casfuncobj.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 //  Copyright (c) 2006 by Rafael Ostertag
00004 //
00005 //  This program is free software; you can redistribute it and/or modify
00006 //  it under the terms of the GNU General Public License as published by
00007 //  the Free Software Foundation; either version 2 of the License, or
00008 //  (at your option) any later version.
00009 //
00010 //  This program is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 //  GNU General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU General Public License
00016 //  along with this program; if not, write to the Free Software
00017 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 //
00019 //
00020 // $Id: casfuncobj.h,v 1.19 2006/12/28 19:01:24 rafi Exp $
00021 //
00022 
00035 #ifndef _CASFUNCOBJ_H
00036 #define _CASFUNCOBJ_H
00037 
00038 #ifdef HAVE_CONFIG_H
00039 #include "config.h"
00040 #endif
00041 
00042 #ifdef DEBUG
00043 #include <cassert>
00044 #endif
00045 
00046 #include <functional>
00047 #include <vector>
00048 
00049 #include "casobject.h"
00050 #include "casexception.h"
00051 #include "casnumeric.h"
00052 #include "casterm.h"
00053 
00064 #if defined(DEBUG) || defined(DEBUG2)
00065 #include <iostream>
00066 
00083 class CASPrintMemAddress {
00084     public:
00095         void operator() ( const CASObject* o ) const {
00096             std::cout << ( ( void* ) o ) << std::endl;
00097         }
00098 };
00099 
00107 class CASPrintObject {
00108     public:
00119         void operator() ( const CASObject* o ) const {
00120             assert ( o != 0 );
00121             o->Print();
00122             std::cout << std::endl;
00123         }
00124 };
00125 
00129 #endif
00130 
00143 class CASTypeFinder_EQ : public std::unary_function<CASObject*, bool> {
00144     private:
00151         const CASObject* object;
00152     public:
00163         explicit CASTypeFinder_EQ ( const CASObject* o ) : object ( o ) {}
00164 
00178         bool operator() ( const CASObject* o ) const {
00179             return object->GetType() == o->GetType();
00180         }
00181 };
00182 
00194 class CASFindEqualObj : public std::unary_function<CASObject*, bool> {
00195     private:
00202         const CASObject* object;
00203     public:
00213         explicit inline CASFindEqualObj ( const CASObject *o ) : object ( o ) {
00214             checkptr ( o );
00215         }
00229         bool operator() ( const CASObject* o ) const {
00230             return object->IsEqual ( o );
00231         }
00232 
00233 };
00234 
00242 class CASDestroyObject {
00243     public:
00247         void operator() ( CASObject* o ) const;
00248 };
00249 
00256 class CASEvaluateObject {
00257     public:
00271         CASObject* operator() ( const CASObject* o ) const {
00272             checkptr ( o );
00273             return o->Evaluate();
00274         }
00275 };
00276 
00282 class CASExpandObject {
00283     public:
00287         CASObject* operator() ( const CASObject* o ) const;
00288 };
00289 
00295 class CASCloneObject {
00296     public:
00300         CASObject* operator() ( const CASObject* o ) const;
00301 };
00302 
00308 class CASInvertObject {
00309     public:
00313         CASObject* operator() ( const CASObject* o ) const;
00314 };
00315 
00321 class CASInvertObjectIP {
00322     public:
00326         void operator() ( CASObject* o ) const;
00327 };
00328 
00334 class CASAbsoluteObjectIP {
00335     public:
00340         void operator() ( CASObject* o ) const;
00341 };
00342 
00349 class CASSortObject {
00350     public:
00355         bool operator() ( const CASObject* o1, const CASObject* o2 ) const;
00356 };
00357 
00369 class CASGarbageSort_Cmp {
00370     public:
00374         bool operator() ( const CASObject* o1, const CASObject* o2 ) const;
00375 };
00376 
00384 class CASObjectEqual : public std::binary_function<CASObject *, CASObject*, bool> {
00385     public:
00389         bool operator() ( const CASObject* o1, const CASObject* o2 );
00390 };
00391 
00400 class CASObjectFindType : public std::unary_function<CASObject *, bool> {
00401     private:
00408         int t;
00409     public:
00413         CASObjectFindType ( int type );
00417         bool operator() ( const CASObject* o ) const;
00418 };
00419 
00427 class CASObjectFindType_Not : public std::unary_function<CASObject *, bool> {
00428     private:
00434         int t;
00435     public:
00439         CASObjectFindType_Not ( int type );
00443         bool operator() ( const CASObject* o ) const;
00444 };
00445 
00454 class CASObjectFindByAddr : public std::unary_function<CASObject *, bool> {
00455     private:
00462         const CASObject *needle;
00463     public:
00471         inline CASObjectFindByAddr ( const CASObject* o ) {
00472             needle = o;
00473         }
00477         bool operator() ( const CASObject* o ) const;
00478 };
00479 
00490 class CASIsPureNumerical {
00491     private:
00499         bool b;
00500     public:
00506         inline explicit CASIsPureNumerical() : b ( true ) {};
00514         inline CASIsPureNumerical ( const CASIsPureNumerical &o ) { b = o.b; }
00519         void operator() ( const CASObject* o );
00527         inline const CASIsPureNumerical &operator= ( const CASIsPureNumerical &o )
00528         {  if ( &o == this )
00529                 return *this;
00530             b = o.b;
00531             return *this;
00532         }
00543     inline bool Result() const { return b; }
00544 };
00545 
00553 class CASExtractNonCoefficients {
00554     public:
00568         CASObject *operator() ( CASObject* o ) const {
00569             if ( !o->meta.IsCoefficient() ) {
00570                 return o;
00571             } else {
00572                 return 0;
00573             }
00574         }
00575 };
00576 
00595 class CASGetCoefficient {
00596     private:
00606         const CASObject *coe;
00607     public:
00613         inline CASGetCoefficient() : coe ( 0 ) {};
00621         inline CASGetCoefficient ( const CASGetCoefficient &o ) { coe = o.coe; }
00631         const CASObject *Result() const { return coe; }
00646         void operator() ( CASObject* o ) {
00647             if ( coe == 0 ) {
00648                 checkptr ( o );
00649                 if ( o->meta.IsCoefficient() ) {
00650                     coe = o;
00651                 }
00652             }
00653         }
00661         const CASGetCoefficient &operator= ( const CASGetCoefficient &o ) {
00662             if ( &o == this )
00663                 return *this;
00664             coe = o.coe;
00665             return *this;
00666         }
00667 };
00668 
00682 class CASExtractSingleValues {
00683     private:
00692         std::vector<const CASObject*> l;
00693     public:
00699         inline explicit CASExtractSingleValues() {};
00700 
00704         CASExtractSingleValues ( const CASExtractSingleValues& o );
00708         const CASExtractSingleValues &operator= ( const CASExtractSingleValues &o );
00709 
00713         void operator() ( CASObject* o );
00714 
00718         void Result ( std::vector<const CASObject*> &rl ) const;
00719 };
00720 
00734 class CASExtractNonSingleValues {
00735     private:
00744         std::vector<const CASObject*> l;
00745     public:
00751         inline explicit CASExtractNonSingleValues() {};
00752 
00756         CASExtractNonSingleValues ( const CASExtractNonSingleValues& o );
00757 
00761         const CASExtractNonSingleValues &operator= ( const CASExtractNonSingleValues &o );
00762 
00766         void operator() ( CASObject* o );
00767 
00771         void Result ( std::vector<const CASObject*> &rl ) const;
00772 };
00773 
00783 class CASCalculateSortWeight {
00784     private:
00795         CASObject *weight;
00796 
00797     public:
00804         inline explicit CASCalculateSortWeight() : weight ( 0 ) {}
00808         ~CASCalculateSortWeight();
00812         CASCalculateSortWeight ( const CASCalculateSortWeight& o );
00816         void operator() ( CASObject* o );
00820         const CASCalculateSortWeight &operator= ( const CASCalculateSortWeight &o );
00824         CASObject* Result() const;
00825 
00826 };
00827 
00831 #endif /* _CASFUNCOBJ_H */

Generated on Sun Dec 31 01:57:26 2006 for ECAS by  doxygen 1.4.7