- template<typename C>
- class Creator: public CreatorBase
- {
- public:
- typedef T *(C::*FuncPtr)(const std::string &);
-
- private:
- FuncPtr func;
-
- public:
- Creator(FuncPtr f): func(f) { }
-
- virtual T *create(Collection &coll, const std::string &name) const
- { return (static_cast<C &>(coll).*func)(name); }
- };
-
- class StoreBase
- {
- protected:
- StoreBase() { }
- public:
- virtual ~StoreBase() { }
-
- virtual void store(Collection &, const std::string &, T *) = 0;
-
- virtual void add_to_loader(Collection::Loader &, const std::string &) = 0;
- };
-
- template<typename S>
- class Store: public StoreBase
- {
- public:
- virtual void store(Collection &coll, const std::string &name, T *obj)
- { coll.add(name, static_cast<S *>(obj)); }
-
- virtual void add_to_loader(Collection::Loader &loader, const std::string &kwd)
- { loader.add(kwd, &Collection::Loader::item<T, S>); }
- };
-
- CreatorBase *creat;
- StoreBase *store;
+ std::function<T *(const std::string &)> create_func;
+ std::vector<std::function<void(const std::string &, T &)>> notify_funcs;