class DirectoryCollection: public Collection
{
private:
+ template<typename T, bool = NeedsCollection<typename T::Loader>::value>
+ class ItemLoader;
+
std::list<FS::Path> dirs;
public:
if(lookup_file(name, file))
{
RefPtr<T> item = new T;
- load(*item, file.str());
+ ItemLoader<T> ldr(*item, *this);
+ IO::BufferedFile in(file.str());
+ Parser parser(in, file.str());
+ ldr.load(parser);
return item.release();
}
else
bool lookup_file(const std::string &, FS::Path &) const;
};
+template<typename T>
+class DirectoryCollection::ItemLoader<T, false>: public T::Loader
+{
+public:
+ ItemLoader(T &o, Collection &):
+ T::Loader(o)
+ { }
+};
+
+template<typename T>
+class DirectoryCollection::ItemLoader<T, true>: public T::Loader
+{
+public:
+ ItemLoader(T &o, Collection &c):
+ T::Loader(o, dynamic_cast<typename T::Loader::Collection &>(c))
+ { }
+};
+
} // namespace DataFile
} // namespace Msp