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: 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 O &get_object() const { return obj; }
59 Provides functionality for loading objects with a Collection. Deriving from
60 this allows loading pointers to objects in the collection automatically.
62 template<typename O, typename C = Collection>
63 class CollectionObjectLoader: public ObjectLoader<O>
71 CollectionObjectLoader(O &o, C *c): ObjectLoader<O>(o), coll(c) { }
74 C &get_collection() const
77 throw no_collection(typeid(O));
82 } // namespace DataFile