CallStack.hh

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Copyright (c) 1995-2005 Ohio Board of Regents and the University of
00003 // Cincinnati.  All Rights Reserved.
00004 
00005 // You may modify, distribute, and use the software contained in this package
00006 // under the terms of the "GNU LIBRARY GENERAL PUBLIC LICENSE" version 2,
00007 // June 1991. A copy of this license agreement can be found in the file
00008 // "LGPL", distributed with this archive.
00009 
00010 //---------------------------------------------------------------------------
00011 
00012 #ifndef PROCESSSTACK_HH
00013 #define PROCESSSTACK_HH
00014 
00015 #include <stdlib.h>
00016 
00017 class ObjectBase;
00018 
00019 struct StackElement {
00020   int waitLabel;
00021   ObjectBase **args;
00022   StackElement *next;
00023   int numArgs;
00024 
00025   StackElement(): waitLabel(-1), args(NULL), next(NULL), numArgs(0) {};
00026 };
00027 
00028 class CallStack {
00029 public:
00030   CallStack() {
00031     stackTop = NULL;
00032     stackBottom = NULL;
00033     numElements = 0;
00034   };
00035   virtual ~CallStack() {
00036     cleanStack();
00037   }
00038 
00039   bool empty() const;
00040   void push(StackElement *);
00041   void push(const int waitLabel, const int numArgs, ...);
00042   StackElement* pop();
00043   void popAboveCurrent();
00044   StackElement* getTop() const;
00045   StackElement* getCurrentTop() const;
00046   void setCurrentToNext();
00047   void setCurrentToTop();
00048 
00049   CallStack& operator = (const CallStack&);
00050 
00051   int stackSize() const { 
00052     return numElements;
00053   }
00054 
00055 private:
00056   void cleanStack();
00057 
00058   StackElement *stackTop;
00059   StackElement *stackBottom;
00060 
00061   // This is used to peek into the stack without actually pushing or
00062   // popping any item from it.
00063   StackElement *currentTop;
00064   int numElements;
00065 };
00066 
00067 #endif

Generated on Fri Mar 31 11:05:08 2006 for Tyvis by  doxygen 1.4.6