BaseRegion.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 // CERTI - HLA RunTime Infrastructure
00003 // Copyright (C) 2002-2005  ONERA
00004 //
00005 // This file is part of CERTI-libRTI
00006 //
00007 // CERTI-libRTI is free software ; you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License
00009 // as published by the Free Software Foundation ; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // CERTI-libRTI is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY ; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015 // Lesser General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this program ; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00020 // USA
00021 //
00022 // $Id: BaseRegion.cc,v 3.5 2007/07/06 09:25:18 erk Exp $
00023 // ----------------------------------------------------------------------------
00024 
00025 
00026 #include "BaseRegion.hh"
00027 
00028 using std::vector ;
00029 
00030 namespace certi {
00031 
00032 // ----------------------------------------------------------------------------
00033 BaseRegion::BaseRegion(RegionHandle h)
00034     : Handled<RegionHandle>(h)
00035 {
00036 }
00037 
00038 // ----------------------------------------------------------------------------
00039 BaseRegion::~BaseRegion()
00040 {
00041 }
00042 
00043 // ----------------------------------------------------------------------------
00044 ULong
00045 BaseRegion::getNumberOfExtents() const
00046     throw ()
00047 {
00048     return extents.size();
00049 }
00050 
00051 // ----------------------------------------------------------------------------
00052 ULong
00053 BaseRegion::getRangeLowerBound(ExtentIndex index,
00054                    DimensionHandle dimension) const
00055     throw (ArrayIndexOutOfBounds)
00056 {
00057     if (index >= extents.size()) {
00058         throw ArrayIndexOutOfBounds("Extent index above limit");
00059     }
00060     else {
00061         return extents[index].getRangeLowerBound(dimension);
00062     }
00063 }
00064 
00065 // ----------------------------------------------------------------------------
00066 ULong
00067 BaseRegion::getRangeUpperBound(ExtentIndex index,
00068                    DimensionHandle dimension) const
00069     throw (ArrayIndexOutOfBounds)
00070 {
00071     if (index >= extents.size()) {
00072         throw ArrayIndexOutOfBounds("Extent index above limit");
00073     }
00074     else {
00075         return extents[index].getRangeUpperBound(dimension);
00076     }
00077 }
00078 
00079 // ----------------------------------------------------------------------------
00080 void
00081 BaseRegion::setRangeLowerBound(ExtentIndex index,
00082                    DimensionHandle dimension,
00083                    ULong val)
00084     throw (ArrayIndexOutOfBounds)
00085 {
00086     if (index >= extents.size()) {
00087         throw ArrayIndexOutOfBounds("Extent index above limit");
00088     }
00089     else {
00090         extents[index].setRangeLowerBound(dimension, val);
00091     }
00092 }
00093 
00094 // ----------------------------------------------------------------------------
00095 void
00096 BaseRegion::setRangeUpperBound(ExtentIndex index,
00097                    DimensionHandle dimension,
00098                    ULong val)
00099     throw (ArrayIndexOutOfBounds)
00100 {
00101     if (index >= extents.size()) {
00102         throw ArrayIndexOutOfBounds("Extent index above limit");
00103     }
00104     else {
00105         extents[index].setRangeUpperBound(dimension, val);
00106     }
00107 }
00108 
00109 // ----------------------------------------------------------------------------
00113 const vector<Extent> &
00114 BaseRegion::getExtents() const
00115 {
00116     return extents ;
00117 }
00118 
00119 // ----------------------------------------------------------------------------
00120 void
00121 BaseRegion::setExtents(const std::vector<Extent> &e)
00122 {
00123     extents = e ;
00124 }
00125 
00126 // ----------------------------------------------------------------------------
00127 // Replace extents
00128 void
00129 BaseRegion::replaceExtents(const std::vector<Extent> &e)
00130     throw (InvalidExtents)
00131 {
00132     if (e.size() != extents.size())
00133     throw InvalidExtents("Different number of extents");
00134 
00135     extents = e ;
00136 }
00137 
00138 // ----------------------------------------------------------------------------
00141 bool
00142 BaseRegion::overlaps(const BaseRegion &region) const
00143 {
00144     if (getSpaceHandle() != region.getSpaceHandle()) {
00145     return false ;
00146     }
00147 
00148     for (unsigned int i = 0 ; i < getNumberOfExtents() ; ++i) {
00149     for (unsigned int j = 0 ; j < region.getNumberOfExtents(); ++j) {
00150         if (extents[i].overlaps(region.extents[j]))
00151         return true ;
00152     }
00153     }
00154     return false ;
00155 }
00156 
00157 } // namespace certi
00158 
00159 // $Id: BaseRegion.cc,v 3.5 2007/07/06 09:25:18 erk Exp $

Generated on Thu Apr 30 15:53:48 2009 for CERTIDeveloperDocumentation by doxygen 1.5.5