How to manage the loading process
Ideal
Use cases
- Filename is in the filesystem namespace. Fileformat identified by file contents.
- Filename implies a set of files. Files are in the filesystem. The
existence of the files triggers full attempt to load files. The file
contents confirm the filetype.
- Filename is URL. The file contents identify format.
- URL
implies a set of files. The existence of the resources triggers full
attempt to load files. The file contents confirm the filetype.
- Filename describes image in entirety
- A loader plugin can take a filestream.
- A loader plugin can take a filename, and recursively issue another load command
- A loader plugin may need to know the filename while taking a filestream?
Design
Several lists of loaders.
- First list decides what to do purely on basis of filename, and includes.
- filename encoded image loader
- Image cache plugins
- URL Loader loads into memory, and passes stream to level 2
- File loader creates file stream, and passes to level 2
- Second List takes stream and filename.
- Simple file format loaders.
- File format loader that then needs to load subsequent files
Practical
This is getting too messy. Instead we will start with a single list of loaders,
that will each get a chance to load an image based on a filepath. In all other
respects the loader should be like the vil loader. It should load an image view
by
- Passing the filename (not open stream as in vil) to a sequence of loaders
- Each loader should attempt to determine relatively quickly if it can load
the filename
- The actual filename(s) to be loaded can be inferred from the filename -
they need not match precisely.
- As a loader attempts to read the file, it can abort at any time, by
returning a null image_resource_sptr
- When all the image header details, etc have been read, the image loader
will return a formed image_resource
- The vil3d_load function (or client) can then call the resource's get_view()
to read the image.
Use cases
That should allow the following use cases.
- Filename is in the filesystem namespace. Fileformat identified by file contents.
- Filename implies a set of files. Files are in the filesystem. The
existence of the files triggers full attempt to load files. The file
contents confirm the filetype.
- Filename describes image in entirety
How to save files in vil3d
No file saving routines have been written, but place holders for various
parts of the saving system are in place.
I recommend that you follow the pattern used by vil. It may be complicated, but
it had many advantages in dealing with large files, and header information. As
with the loader, vil3d saver should pass around filenames to image_format::make_output_image(),
so that multiple slice filenames, etc. can be inferred.
Ian Scott.