1 #ifndef MSP_DATAFILE_OBJECTLOADER_H_
2 #define MSP_DATAFILE_OBJECTLOADER_H_
13 Provides the basic functionality of an object loader. Deriving from this
14 allows loading values directly into member variables of the objects.
17 class ObjectLoader: virtual public Loader
25 ObjectLoader(O &o): obj(o) { }
28 O &get_object() const { return obj; }
33 Convenience class for loading derived objects. Inherits from the base class
34 loader and shadows its members with ones for the derived type.
36 template<typename O, typename B>
37 class DerivedObjectLoader: public B
45 template<typename... Args>
46 DerivedObjectLoader(O &o, Args &&... a): B(o, std::forward<Args>(a)...), obj(o) { }
49 O &get_object() const { return obj; }
54 Provides functionality for loading objects with a Collection. Deriving from
55 this allows loading pointers to objects in the collection automatically.
57 template<typename O, typename C = Collection>
58 class CollectionObjectLoader: public ObjectLoader<O>
66 CollectionObjectLoader(O &o, C *c): ObjectLoader<O>(o), coll(c) { }
69 C &get_collection() const
72 throw no_collection(typeid(O));
77 } // namespace DataFile