# RoutingSpace.cc

Go to the documentation of this file.

    00001 // ----------------------------------------------------------------------------
    00002 // CERTI - HLA RunTime Infrastructure
    00003 // Copyright (C) 2003-2005  ONERA
    00004 //
    00005 // This file is part of CERTI-libCERTI
    00006 //
    00007 // CERTI-libCERTI 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-libCERTI 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: RoutingSpace.cc,v 3.15 2008/06/12 07:39:49 erk Exp $
    00023 // ----------------------------------------------------------------------------
    00024
    00025
    00026 #include "RoutingSpace.hh"
    00027 #include "helper.hh"
    00028
    00029 #include <iostream>
    00030 #include <cassert>
    00031 #include <algorithm>
    00032
    00033 using std::vector ;
    00034 using std::cout ;
    00035 using std::endl ;
    00036 using std::string ;
    00037
    00038 namespace certi {
    00039
    00040 // ----------------------------------------------------------------------------
    00041
    00042 RoutingSpace::RoutingSpace() { }
    00043
    00044 // ----------------------------------------------------------------------------
    00045
    00046 RoutingSpace::~RoutingSpace() { }
    00047
    00048 // ----------------------------------------------------------------------------
    00049 void
    00050 RoutingSpace::addDimension(const Dimension &d)
    00051 {
    00052     dimensions.push_back(d);
    00053     assert(dimensions.back().getHandle() == dimensions.size());
    00054 }
    00055
    00056 // ----------------------------------------------------------------------------
    00057 void
    00058 RoutingSpace::display() const
    00059 {
    00060     cout << "RoutingSpace \"" << getName() << "\"" << endl ;
    00061 }
    00062
    00063 // ----------------------------------------------------------------------------
    00064 DimensionHandle
    00065 RoutingSpace::getDimensionHandle(std::string dimension_name) const
    00066     throw (NameNotFound)
    00067 {
    00068     vector<Dimension>::const_iterator it = std::find_if(
    00069     dimensions.begin(),
    00070     dimensions.end(),
    00071     NameComparator<Dimension>(dimension_name));
    00072
    00073     if (it == dimensions.end())
    00074     throw NameNotFound("");
    00075     else
    00076     return it->getHandle();
    00077 }
    00078
    00079 // ----------------------------------------------------------------------------
    00080 string
    00081 RoutingSpace::getDimensionName(DimensionHandle dimension_handle) const
    00082     throw (DimensionNotDefined)
    00083 {
    00084     vector<Dimension>::const_iterator it = std::find_if(
    00085     dimensions.begin(),
    00086     dimensions.end(),
    00087     HandleComparator<Dimension>(dimension_handle));
    00088
    00089     if (it == dimensions.end())
    00090     throw DimensionNotDefined("");
    00091     else
    00092     return it->getName();
    00093 }
    00094
    00095 // ----------------------------------------------------------------------------
    00096 size_t
    00097 RoutingSpace::size() const
    00098 {
    00099     return dimensions.size();
    00100 }
    00101
    00102 // ----------------------------------------------------------------------------
    00103 Extent
    00104 RoutingSpace::createExtent() const
    00105 {
    00106     Extent extent(size());
    00107
    00108     vector<Dimension>::const_iterator it ;
    00109     for (it = dimensions.begin(); it != dimensions.end(); ++it) {
    00110     Handle h = it->getHandle();
    00111     extent.setRangeLowerBound(h, it->getLowerBound());
    00112     extent.setRangeUpperBound(h, it->getUpperBound());
    00113     }
    00114
    00115     return extent ;
    00116 }
    00117
    00118 } // namespace certi
    00119
    00120 // $Id: RoutingSpace.cc,v 3.15 2008/06/12 07:39:49 erk Exp $