1 #ifndef MSP_DATAFILE_OBJECTLOADER_H_
2 #define MSP_DATAFILE_OBJECTLOADER_H_
10 class no_collection: public std::runtime_error
13 no_collection(const std::type_info &);
19 Provides the basic functionality of an object loader. Deriving from this
20 allows loading values directly into member variables of the objects.
23 class ObjectLoader: virtual public Loader
31 ObjectLoader(O &o): obj(o) { }
34 O &get_object() const { return obj; }
39 Convenience class for loading derived objects. Inherits from the base class
40 loader and shadows its members with ones for the derived type.
42 template<typename O, typename B>
43 class DerivedObjectLoader: public B
51 DerivedObjectLoader(O &o): B(o), obj(o) { }
54 DerivedObjectLoader(O &o, T &a): B(o, a), obj(o) { }
57 O &get_object() const { return obj; }
62 Provides functionality for loading objects with a Collection. Deriving from
63 this allows loading pointers to objects in the collection automatically.
65 template<typename O, typename C = Collection>
66 class CollectionObjectLoader: public ObjectLoader<O>
74 CollectionObjectLoader(O &o, C *c): ObjectLoader<O>(o), coll(c) { }
77 C &get_collection() const
80 throw no_collection(typeid(O));
85 } // namespace DataFile