tbx  0.7.6
Public Member Functions | List of all members
tbx::Loader Class Referenceabstract

Class to handle file/data loading from the filer or an external application. More...

#include <loader.h>

Inheritance diagram for tbx::Loader:
tbx::MemoryLoader

Public Member Functions

virtual bool load_file (LoadEvent &event)=0
 Override to do the actual file load. More...
 
virtual bool accept_file (LoadEvent &event)
 Override to see if the loader can accept a file. More...
 
virtual void * data_buffer (const LoadEvent &event, int &buffer_size)
 Set up buffer for application to application data transfer. More...
 
virtual bool data_received (DataReceivedEvent &event)
 Override to receive the file by in memory transfer from another application. More...
 
virtual void data_error (const LoadEvent &event)
 Informs loader that an error occurred during application to application data transfer. More...
 

Detailed Description

Class to handle file/data loading from the filer or an external application.

Add the loader to the object you wish to handle the load and override the load_file method to load the file.

Member Function Documentation

◆ accept_file()

virtual bool tbx::Loader::accept_file ( LoadEvent event)
inlinevirtual

Override to see if the loader can accept a file.

Defaults to return true as in normal circumstances the file type is all that is important and that will be specified when adding the loader.

◆ data_buffer()

virtual void* tbx::Loader::data_buffer ( const LoadEvent event,
int &  buffer_size 
)
inlinevirtual

Set up buffer for application to application data transfer.

Called after a file has been accepted so the loader can create a buffer for the transfer or point to the location to load to.

Return 0 (as the default does) if application to application data transfer is not supported.

Parameters
eventLoadEvent that started the data transfer
buffer_sizesize of the buffer returned (defaults to event.estimated_size())
Returns
buffer for data transfer or 0 if data transfer is not to be used.

Reimplemented in tbx::MemoryLoader.

◆ data_error()

virtual void tbx::Loader::data_error ( const LoadEvent event)
inlinevirtual

Informs loader that an error occurred during application to application data transfer.

Parameters
eventload event that started the transfer

Reimplemented in tbx::MemoryLoader.

◆ data_received()

virtual bool tbx::Loader::data_received ( DataReceivedEvent event)
inlinevirtual

Override to receive the file by in memory transfer from another application.

This routine may be called multiple times until all the data is transferred.

It is possible for the last packet transferred to contain zero bytes if the penultimate call filled the buffer exactly.

The DataReceivedEvent contains details of where the data was copied and the number of bytes received. The more method returns false when there is no more data to receive.

By default this returns false as a loader can support transfer by file only.

Parameters
eventDetails of buffer received
Returns
true if buffer could be processed, false on error.

Reimplemented in tbx::MemoryLoader.

◆ load_file()

virtual bool tbx::Loader::load_file ( LoadEvent event)
pure virtual

Override to do the actual file load.

The file name for the load is in event.file_name().

Returns
true if file is loaded.

Implemented in tbx::MemoryLoader.


The documentation for this class was generated from the following file: