Task #1202
closedshortcuts between FIB, PIT, Measurements, StrategyChoice
Description
Add shortcuts between conceptual tables backed by NameTree.
API¶
Fib::findLongestPrefixMatch(const pit::Entry&)
Fib::findLongestPrefixMatch(const measurements::Entry&)
StrategyChoice::findEffectiveStrategy(const pit::Entry&)
Measurements::get(const pit:*Entry&)
Design¶
xx::Entry needs to declare in "private:" section:
shared_ptr<name_tree::Entry> m_nameTreeEntry; friend class NameTree; friend class name_tree::Entry;
name_tree::Entry
methods should set m_nameTreeEntry member when xx::Entry is attached, and unset when xx::Entry is detached (don’t forget to unset on the old attached xx::Entry when attaching a new FIB/Measurements/StrategyChoice entry)NameTree::get(const xx::Entry&) const
returns m_nameTreeEntry. This is called byFib::findLongestPrefixMatch(const pit::Entry&)
and other methods, so Fib/etc needn’t be made friends of pit::Entry.Implement Fib::findLongestPrefixMatch overload, etc, by going through the NameTree entries.
Updated by Junxiao Shi almost 11 years ago
- Due date deleted (
02/19/2014) - Start date deleted (
02/19/2014)
Updated by Junxiao Shi almost 11 years ago
FIB/PIT/Measurements entry should contain shared_ptr<NameTree>
.
I suggest an API like:
namespace name_tree {
class Entry;
}
namespace fib {
class Entry {
private:
shared_ptr<name_tree::Entry> m_nameTreeNode;
friend class NameTree;
};
}
namespace pit {
class Entry {
private:
shared_ptr<name_tree::Entry> m_nameTreeNode;
friend class NameTree;
};
}
namespace measurements {
class Entry {
private:
shared_ptr<name_tree::Entry> m_nameTreeNode;
friend class NameTree;
};
}
class NameTree
{
shared_ptr<name_tree::Entry> get(const fib::Entry& fibEntry);
shared_ptr<name_tree::Entry> get(const pit::Entry& pitEntry);
shared_ptr<name_tree::Entry> get(const measurements::Entry& measurementsEntry);
};
Updated by Haowei Yuan almost 11 years ago
I think the following three functions could be implemented at each fib/pit/measurements-entry.hpp, and probably should not in NameTree class.
shared_ptr<name_tree::Entry> get(const fib::Entry& fibEntry);
shared_ptr<name_tree::Entry> get(const pit::Entry& pitEntry);
shared_ptr<name_tree::Entry> get(const measurements::Entry& measurementsEntry);
Updated by Junxiao Shi almost 11 years ago
My idea is, forwarding/strategy should not know about name_tree::Entry
. Therefore, it's a private field, and class NameTree
is a friend.
Updated by Alex Afanasyev almost 11 years ago
Yes, name_tree/NameTree is "internal optimization" that should not be really exposed in the interface, unless there is a very good reason to do so.
Updated by Haowei Yuan almost 11 years ago
Yes, the NameTree should not be exposed in the interface to /fw or /strategy.
What I was trying to say is, if the shared_ptr<name_tree::Entry> get(const fib::Entry& fibEntry);
is used only internally in fib/pit/measurements.cpp, then it is probably easier to just return fib->m_nameTreeEntry
or fib->getNameTreeEntry()
, since you already have the fibEntry pointer. (alternatively, you could call m_nameTree->get(fibEntry)
, which then returns fibEntry->m_nameTreeEntry
). It shouldn't matter much in this case...
The nice part of having these three functions in NameTree is that the interface get()
is simple and unified.
Updated by Junxiao Shi almost 11 years ago
pit::Entry::m_nameTreeEntry
is not only used by Pit.
Measurements::get(pit::Entry)
would like to get the name_tree::Entry
from PIT entry, and follow the pointer to find Measurements entry.
However, it's strange to make class Measurements
a friend of pit::Entry
, therefore this should go through NameTree::get
.
Updated by Junxiao Shi almost 11 years ago
- Subject changed from shortcuts between FIB, PIT, Measurements to shortcuts between FIB, PIT, Measurements, StrategyChoice
- Description updated (diff)
- Assignee set to Tian Song
Updated by Tian Song almost 11 years ago
- Status changed from In Progress to Code review
- % Done changed from 50 to 80
Updated by Tian Song almost 11 years ago
- Status changed from Code review to Closed
- % Done changed from 80 to 100