arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

MetaProg.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     3-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 ///MetaProg.h
00019 ///  a base class for grinder metaprograms
00020 
00021 #ifndef __GRINDER_META_PROG_DOT_H
00022 #define __GRINDER_META_PROG_DOT_H
00023 
00024 #include <simBase/simBase.h>
00025 #include <smartptr.h>
00026 #include "Tape.h"
00027 #include "GrinderKeys.h"
00028 #include "GrinderKinds.h"
00029 #include <vector>
00030 #include <sstream>
00031 
00032 class MetaProg : 
00033    public SimBase,
00034    public gutz::Counted
00035 {
00036 public:
00037    virtual ~MetaProg() {}
00038 
00039    /// from <GrinderKinds.h>
00040    int getKind() const {return _kind;}
00041 
00042    /// hopefully this will go away soon
00043    virtual std::string genText() {std::string();}
00044 
00045    static void pushScope(){}
00046    static void popScope() {}
00047 
00048 
00049    std::ostringstream &operator<<(std::ostringstream &oss);
00050 
00051 protected:
00052    MetaProg() : _kind(GK_UNKNOWN) {}
00053    MetaProg(int kind) : _kind(kind) {}
00054    MetaProg(const MetaProg &mp) {}/// not used
00055    MetaProg &operator=(const MetaProg &mp) {} ///not used
00056 
00057    int _kind;
00058 };
00059 
00060 typedef gutz::SmartPtr<MetaProg> MetaProgSP;
00061 typedef std::vector<MetaProgSP>  MetaProgSPVec;
00062 typedef MetaProgSPVec::iterator  MetaProgSPVecIter;
00063 
00064 //////////////////////////////////////////////////////////
00065 /// specific kinds of metaprograms, mostly for typing
00066 //////////////////////////////////////////////////////////
00067 
00068 ////////////////////////////////
00069 /// Fragment
00070 ////////////////////////////////
00071 
00072 class FPMetaProg : public MetaProg 
00073 {
00074 public:
00075    virtual ~FPMetaProg() {}
00076    
00077 protected:
00078    FPMetaProg() : MetaProg(GK_FRAGMENT) {}
00079 };
00080 
00081 ////////////////////////////////
00082 /// Vertex
00083 ////////////////////////////////
00084 
00085 class VPMetaProg : public MetaProg 
00086 {
00087 public:
00088    virtual ~VPMetaProg() {}
00089 
00090 protected:
00091    VPMetaProg() : MetaProg(GK_VERTEX) {}
00092 };
00093 
00094 //////////////////////////////////////////////////////////
00095 /// some implementation
00096 //////////////////////////////////////////////////////////
00097 
00098 inline
00099 std::ostringstream &MetaProg::operator<<(std::ostringstream &oss)
00100 {
00101    oss << "## meta: " << typeid(*this).name() << "::"
00102       << getName() << "\n";
00103    oss << genText();
00104    return oss;
00105 }
00106 
00107 inline
00108 std::ostringstream &operator<<(std::ostringstream &oss, MetaProgSP m)
00109 {
00110    return m->operator<<(oss);
00111 }
00112 
00113 
00114 #endif
00115 

Send questions, comments, and bug reports to:
jmk