After having thought on the db approach, I’ve envised some critical points, that could be put in the discussion.
Developer are facing generally the problem of speed when doing searches, for which a relational db like sqlite is tailored for this scope, so qhy not leverage his power in doing such things.
Said so the main concern of a developer could be “the binary format could lead to data corruption”, the answer is yes.
But if we are dealing with thousand of objects maybe a search would be using much horsepower, using the object directly.
Why not leveraging the power of sqlite to construct some “pivot table” between relevant data and the real objects?
think a document with thousand of objects, and maybe you will search for a particular object that have one property that interest you.
maybe simply you want to find all objects, with a particular name or whose position is between a min point and a max point.
if you build a table containing the object data and the object relevant reference, like this:
CREATE TABLE objects (Id INTEGER PRIMARY KEY, name, fcid, label, bbmin, bbmax, … )
fcid is the internal FreeCAD id number, or maybe the unique name property, i.e the identifier for this objects that permit to retrieve it correctly by the subsequent code.
then you make a slection like:
SELECT * FROM objects WHERE name LIKE “whatyouwant” AND bbmin > yourminpos AND bbmax < yourmaxpos"
you will find all the relevant object and maybe load in memory only these objects.
This pivot table could be stored in the file, or maybe build at the loading of file.
Same thing should be done with annotations, maybe an XML file, or a csc file could hold the data (for an easy “crash recovery”) and a pivot table stored in the file, or rebuild on loading.
eventually a mean to rebuild such tables could be supplied.
When dealing with thousand of objects, this will be a correct approach, a similar approach is used in BRL-CAD (I know it is jurassic but it have been built for dealing with complex objects) it use a database for holding all the 3d objects and use this when for example it id doing ballistic analysis (it was build by the US army in fact his name mean Ballistic Research Laboratory - CAD).
Anyone who has programmed a complex search could catch the amount of work needed to put in place a query, with sqlite is only matter of doing a query and iterate through the resulting list of database rows, not telling that the selct could only return the relevant internal id to retrieve the objects, using:
SELECT fcid from objects …
Regards
Carlo D.