{ };
+class TestSource: public DataFile::CollectionSource
+{
+public:
+ virtual bool is_loadable(const DataFile::CollectionItemTypeBase &, const std::string &) const;
+ virtual NameList get_names(const DataFile::CollectionItemTypeBase &) const;
+ virtual void load(DataFile::Collection &, const DataFile::CollectionItemTypeBase &, const std::string &) const;
+};
+
+
class TestCollection: public DataFile::Collection
{
+private:
+ TestSource source;
+
public:
TestCollection();
EXPECT_EQUAL(ccoll->get<Foo>("b").get_tag(), 2);
EXPECT_EQUAL(ccoll->get<Bar>("c").get_tag(), 3);
EXPECT_EQUAL(ccoll->get<Bar>("d").get_tag(), 4);
+ EXPECT_EQUAL(ccoll->get<Sub>("d").get_tag(), 4);
}
void CollectionTests::nonexistent()
}
+bool TestSource::is_loadable(const DataFile::CollectionItemTypeBase &, const string &name) const
+{
+ return name=="f";
+}
+
+DataFile::CollectionSource::NameList TestSource::get_names(const DataFile::CollectionItemTypeBase &) const
+{
+ NameList names;
+ names.push_back("f");
+ return names;
+}
+
+void TestSource::load(DataFile::Collection &coll, const DataFile::CollectionItemTypeBase &, const string &name) const
+{
+ if(name=="f")
+ coll.add("f", new Foo);
+}
+
+
TestCollection::TestCollection()
{
add_type<Foo>().keyword("foo").creator(&TestCollection::create_foo);
add_type<Bar>().keyword("bar");
- add_type<Sub>().keyword("sub").store_as<Bar>();
- add_future<Foo>("f");
+ add_type<Sub>().keyword("sub").base<Bar>();
+ add_source(source);
}
Foo *TestCollection::create_foo(const string &)