Hi Gerrit, All,

Gerrit Voss wrote:
In general I would try to work out the general infrastructure things
(compression/encryption/caching) first and than, as a last step
do this transition.

ok, here is what I've come up with. It goes along the lines of what is on the wiki. One thing it does not attempt to solve are external loaders (in our case that currently means Collada), they can get some of the benefits of the infrastructure, but they are clearly second class citizens.

I imagine the basic usage to be something like this:

// /home/user/models contains e.g. vehicles/racecar.wrl.gz and
// /somedir/modellib.zip contains e.g. buildings/townhouse.wrl

ContentResolverRefPtr cr = ContentResolver::create();
cr->addMount(
  FSContentProvider::create("/home/user/models"), "/");
cr->addMount(
  ZIPContentProvider::create("/somedir/modellib.zip"), "/");

NodeRefPtr model1 = cr->read<Node>("/buildings/townhouse.wrl");
NodeRefPtr model2 = cr->read<Node>("/vehicles/racecar.wrl.gz");


There are the following elements involved:

ContentResolver has two functions: it maintains a VFS where ContentProviders are mounted in a virtual directory tree and secondly it holds a map of file types (or file extensions) to FiletypeHandler objects (these can each read a specific file format). It also holds a pointer to a Cache object and every read request first queries the cache, whether it can satisfy the request.

ContentProvider is a archive or directory in the VFS tree and can create handles to files in that archive/directory. abstract.

FileHandle is a means to access a file, i.e. to create a stream that reads or writes to that file. abstract. For each concrete ContentProvider type there will be at least one concrete FileHandle type.

FiletypeHandler is essentially a unification of what today is called SceneFileType/ImageFileType. It accepts a FileHandle to read/write to the streams the handle can create. If the FiletypeHandler needs real files (because it uses external libs like Collada) it can try to fallback to openReadLocal() etc. Compression/Encryption would be registered as FiletypeHandlers that internally wrap one FileHandle with another and then query the ContentResolver again for a handler (this time one level of extensions is removed from the filename).


Attached is some "code", well honestly just some classes I wrote down to see how they interact and whether this has a chance of working, but maybe it gives you an idea of what is meant to happen ;)

Looking forward to comments/suggestions :)

        Thanks,
                Carsten

Attachment: FileIO.tar.gz
Description: GNU Zip compressed data

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to