Saving C++ based data structures
Saving C++ based data structures
- Subject: Saving C++ based data structures
- From: Dan Price <email@hidden>
- Date: Mon, 5 Dec 2005 01:13:20 +0000 (GMT)
Greetings
I'm writing a rather complex 3D modeling application.
The interface code is standard Cocoa and Obj-C in a
document framework, but the guts of the program is C++
for the sake of speed, and overloaded operators etc
(it's quite Math heavy). I need to come up with a way
to save out the scene data to XML, but object-value
encoding is proving to be too inflexible. I have an
NSObject-based wrapper class, ShapeNode, which
maintains a pointer to a C++ class, Shape. The C++
class handles drawing to OpenGL, transformation etc.
ShapeNode has an NSMutableArray of child ShapeNodes.
The document object has a single ShapeNode, root,
which represents the top of the scene-graph hierarchy.
So I've got Obj-C wrappers, in an cocoa-style
NSMustableArray database, pointing to C++ objects.
Object-value encoding requires NSObject classes to
adhere to the Encoding protocol and must contain
standard accessors to the object data. But other than
basic stuff like name(), my interface code gets and
sets data to the C++ Shape object directly. ShapeNode
is just simple wrapper.
I could just write a routine in the document object
which visits every object and writes it's data
explicitly, but many of the C++ Shape subclasses have
unique properties (like float ratios and
feature-enablers specific to that object) which would
require the document class to know far too much about
them. I need a object-value encoding style system
where every object is simply asked to save itself and
load itself from the XML. Any ideas as to how I could
do this?
Sorry for the long post - I hope this makes sense.
___________________________________________________________
Yahoo! Model Search 2005 - Find the next catwalk superstars -
http://uk.news.yahoo.com/hot/model-search/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden