How to use XmlAdapters to implement Load and Store methods for a CLAM::Component. More...
Classes | |
class | CLAM::XMLAdapter< T > |
This class adapts to the XMLable interface any basic object. More... | |
class | CLAM::XMLArrayAdapter< T > |
This class adapts to the XMLable interface any array of basic objects. More... | |
class | CLAM::XMLComponentAdapter |
This class adapts to the XMLable interface any object that is a CLAM::Component. More... | |
class | CLAM::XMLIterableAdapter< T > |
This class adapts to the XMLable interface any STL like container of basic objects or CLAM::Component's. More... |
How to use XmlAdapters to implement Load and Store methods for a CLAM::Component.
When you are implementing StoreOn and LoadFrom for a given Component, you should choose one of those adapters to wrap the subitems to be stored on, or loaded from, the XmlStorage.
When you create an adapter, the adaptee is specified by the the first constructor parameters, so they are adapter dependant. The later two constructor parameters are always to indicate in which XML form the subitem will be stored or loaded.
MyAdapterClass( // Here goes the adaptee info , const char * name = NULL, bool beElement = false );
You can use them in the following form:
void StoreOn(CLAM::Storage & storage) const { SelectedAdapter adapter(subitem, "ElementName", true); storage.Store(adapter); } void LoadFrom(CLAM::Storage & storage) { SelectedAdapter adapter(subitem, "ElementName", true); if (!storage.Load(adapter)) { // error handling } }
For more information see the documentation for any concrete adapter class.