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/architecture/Arc.hpp $ 00003 // $Id: Arc.hpp 10 2011-10-12 18:40: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 Arc class. 00018 00019 #ifndef TORC_ARCHITECTURE_ARC_HPP 00020 #define TORC_ARCHITECTURE_ARC_HPP 00021 00022 #include "torc/architecture/Tilewire.hpp" 00023 00024 namespace torc { 00025 namespace architecture { 00026 00027 /// \brief Encapsulation of an arc between two tilewires. 00028 class Arc { 00029 protected: 00030 // members 00031 /// \brief The source tilewire. 00032 Tilewire mSourceTilewire; 00033 /// \brief The sink tilewire. 00034 Tilewire mSinkTilewire; 00035 public: 00036 // constructors 00037 /// \brief Null constructor. 00038 /// \details The source and sink tilewires will be set to Tilewire::sInvalid. 00039 Arc(void) : mSourceTilewire(), mSinkTilewire() {} 00040 /// \brief Public constructor. 00041 Arc(const Tilewire& inSourceTilewire, const Tilewire& inSinkTilewire) 00042 : mSourceTilewire(inSourceTilewire), mSinkTilewire(inSinkTilewire) {} 00043 // accessors 00044 /// \brief Returns the source tilewire. 00045 const Tilewire& getSourceTilewire(void) const { return mSourceTilewire; } 00046 /// \brief Returns the sink tilewire. 00047 const Tilewire& getSinkTilewire(void) const { return mSinkTilewire; } 00048 // operators 00049 /// \brief Comparison operator. 00050 bool operator ==(const Arc& rhs) const { 00051 return mSourceTilewire == rhs.mSourceTilewire && mSinkTilewire == rhs.mSinkTilewire; 00052 } 00053 // functions 00054 bool isUndefined(void) const { 00055 return mSourceTilewire.isUndefined() || mSinkTilewire.isUndefined(); 00056 } 00057 // friends 00058 /// \brief Return a hash value for the specified arc. 00059 friend std::size_t hash_value(const Arc& inArc); 00060 }; 00061 00062 class InvalidArcException { 00063 public: 00064 // members 00065 Arc mArc; 00066 // constructors 00067 InvalidArcException(const Arc& inArc) : mArc(inArc) {} 00068 }; 00069 00070 /// \brief Vector of Arc objects. 00071 typedef std::vector<Arc> ArcVector; 00072 00073 } // namespace architecture 00074 } // namespace torc 00075 00076 #endif // TORC_ARCHITECTURE_ARC_HPP