MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLFileLoaderMemory Class Reference
Inheritance diagram for TSLFileLoaderMemory:

Detailed Description

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)
 
- Public Member Functions inherited from TSLFileLoader
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

- Protected Member Functions inherited from TSLFileLoader
 TSLFileLoader ()
 
 ~TSLFileLoader ()
 

Constructor & Destructor Documentation

◆ TSLFileLoaderMemory()

TSLFileLoaderMemory::TSLFileLoaderMemory ( TSLFileLoader * fallbackLoader = 0)

Constructor for in memory file loader

Parameters
fallbackLoaderAnother 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.

Member Function Documentation

◆ addFallbackLoader()

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.

Parameters
fallbackLoaderThe TSLFileLoader to revert to if the file cannot be found.

◆ addMemoryBlock()

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.

Parameters
equivalentFilenameFilename used for identifying this resource. eg. "tsllinestyles.dat"
dataPointerAddress of the memory block
dataSizeSize of the memory block in bytes
lastModificationTimeThe last modification time of the equivalent file.
Returns
true on success, false otherwise.

◆ addResource()

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:

  • Ensure that the project's .rc, .vcproj and resource.h files are all writable.
  • In the Resource View, right click on the .rc file and choose 'Add Resource...'
  • In the 'Add Resource' dialog, press the 'Import ...' button
  • In the resultant File Dialog, choose . from the File Type combo and select the file - the filename should be passed in to this method as the 'equivalentFilename' parameter
  • In the 'Custom Resource Type' dialog, either choose a resource type or enter a new name - eg. "CONFIG_FILES" - this string should be passed in to this method as the 'className' parameter
  • The file will be added into the resource view - change the 'IDR_xxx' name to something more meaningful - this string should be passed in to this method as 'resourceID' parameter
  • When the project is built, the file will be compiled into the output executable.
Parameters
equivalentFilenameFilename used for identifying this resource. eg. "tsllinestyles.dat"
instanceHandleHandle of application instance - On MFC, use AfxGetInstanceHandle(), for ATL older than 7.0, use _Module.GetResourceInstance(), for ATL 7.0 use _AtlBaseModule.GetResourceInstance()
idResource ID, eg. IDR_LINESTYLES_FILE
classNameName of the custom resource type used when importing the file into the resources, eg. "CONFIG_FILES"
lastModificationTimeThe last modification time of the resource.
Returns
true on success, false otherwise.

◆ operator new() [1/2]

void * TSLFileLoaderMemory::operator new ( size_t size)

Overridden allocation to redirect to MapLink

◆ operator new() [2/2]

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.

◆ removeMemoryBlock()

bool TSLFileLoaderMemory::removeMemoryBlock ( const char * equivalentFilename)

Remove the memory block associated with 'equivalentFile'

Parameters
equivalentFilenameFilename used for identifying this resource. eg. "tsllinestyles.dat"
Returns
true if the memory block was removed.