adapter interface for the test-entry

This commit is contained in:
Fischlurch 2010-04-25 15:15:53 +02:00
parent 3c35e2a95f
commit bf02d6d03f
2 changed files with 41 additions and 3 deletions

View file

@ -108,22 +108,46 @@ namespace advice {
template<class POA>
class Index
{
typedef pair<Binding::Matcher, POA*> Entry;
struct Entry
: pair<Binding::Matcher, POA*>
{
Entry (POA& elm)
: pair<Binding::Matcher, POA*> (getMatcher(elm), &elm)
{ }
friend bool
operator== (Entry const& a, Entry const& b)
{
return a.second == b.second;
}
friend bool
operator!= (Entry const& a, Entry const& b)
{
return a.second != b.second;
}
};
typedef vector<Entry> EntryList;
class Cluster
{
EntryList elms_;
public:
void
append (POA& elm)
{
Entry entry (getMatcher(elm), &elm);
Entry entry (elm);
REQUIRE (!contains (elms_, entry));
elms_.push_back(entry);
}
};
struct RequestCluster
: Cluster
{
@ -158,7 +182,7 @@ namespace advice {
addRequest (POA& entry)
{
HashVal key (hash_value(entry));
requestEntries_[key].add (entry);
requestEntries_[key].append (entry);
provisionEntries_[key].publish_latest_solution (entry);
}

View file

@ -79,6 +79,20 @@ namespace test {
}
/* == Adapter interface for use within the Index == */
friend HashVal
hash_value (TestPOA const& entry)
{
return hash_value (entry.pattern_);
}
friend const Binding::Matcher
getMatcher (TestPOA const& entry)
{
return entry.pattern_;
}
friend TestPOA*
getSolution (TestPOA& entry)
{