Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Object Interfaces and Interface Proxies

Classes derived from simdata::Object can define interfaces that allow runtime introspection and assignment of specified member variables. Such interfaces are used by the data compiler to bind XML data to class instances, which are then serialized to create a binary data archive. Objects can later be deserialized from the archive to create instances that are preloaded with the data originally specified in XML.

The ObjectInterface class is the primary, internal interface to an Object subclass. ObjectInterface instances, in turn, rely on the MemberAccessorBase class and its derivatives to access individual member variables. None of these classes are created directly by the user. Instead, a series of macros are used in the declaration of any class derived from simdata::Object to declare an InterfaceProxy class. See Object Interface Macros for a detailed discussion of these macros. The net effect is to create an inner class derived from InterfaceProxy, of which a single instance is created. This instance is created during static construction, and automatically registers itself with the SimData InterfaceRegistry. Any registered InterfaceProxy can be accessed through the registry by specifying the corresponding class name.

The InterfaceProxy classes act as both object factories and member accessors. New instances of the corresponding Object classes can be created dynamically, and data members can be read and set by using string identifiers specified in the macros used to define the interface. Code using an InterfaceProxy needs to know nothing in advance about the corresponding object class. The interface provides a list of names of all accessible member variables, the data type of each variable, and methods to get and set the value of each member variable.

Structurally, when you use the macros provided to declare an InterfaceProxy for an Object class, you are defining a new class derived from InterfaceProxy. That class contains an ObjectInterface member variable, and each of the macros such as SIMDATA_XML(name, member, required) adds a new MemberAccessor instance to this interface. Most of the methods of InterfaceProxy are just thin wrappers around calls to the underlying ObjectInterface. In the case of inherited interfaces, however, calls to InterfaceProxy methods may propogate up the inheritance chain until an ObjectInterface is found to satisfy the request. If no matching interface is found, the base class InterfaceProxy defines default implementations (such as throwing an exception).


SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]