class Serializable

Serializable objects can save and restore themselves from Serializers and Deserializers. More...

Full namefun::Serializable
Definition#include <fun/Serializable.h>
Inheritsfun::LoadableClass [public ]
Inherited byConfigFile, Describable, DieRoll, KeyValuePair, Nameable, PropertyList, SerializableList, SimpleCLParser
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Serializable objects can save and restore themselves from Serializers and Deserializers.

As a Serializable is a LoadableClass, somewhere in the source file for class Foo, you need this line:

INITIALIZER(Foo);

You also want to make sure the serialize() method for the Foo class has the line

ser.setSerializableClass("Foo");

after calling any base class serialize() methods.

See Serializer and Deserializer for methods for storing and retrieving elements from (S|Des)erializers, and for examples.

Right now, there's no error handling during loading etc.; this should throw exceptions.

 Serializable ()

Serializable

 ~Serializable ()

~Serializable

[virtual]

void  deserialize (const Deserializer &)

deserialize

[virtual]

Loads the Serializable object (and any sub-objects) from the given Deserializable.

Derived classes should always start by calling the superclass' deserialize().

THIS IS NONSENSE For example, suppose you had a simple XML file:

2 17 Mean/hungry

Calling getTreeable("bunny") would cause a new instance of DevilBunny to be created (and the class to be loaded from a shared object, if necessary), and the new instance would be loaded from the bunny XML node. See Treeable for more information, but presumably DevilBunny::loadFromTree() would look something like this:

void DevilBunnyBox::deserialize(const Deserializer &node) { Serializable::deserialize(node); xpos = node.getInt("xpos"); ypos = node.getInt("ypos"); disp = node.getString("disposition"); // maybe some error checking, or loading other stuff }

void  serialize (Serializer &)

serialize

[const virtual]

Stores the Serializable object in the given Serializer.

Derived classes should always start by calling the superclass' serialize(). They should also call setSerializableClass() with their own class name. NOT_DONE include a simple example here.


Generated by: stephan on cheyenne on Mon Aug 11 14:06:52 2003, using kdoc 2.0a54.