00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/router/RouterHeuristicBase.hpp $ 00003 // $Id: RouterHeuristicBase.hpp 1 2011-02-25 22:11:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the HeuristicBase class. 00018 00019 #ifndef TORC_ROUTER_ROUTERHEURISTICBASE_HPP 00020 #define TORC_ROUTER_ROUTERHEURISTICBASE_HPP 00021 00022 #include "torc/architecture/DDB.hpp" 00023 #include <boost/unordered_map.hpp> 00024 #include <boost/any.hpp> 00025 00026 00027 namespace torc { 00028 namespace router { 00029 00030 /// \brief Provides the interface for net routers. 00031 class RouterHeuristicBase { 00032 // types 00033 /// \brief Imported type names 00034 typedef architecture::DDB DDB; 00035 typedef boost::unordered_map<boost::uint32_t, boost::any> ParameterMap; 00036 00037 protected: 00038 // members 00039 /// \brief Database reference. 00040 DDB& mDB; 00041 /// \brief Parameter map. 00042 ParameterMap mParameters; 00043 00044 public: 00045 // constructor 00046 /// \brief Public Constructor 00047 RouterHeuristicBase(DDB& inDB) : mDB(inDB) {} 00048 /// \brief Destructor. 00049 virtual ~RouterHeuristicBase() {} 00050 00051 /// \brief Get a parameter. 00052 boost::any getParameter(boost::uint32_t index) { 00053 ParameterMap::iterator p = mParameters.find(index); 00054 if (p != mParameters.end()) { 00055 return p->second; 00056 } 00057 return boost::any(); 00058 } 00059 /// \brief Set a parameter. 00060 void setParameter(boost::uint32_t index, boost::any inParameter) { 00061 mParameters[index] = inParameter; 00062 } 00063 /// \brief Do something with the parameters. 00064 virtual void processParameters() {} 00065 00066 }; 00067 00068 } // namespace router 00069 } // namespace torc 00070 00071 #endif // TORC_ROUTER_ROUTERHEURISTICBASE_HPP