![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
Simple file loader class for in-memory files.
The memory loader will use the filename and path passed in as the key to access data stored. On Windows the filename and path are converted to lowercase, on other platforms the filename and path are case sensitive.
If you add a resource on Windows the loader will process any filenames passed in. Any directory path will be removed and the basename (including extension) will be made lower case. This allows for simple matching.
This simple loader operates only synchronously and only on in memory callbacks. A fallback loader may be specified which is used for files that are not added using the 'addResource' or 'addMemoryBlock' methods. If no fallback loader is specified, an internally created blocking loader is used.
For this loader, a file is always read in one chunk not block by block, so no progress callbacks will happen until the load process is finished. Note that a multi-threaded or remote fallback loader may use progress callbacks.
The synchronous flag only has an effect if a multi-threaded fallback loader is used.
This loader has no worker thread - callbacks always come from the main thread - but this restriction does not apply to a fallback loader.
The data is owned by the user. This is to allow data to be stored in flash memory.
Public Member Functions | |
TSLFileLoaderMemory (TSLFileLoader *fallbackLoader=0) | |
void | addFallbackLoader (TSLFileLoader *fallbackLoader) |
bool | addMemoryBlock (const char *equivalentFilename, unsigned char *dataPointer, TSLUSize dataSize, TSLTimeType *lastModificationTime=NULL) |
bool | addResource (const char *equivalentFilename, void *instanceHandle, TSLUSize id, const char *className, TSLTimeType *lastModificationTime=NULL) |
bool | removeMemoryBlock (const char *equivalentFilename) |
void * | operator new (size_t size) TSL_NO_THROW |
void * | operator new (size_t size, char *filename, int line) |
![]() | |
void | cancelAllLoads () |
void | destroy () |
bool | fileExists (const char *filename) |
bool | fileModificationTime (TSLPathList *pathList, const char *filename, TSLTimeType &lastModificationTime) |
bool | findMatchingFile (TSLPathList *pathList, const char *filename, TSLSimpleString &fullPathFound, TSLMaplCompressionOption *compression=0, bool *remote=0) |
TSLLoaderStatus | load (TSLPathList *pathList, const char *filename, TSLLoaderCallback callback, void *arg, bool synchronous=true) |
TSLLoaderStatus | loadImmediate (TSLPathList *pathList, const char *filename, TSLifstream *stream) |
TSLLoaderStatus | loadSegment (TSLPathList *pathList, const char *filename, TSLFileOffset offset, TSLFileLength length, TSLLoaderCallback callback, void *arg, bool synchronous=true) |
TSLLoaderStatus | loadSegmentImmediate (TSLPathList *pathList, const char *filename, TSLFileOffset offset, TSLFileLength length, TSLifstream *stream) |
void | setCallback (TSLLoaderFileCallback callback, void *userData, int loaderCallbacks) |
TSLFileLoaderTypeEnum | type () const |
Additional Inherited Members | |
![]() | |
TSLFileLoader () | |
~TSLFileLoader () | |
TSLFileLoaderMemory::TSLFileLoaderMemory | ( | TSLFileLoader * | fallbackLoader = 0 | ) |
Constructor for in memory file loader
fallbackLoader | Another loader to use when requested files are not available as in-memory versions. Default is 0, which means that an internally created blocking loader is used. |
void TSLFileLoaderMemory::addFallbackLoader | ( | TSLFileLoader * | fallbackLoader | ) |
This method adds a fallback loader for an instance of TSLFileLoaderMemory. If the file cannot be found then the fallback loader is used to to try locate it.
Replaces the previous Fallback Loader added by the user.
fallbackLoader | The TSLFileLoader to revert to if the file cannot be found. |
bool TSLFileLoaderMemory::addMemoryBlock | ( | const char * | equivalentFilename, |
unsigned char * | dataPointer, | ||
TSLUSize | dataSize, | ||
TSLTimeType * | lastModificationTime = NULL ) |
Adds a memory block as an equivalent file
Note. The caller owns the memory block as this may be in flash.
equivalentFilename | Filename used for identifying this resource. eg. "tsllinestyles.dat" |
dataPointer | Address of the memory block |
dataSize | Size of the memory block in bytes |
lastModificationTime | The last modification time of the equivalent file. |
bool TSLFileLoaderMemory::addResource | ( | const char * | equivalentFilename, |
void * | instanceHandle, | ||
TSLUSize | id, | ||
const char * | className, | ||
TSLTimeType * | lastModificationTime = NULL ) |
Adds a resource definition - used on Windows only
To add a file into the resources in Visual Studio, use the following in Visual Studio .NET 2003:
equivalentFilename | Filename used for identifying this resource. eg. "tsllinestyles.dat" |
instanceHandle | Handle of application instance - On MFC, use AfxGetInstanceHandle(), for ATL older than 7.0, use _Module.GetResourceInstance(), for ATL 7.0 use _AtlBaseModule.GetResourceInstance() |
id | Resource ID, eg. IDR_LINESTYLES_FILE |
className | Name of the custom resource type used when importing the file into the resources, eg. "CONFIG_FILES" |
lastModificationTime | The last modification time of the resource. |
void * TSLFileLoaderMemory::operator new | ( | size_t | size | ) |
Overridden allocation to redirect to MapLink
void * TSLFileLoaderMemory::operator new | ( | size_t | size, |
char * | filename, | ||
int | line ) |
When included in an MFC application in debug mode, the debug new expects this to be here. Override it and return the same as the normal one. The library must include it when compiled in release mode, since the user's application may be in debug mode.
bool TSLFileLoaderMemory::removeMemoryBlock | ( | const char * | equivalentFilename | ) |
Remove the memory block associated with 'equivalentFile'
equivalentFilename | Filename used for identifying this resource. eg. "tsllinestyles.dat" |