00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TORC_ROUTER_ROUTENODE_HPP
00020 #define TORC_ROUTER_ROUTENODE_HPP
00021
00022 #include "torc/architecture/Arc.hpp"
00023 #include "torc/common/EncapsulatedInteger.hpp"
00024 #include <boost/cstdint.hpp>
00025 #include <functional>
00026
00027 namespace torc {
00028 namespace router {
00029
00030
00031
00032
00033 #ifdef __GNUC__
00034 #pragma pack(push, 2)
00035 #endif
00036
00037
00038
00039
00040 class RouteNode {
00041 protected:
00042
00043
00044 typedef architecture::Tilewire Tilewire;
00045
00046 typedef architecture::Arc Arc;
00047 protected:
00048
00049
00050 architecture::Arc mArc;
00051
00052 boost::int32_t mCost;
00053
00054 boost::int32_t mPathCost;
00055
00056 boost::int32_t mDepth;
00057
00058 RouteNode* mParent;
00059 public:
00060
00061
00062 RouteNode() : mArc(), mCost(0), mPathCost(0), mDepth(-1), mParent(0) {}
00063
00064 RouteNode(Tilewire inSource, Tilewire inSink, boost::int32_t inDepth, RouteNode* inParent)
00065 : mArc(inSource, inSink), mCost(0), mPathCost(0), mDepth(inDepth), mParent(0) {}
00066
00067 RouteNode(Tilewire inSource, Tilewire inSink, boost::int32_t inCost,
00068 boost::int32_t inPathCost, boost::int32_t inDepth, RouteNode* inParent)
00069 : mArc(inSource, inSink), mCost(inCost), mPathCost(inPathCost), mDepth(inDepth),
00070 mParent(inParent) {}
00071
00072 RouteNode(Arc inArc, boost::int32_t inDepth, RouteNode* inParent)
00073 :mArc(inArc), mCost(0), mPathCost(0), mDepth(inDepth), mParent(inParent) {}
00074
00075 RouteNode(Arc inArc, boost::int32_t inCost, boost::int32_t inPathCost,
00076 boost::int32_t inDepth, RouteNode* inParent) : mArc(inArc), mCost(inCost),
00077 mPathCost(inPathCost), mDepth(inDepth), mParent(inParent) {}
00078
00079
00080 const Arc& getArc() const { return mArc; }
00081
00082 const Tilewire& getSourceTilewire() const { return mArc.getSourceTilewire(); }
00083
00084 const Tilewire& getSinkTilewire() const { return mArc.getSinkTilewire(); }
00085
00086 const boost::int32_t getCost() const { return mCost; }
00087
00088 void setCost(boost::int32_t inHeuristicCost) { mCost = inHeuristicCost; }
00089
00090 const boost::int32_t getPathCost() const { return mPathCost; }
00091
00092 void setPathCost(boost::int32_t inPathCost) { mPathCost = inPathCost; }
00093
00094 const boost::int32_t getDepth() const { return mDepth; }
00095
00096 void setDepth(boost::int32_t inDepth) { mDepth = inDepth; }
00097
00098 RouteNode* getParent() const { return mParent; }
00099
00100 RouteNode* getTop() {
00101 RouteNode* top = this;
00102 while (top->mParent != 0) top = top->mParent;
00103 return top;
00104 }
00105 bool operator< (const RouteNode* rhs) const {
00106 return (mCost < rhs->mCost);
00107 }
00108 };
00109
00110 #ifdef __GNUC__
00111 #pragma pack(pop)
00112 #endif
00113
00114
00115 typedef std::vector<RouteNode*> RouteNodePtrVector;
00116
00117
00118 class RouteNodePtrCostCompare : std::binary_function<RouteNode*, RouteNode*, bool> {
00119 public:
00120 bool operator() (const RouteNode* a, const RouteNode* b) const {
00121 return (a->getCost() > b->getCost());
00122 }
00123 };
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 }
00134 }
00135
00136 #endif // TORC_ROUTER_ROUTENODE_HPP