ArrayInfo.hh

Go to the documentation of this file.
00001 #ifndef ARRAY_INFO_HH
00002 #define ARRAY_INFO_HH
00003 
00004 
00005 // Copyright (c) 1995-2005 Ohio Board of Regents and the University of
00006 // Cincinnati.  All Rights Reserved.
00007 
00008 // You may modify, distribute, and use the software contained in this
00009 // package under the terms of the "GNU LIBRARY GENERAL PUBLIC LICENSE"
00010 // version 2, June 1991. A copy of this license agreement can be found in
00011 // the file "LGPL", distributed with this archive.
00012 
00013 
00014 #include <warped/Serializable.h>
00015 #include <warped/SerializedInstance.h>
00016 #include <warped/DeserializerManager.h>
00017 #include <iostream>
00018 using std::ostream;
00019 using std::cerr;
00020 using std::endl;
00021 
00022 class RValue;
00023 
00024 class ArrayInfo : public Serializable {
00025   friend ostream& operator<<(ostream&, const ArrayInfo&);
00026 public:
00027   enum ArrayDirn_t {to = 1, downto = -1};
00028   
00029   ArrayInfo();
00030   ArrayInfo(int, ArrayInfo::ArrayDirn_t, int);
00031   ArrayInfo(const RValue &left, ArrayInfo::ArrayDirn_t, const RValue &right);
00032   ArrayInfo(const ArrayInfo&);
00033   int length() const;
00034   bool operator==(const ArrayInfo&) const;
00035   bool operator!=(const ArrayInfo&) const;
00036   bool is_null_range() const;
00037   bool isAscending() const { return (dirn() == to); }
00038 
00039   ArrayInfo &operator=(const ArrayInfo&);
00040   bool contains(const int) const;
00041 
00042   int storageIndex(const int) const;
00043   
00047   int actualIndex(int) const;
00048 
00049   int left() const { return lbound; }
00050   int right() const { return rbound; }
00051   ArrayInfo::ArrayDirn_t dirn() const { return direction; }
00052   
00053   int rightof(int i) const {
00054     if (i == rbound) {
00055       cerr << "ArrayInfo::rightof: can't take rightof right bound!\n("
00056            << lbound << " " << (int) direction << " " << rbound << ")" << endl;
00057       abort();
00058     }
00059     return (i + (int) direction);
00060   }
00061 
00062   static const string &getArrayInfoType(){
00063     static const string arrayInfoType = "ArrayInfo";
00064     return arrayInfoType;
00065   }
00066 
00067   const string &getDataType() const {
00068     return getArrayInfoType();
00069   }
00070   
00071   void serialize( SerializedInstance *serializeInto ) const {
00072     serializeInto->addInt( lbound );
00073     serializeInto->addInt( rbound );
00074     serializeInto->addInt( direction );
00075   }
00076   
00077   static Serializable *deserialize( SerializedInstance *si ){
00078     int lBound = si->getInt();
00079     int rBound = si->getInt();
00080     ArrayDirn_t dDirection = ArrayDirn_t( si->getInt() );
00081     return new ArrayInfo( lBound, dDirection, rBound );
00082   }
00083 
00084   static void registerDeserializer(){
00085     DeserializerManager::instance()->registerDeserializer( getArrayInfoType(),
00086                                                            &ArrayInfo::deserialize );
00087   }
00088 
00089 protected:
00090   
00091 private:
00092   int lbound;
00093   int rbound;
00094   ArrayDirn_t direction;
00095 };
00096 
00097 extern ostream& operator<<(ostream& os, const ArrayInfo::ArrayDirn_t &);
00098 
00099 const ArrayInfo &defaultInfo();
00100 const ArrayInfo &others();
00101 const ArrayInfo &nullInfo();
00102 
00103 #endif

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