00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Extent.hh"
00027 #include "Dimension.hh"
00028 #include "PrettyDebug.hh"
00029
00030 using std::vector ;
00031
00032 namespace {
00033
00034 PrettyDebug D("EXTENT", __FILE__);
00035
00036 }
00037
00038 namespace certi {
00039
00040
00044 Extent::Extent(size_t n)
00045 {
00046 Range range(Dimension::getLowerBound(), Dimension::getUpperBound());
00047 ranges.resize(n, range);
00048 }
00049
00050
00053 ULong
00054 Extent::getRangeLowerBound(DimensionHandle handle) const
00055 throw (ArrayIndexOutOfBounds)
00056 {
00057 if ((handle <= 0) || (handle > ranges.size()))
00058 throw ArrayIndexOutOfBounds("Invalid dimension handle");
00059 else
00060 return ranges[handle - 1].first ;
00061 }
00062
00063
00066 ULong
00067 Extent::getRangeUpperBound(DimensionHandle handle) const
00068 throw (ArrayIndexOutOfBounds)
00069 {
00070 if ((handle <= 0) || (handle > ranges.size()))
00071 throw ArrayIndexOutOfBounds("Invalid dimension handle");
00072 else
00073 return ranges[handle - 1].second ;
00074 }
00075
00076
00079 void
00080 Extent::setRangeLowerBound(DimensionHandle handle, ULong val)
00081 throw (ArrayIndexOutOfBounds)
00082 {
00083 if ((handle <= 0) || (handle > ranges.size()))
00084 throw ArrayIndexOutOfBounds("Invalid dimension handle");
00085 else
00086 ranges[handle - 1].first = val ;
00087 }
00088
00089
00092 void
00093 Extent::setRangeUpperBound(DimensionHandle handle, ULong val)
00094 throw (ArrayIndexOutOfBounds)
00095 {
00096 if ((handle <= 0) || (handle > ranges.size()))
00097 throw ArrayIndexOutOfBounds("Invalid dimension handle");
00098 else
00099 ranges[handle - 1].second = val ;
00100 }
00101
00102
00105 size_t
00106 Extent::size() const
00107 {
00108 return ranges.size();
00109 }
00110
00111
00114 bool
00115 Extent::overlaps(const Extent &e) const
00116 {
00117 for (unsigned int i = 1 ; i <= size(); ++i) {
00118 D[pdTrace] << e.getRangeLowerBound(i) << " < " << getRangeUpperBound(i)
00119 << " or " << e.getRangeUpperBound(i) << " < "
00120 << getRangeLowerBound(i) << " ?" << std::endl ;
00121 if (e.getRangeLowerBound(i) > getRangeUpperBound(i) ||
00122 e.getRangeUpperBound(i) < getRangeLowerBound(i))
00123 return false ;
00124 }
00125 return true ;
00126 }
00127
00128 }
00129
00130