00001 #ifndef EXPRARRAY_H 00002 #define EXPRARRAY_H 00003 00004 #include "SundanceDefs.h" 00005 #include <string> 00006 00007 00008 namespace Sundance 00009 { 00010 00011 using namespace TSF; 00012 using std::string; 00013 00014 using std::ostream; 00015 class Expr; 00016 00017 /** 00018 * \ingroup LowLevelSymbolics 00019 TSFArrays of Exprs need to be specialized in order that copies are done with 00020 the assignUsingRHSPtr() method of TSFArray. 00021 00022 */ 00023 class ExprArray 00024 { 00025 public: 00026 /** \name Developer-only methods */ 00027 //@{ 00028 /** Empty ctor */ 00029 ExprArray(); 00030 00031 /** */ 00032 ExprArray(int n); 00033 00034 /** */ 00035 ExprArray(int n, const Expr* cTSFArray); 00036 00037 /** */ 00038 ExprArray(int n, const Expr& t); 00039 // explicit copy ctor, dtor, and assign needed to prevent memory 00040 // corruption 00041 00042 /** */ 00043 ~ExprArray(); 00044 00045 /** */ 00046 ExprArray(const ExprArray& other); 00047 00048 /** */ 00049 const ExprArray& operator=(const ExprArray& other); 00050 00051 /** */ 00052 void resize(int newN); 00053 00054 /** */ 00055 void reserve(int n); 00056 00057 /** */ 00058 int capacity() const ; 00059 00060 /** */ 00061 void remove(int i); 00062 00063 // add a new entry. 00064 /** */ 00065 ExprArray& append(const Expr& rhs); 00066 00067 // simple accessors. 00068 // If NOBOUNDSCHECK is not set and a bounds error occurs, crash. 00069 // In cases where error handling is to be used, and exceptions are 00070 // not supported, use get and put instead. 00071 /** */ 00072 Expr& operator[](int i); 00073 /** */ 00074 const Expr& operator[](int i) const; 00075 00076 /** */ 00077 int length() const; 00078 //@} 00079 private: 00080 Expr* data_; 00081 int len_; 00082 int reserve_; 00083 00084 void indexCheckCrash(int i) const; 00085 bool indexCheckNoCrash(int i) const; 00086 }; 00087 00088 //* \relates ExprArray */ 00089 ostream& operator<<(ostream& os, const ExprArray& array); 00090 00091 00092 00093 } 00094 #endif 00095