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

Helper class to implement the loader interface and call a routine once all the bytes have been loaded with the bytes loaded at the end of the processing. More...

#include <memoryloader.h>

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

Public Member Functions

 MemoryLoader (bool show_error=false, const char *error_title=0)
 Construct the memory loader object. More...
 
virtual bool load_file (LoadEvent &event)
 Overriden from Loader to load the file and pass the bytes loaded to the data_loaded function. 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)
 Overriden from Loader to populate the internal data buffer from the transfer. More...
 
virtual void data_error (const LoadEvent &event)
 Informs loader that an error occurred during application to application data transfer. More...
 
virtual void data_exception (const LoadEvent &event, std::exception &except)
 Informs loader an exception occurred during the loading process. More...
 
virtual void data_loaded (const LoadEvent &event, char *data, int data_size, bool &claim_data)=0
 Called when all the data has been loaded this method is called with a character array of the data recieved. More...
 
- Public Member Functions inherited from tbx::Loader
virtual bool accept_file (LoadEvent &event)
 Override to see if the loader can accept a file. More...
 

Detailed Description

Helper class to implement the loader interface and call a routine once all the bytes have been loaded with the bytes loaded at the end of the processing.

Add the loader to the object you wish to handle the load and override the data_loaded method to process the bytes loaded.

Constructor & Destructor Documentation

◆ MemoryLoader()

tbx::MemoryLoader::MemoryLoader ( bool  show_error = false,
const char *  error_title = 0 
)

Construct the memory loader object.

Parameters
show_errortrue to show a message box on error (default false)
error_titleTitle to show if an error is reported ("" or 0 for the default title)

Member Function Documentation

◆ data_buffer()

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

Set up buffer for application to application data transfer.

This method is overriden from the Loader class to create an internal buffer which will be filled and then passed to the data_loaded method.

Parameters
eventLoadEvent that started the data transfer
buffer_sizesize of the buffer returned (defaults to event.estimated_size())
Returns
internal buffer created for the data transfer.

Reimplemented from tbx::Loader.

◆ data_error()

void tbx::MemoryLoader::data_error ( const LoadEvent event)
virtual

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

overrided to show a message if show_error was set in the constructor override for alternate processing

Parameters
eventload event that started the transfer

Reimplemented from tbx::Loader.

◆ data_exception()

void tbx::MemoryLoader::data_exception ( const LoadEvent event,
std::exception &  except 
)
virtual

Informs loader an exception occurred during the loading process.

If not overriden it will show an error box if show_error was set in the constructor or call data_error if not.

Parameters
eventload event that started the transfer
exceptexception that occurred.

◆ data_loaded()

virtual void tbx::MemoryLoader::data_loaded ( const LoadEvent event,
char *  data,
int  data_size,
bool &  claim_data 
)
pure virtual

Called when all the data has been loaded this method is called with a character array of the data recieved.

Parameters
databytes loaded.
data_sizenumber of bytes in the buffer;
claim_dataset to true to claim the data buffer. If claim_data is true, delete the claimed buffer with delete [] when it's finished with.

◆ data_received()

bool tbx::MemoryLoader::data_received ( DataReceivedEvent event)
virtual

Overriden from Loader to populate the internal data buffer from the transfer.

Once all data is received the data_loaded method will be called.

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

Reimplemented from tbx::Loader.

◆ load_file()

bool tbx::MemoryLoader::load_file ( LoadEvent event)
virtual

Overriden from Loader to load the file and pass the bytes loaded to the data_loaded function.

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

Returns
true if file is loaded.

Implements tbx::Loader.


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