DataUploader< DataType_t > Class Template Reference

The class used to upload data. More...

Inheritance diagram for DataUploader< DataType_t >:

Public Types

typedef DataType_t DataType
 The type of data being exchanged.
typedef farsa::DatumToUpload
< DataType
DatumToUpload
 A typedef to use the correct DatumToUpload.
enum  FullQueueBehavior { OverrideOlder, BlockUploader, IncreaseQueueSize, SignalUploader }
 The possible behaviors when the queue is full. More...

Public Member Functions

 DataUploader (unsigned int queueSize, FullQueueBehavior b, DataDownloader< DataType > *downloader=NULL)
 Constructor.
 ~DataUploader ()
 Destructor.
bool associationBeforeUploadChecked () const
 Returns true if an exception is thrown if the user tries to upload a datum but no association is present.
void checkAssociationBeforeUpload (bool v)
 Sets whether an exception has to be thrown if the user tries to upload a datum but no association is present.
DataTypecreateDatum ()
 Returns a pointer to an object that will be the next datum to upload.
bool datumCreatedNotUploaded () const
 Returns true if a new datum has been created but not uploaded (i.e. createDatum() has been called but uploadDatum() hasn't)
unsigned int getAvailableSpace () const
 Returns the number of data the queue can hold before becoming full.
const DataDownloader< DataType > * getDownloader () const
 Returns the downloader associated with this uploader.
FullQueueBehavior getFullQueueBehavior () const
 Returns the FullQueueBehavior.
unsigned int getNumDataInQueue () const
 Returns the number of data currently in the queue.
unsigned int getQueueSize () const
 Returns the queue size.
void uploadDatum ()
 Adds the current datum to the queue.

Friends

class DataDownloader< DataType >
 The downloader is friend to modify the queue and call setDownloader.

Detailed Description

template<class DataType_t>
class farsa::DataUploader< DataType_t >

The class used to upload data.

See dataexchange.h for more information

Warning
Functions in this class are NOT thread safe

Definition at line 238 of file dataexchange.h.

Member Typedef Documentation

typedef DataType_t DataType

The type of data being exchanged.

Definition at line 244 of file dataexchange.h.

A typedef to use the correct DatumToUpload.

Definition at line 249 of file dataexchange.h.

Member Enumeration Documentation

The possible behaviors when the queue is full.

Enumerator:
OverrideOlder 

Overrides older data

BlockUploader 

Blocks the uploader until at least one datum has been downloaded

IncreaseQueueSize 

Increases the queue size to upload the new datum

SignalUploader 

Tells the uploader the queue is full

Definition at line 254 of file dataexchange.h.

Constructor & Destructor Documentation

DataUploader ( unsigned int  queueSize,
FullQueueBehavior  b,
DataDownloader< DataType > *  downloader = NULL 
)

Constructor.

Parameters
queueSizethe size of the queue. If the b parameter is IncreaseQueueSize, this is the initial size and the queue will never be shorter than this. The queue will always have at least one element (even if this is set to 0)
bthe behavior when the queue is full
downloaderthe downloader to which we are associated. This can be NULL. If downloader is already associated with another uploader, an exception is thrown

Definition at line 1294 of file dataexchange.h.

Destructor.

Definition at line 1305 of file dataexchange.h.

Member Function Documentation

bool associationBeforeUploadChecked ( ) const
inline

Returns true if an exception is thrown if the user tries to upload a datum but no association is present.

When this object is constructed, this is set to true

Returns
true if an exception is thrown if the user tries to upload a datum but no association is present

Definition at line 392 of file dataexchange.h.

void checkAssociationBeforeUpload ( bool  v)
inline

Sets whether an exception has to be thrown if the user tries to upload a datum but no association is present.

When this object is constructed, this is set to true

Parameters
vif true an exception is thrown when the user tries to upload a datum and no association is present

Definition at line 379 of file dataexchange.h.

DataType_t * createDatum ( )

Returns a pointer to an object that will be the next datum to upload.

Modify the object returned by this function, it will be the next datum to upload. If the queue is full, this function blocks if the FullQueueBehavior is set to BlockUploader, while it returns NULL if the FullQueueBehavior is set to SignalUploader

Returns
the object that will be the next datum
Warning
If you call this function remember to call uploadDatum() when done. A more convenient way to create data is to use DatumToUpload

Definition at line 1337 of file dataexchange.h.

References UploaderDownloaderAssociationNotPresentException::DownloaderNotPresent.

bool datumCreatedNotUploaded ( ) const
inline

Returns true if a new datum has been created but not uploaded (i.e. createDatum() has been called but uploadDatum() hasn't)

Returns
true if a new datum has been created but not uploaded

Definition at line 366 of file dataexchange.h.

unsigned int getAvailableSpace ( ) const

Returns the number of data the queue can hold before becoming full.

If the FullQueueBehavior is IncreaseQueueSize, this function always returns at least 1

Returns
the number of data the queue can hold before becoming full

Definition at line 1317 of file dataexchange.h.

const DataDownloader<DataType>* getDownloader ( ) const
inline

Returns the downloader associated with this uploader.

Returns
the downloader associated with this uploader or NULL if we are not associated with any downloader
Note
the downloader probably lives in another thread, so you should not use the returned pointer for anything except comparison with other pointers (e.g. to understand if an association is present or not)

Definition at line 314 of file dataexchange.h.

FullQueueBehavior getFullQueueBehavior ( ) const
inline

Returns the FullQueueBehavior.

Returns
the FullQueueBehavior

Definition at line 299 of file dataexchange.h.

unsigned int getNumDataInQueue ( ) const

Returns the number of data currently in the queue.

If the FullQueueBehavior is IncreaseQueueSize, this function can return a value greater than getQueueSize()

Returns
the number of data currently in the queue

Definition at line 1329 of file dataexchange.h.

unsigned int getQueueSize ( ) const
inline

Returns the queue size.

Returns
the queue size

Definition at line 289 of file dataexchange.h.

void uploadDatum ( )

Adds the current datum to the queue.

If createDatum() hasn't been called, this function does nothing

Definition at line 1410 of file dataexchange.h.

Friends And Related Function Documentation

friend class DataDownloader< DataType >
friend

The downloader is friend to modify the queue and call setDownloader.

Definition at line 459 of file dataexchange.h.


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