Lately I've been working on a RTTI streaming system.
Similar in to the VCL streaming system, it allows for the loading & saving of an object's published properties.
The code is inspirered by Superpig's "Enginuity" article series on gamedev.net
This is still in the early stages, and really isnt ready for a public release.
Features:
- Allows the streaming of published properties
- Correctly detects if a property are readable and/or writeable!
- Delayed biulding of an object's property list till the object is actually touched/used
- Handles nil object properties properly.
- Allows the setting of an objects properties or the object itself
- Creation of 'virtual' properties. Which dont actual map to a real property.
- Does not require an object inherites from a class, only that it has published properties with typeinfo
- Supports non-object variables.
- Does not use the VCL.
Limtations:Code:type TMyObject = class protected fz : boolean; ftest : TMyObject; Published Property test : TMyObject read ftest write ftest; Property z : boolean read fz write fz; end; {TMyObject} SettingsManager.Variable[ 'MyObject.test' ] := 'MyObject'; SettingsManager.Variable[ 'MyObject.z' ] := 'true'; SettingsManager.Variable[ 'MyObject.test.z' ] := 'false'; SettingsManager.Variable[ 'MyObject' ] := '( z = true; test = ( z = false; ) )';
- Makes the assumption that any published object properties are managed by the class. And if they are writeable, then they can be assigned with a different object! So dont make the published property writable if it will cause a memory leak if you assign an object to it.
- Any virtual properties are destroyed when an object refreshes its propery list (ie "MyObject.text := MyObject" will destroy any virtual properties on "MyObject.text") and NOT assign any virtual properties "MyObject" has.
Working on this issue.- Does not allow for array based properties.
- If an object which is wrapped is destroyed, the wrapping system probable will implode.
- Cant clear all the wrapper's at once atm (next version will have this)
- Outputs/reads a flexible, but fixed format. Want to change this.
- Collections cant be streamed atm. Planing on designing a way. Probable an interface which allows the system to itterate of child objects the parent object owns & create new child objects.
- Published interfaces?
- Published event handlers?
Planned features:
- Allow name resolution for non-object types ie "MyObject.test.z = MyObject.z"
- Allow array types to be properly handled
- Allow array indexing to be handled
- Some way to detected/informed when underlying object gets destroyed (preferable someway that doesnt require active registration)
- Allow the streaming system to itterate over collections (will require the collection class to implement somethign to allow for this)
- Allow resolution of published events from object -> name in settings tree if possible.
Link.
Comments?
:edit2: Updated link to newest version.
Bookmarks