HTTP Virtual File specific work item. More...
#include <virtualfileworkitem.hpp>
Public Types | |
enum | { WORK_ITEM_TYPE = ConnectWorkItem::User } |
Public Types inherited from kanzi::connect::ConnectWorkItem | |
enum | ExecutionContext { ExecutionContext::RUN_IN_MAIN_THREAD, ExecutionContext::RUN_IN_WORKER_THREAD } |
How to execute the work item. More... | |
typedef function< void(void)> | Executor |
Callback function that is dispatched to work queue and is used to execute work. More... | |
enum | Priority { LowPriority = 1, NormalPriority = 10, HighPriority = 20, SystemPriority = 30 } |
Priority levels for the work items. More... | |
enum | Type { Base, User = 1000 } |
Types for the work items. More... | |
Public Member Functions | |
int | getHandle () const |
Retrieve handle. More... | |
const string & | getMime () const |
Retrieve MIME type. More... | |
const string | getResultAsData () const |
Retrieve result file content. More... | |
const string | getResultAsFile () const |
Retrieves the filepath. More... | |
const string | getResultAsURI () const |
Retrieves the uri. More... | |
shared_ptr< VirtualfileServiceConcept::Session > | getSession () const |
Retrieve session. More... | |
const string & | getUri () const |
Retrieve the uri where from the content is to be retrieved. More... | |
bool | hasResultAsData () const |
Determine whether result file content is set. More... | |
bool | hasResultAsFile () const |
Determine whether filepath is defined. More... | |
bool | hasResultAsUri () const |
Determine whether uri is defined. More... | |
void | notifyComplete () |
Completes the pending object. More... | |
void | setHandle (int handle) |
Store the handle. More... | |
void | setMime (const string &mime) |
Store the MIME type of the returned object. More... | |
void | setResultAsData (const string &fileContent) |
Sets the result file content. More... | |
void | setResultAsData (const unsigned char *bytes, size_t length) |
Sets result file content as a binary (can also be text, obviously) More... | |
void | setResultAsFile (const string &filename) |
Sets result as a file. More... | |
void | setResultAsURI (const string &uri) |
Sets uri. More... | |
void | setSession (shared_ptr< VirtualfileServiceConcept::Session > session) |
Store session. More... | |
VirtualFileWorkItem (int32_t priority, string uri) | |
Constructor. More... | |
bool | waitUntilComplete (int ms) |
Waits for this object to be completed. More... | |
virtual | ~VirtualFileWorkItem () |
C++ destructor. More... | |
Public Member Functions inherited from kanzi::connect::ConnectWorkItem | |
ConnectWorkItem (int32_t type=Base, int32_t priority=NormalPriority, ExecutionContext executionContext=ExecutionContext::RUN_IN_MAIN_THREAD) | |
Constructor. More... | |
bool | deadlineIsEarlierThan (const ConnectWorkItem &workItem) const |
Checks whether this object(s) deadline is earlier than with the "other" item. More... | |
ConnectWorkItem::Executor | getExecutor () const |
Retrieve the executor function. More... | |
int32_t | getPriority () const |
retrieve the work item priority More... | |
AbstractServiceSharedPtr | getTargetService () |
retrieve the service this work item is traveling to. More... | |
int32_t | getType () const |
retrieve the work item type identifier More... | |
int64_t | handle () const |
Returns the handle associated with the object. More... | |
bool | hasExecutor () const |
Does the object have custom executor. More... | |
bool | hasTimeout () const |
determines whether object defines a timeout More... | |
bool | invokeWithExecutor () |
Dispatches the object with executor. More... | |
bool | runInWorkerThread () const |
Should this work item be run in worker thread or main thread. More... | |
void | setExecutor (ConnectWorkItem::Executor executorFunction) |
Setups an executor function to execute the work item. More... | |
void | setTargetService (AbstractServiceSharedPtr service) |
setups the target service More... | |
void | setTimeout (chrono::milliseconds timeout, int64_t handle) |
Sets the timeout for the work item. More... | |
chrono::milliseconds | timeoutUntilDeadline (chrono::time_point< chrono::steady_clock > &now) const |
returns the timeout in milliseconds until this object time(s) out. More... | |
chrono::milliseconds | timeoutUntilDeadline () const |
returns the timeout in milliseconds until this object time(s) out. More... | |
virtual | ~ConnectWorkItem () |
virtual destructor for cleanup. More... | |
Protected Attributes | |
int | m_handle |
string | m_mime |
optional< string > | m_resultContent |
optional< string > | m_resultFilePath |
optional< string > | m_resultRedirectUri |
shared_ptr< VirtualfileServiceConcept::Session > | m_session |
string | m_uri |
The URI to retrieve. More... | |
Wait | m_waiter |
Wait object used with multiple threads. More... | |
Protected Attributes inherited from kanzi::connect::ConnectWorkItem | |
ExecutionContext | m_executionContext |
Defines whether work item should be executed in main thread or one of the workers. More... | |
Executor | m_executor |
Optional executor function that get(s) invoked to handle the item instead of passing it to the services handler function. More... | |
int32_t | m_priority |
Priority value. More... | |
AbstractServiceWeakPtr | m_service |
defines the service this work item is traveling to. More... | |
optional< TimerInfo > | m_timerInfo |
Optional object that defines the scheduling information. More... | |
int32_t | m_type |
Type identifier. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from kanzi::connect::ConnectWorkItem | |
static ConnectWorkItemSharedPtr | create (ExecutionContext executionContext=ExecutionContext::RUN_IN_MAIN_THREAD) |
Creates a default instance of the work item. More... | |
HTTP Virtual File specific work item.
Encapsulates effectively one request where incoming data is the URI and outgoing data is the result in three possible forms (data-as-is, full-path-to-file, redirect-to-url).
|
inlinevirtual |
C++ destructor.
kanzi::connect::VirtualFileWorkItem::VirtualFileWorkItem | ( | int32_t | priority, |
string | uri | ||
) |
Constructor.
priority | Priority of the work item. |
int kanzi::connect::VirtualFileWorkItem::getHandle | ( | ) | const |
Retrieve handle.
const string& kanzi::connect::VirtualFileWorkItem::getMime | ( | ) | const |
Retrieve MIME type.
const string kanzi::connect::VirtualFileWorkItem::getResultAsData | ( | ) | const |
Retrieve result file content.
const string kanzi::connect::VirtualFileWorkItem::getResultAsFile | ( | ) | const |
Retrieves the filepath.
const string kanzi::connect::VirtualFileWorkItem::getResultAsURI | ( | ) | const |
Retrieves the uri.
shared_ptr<VirtualfileServiceConcept::Session> kanzi::connect::VirtualFileWorkItem::getSession | ( | ) | const |
Retrieve session.
const string& kanzi::connect::VirtualFileWorkItem::getUri | ( | ) | const |
Retrieve the uri where from the content is to be retrieved.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsData | ( | ) | const |
Determine whether result file content is set.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsFile | ( | ) | const |
Determine whether filepath is defined.
bool kanzi::connect::VirtualFileWorkItem::hasResultAsUri | ( | ) | const |
Determine whether uri is defined.
void kanzi::connect::VirtualFileWorkItem::notifyComplete | ( | ) |
Completes the pending object.
void kanzi::connect::VirtualFileWorkItem::setHandle | ( | int | handle | ) |
Store the handle.
handle | handle to store. |
void kanzi::connect::VirtualFileWorkItem::setMime | ( | const string & | mime | ) |
Store the MIME type of the returned object.
mime | The MIME type. |
void kanzi::connect::VirtualFileWorkItem::setResultAsData | ( | const string & | fileContent | ) |
Sets the result file content.
fileContent | buffer containing the dat.a |
void kanzi::connect::VirtualFileWorkItem::setResultAsData | ( | const unsigned char * | bytes, |
size_t | length | ||
) |
Sets result file content as a binary (can also be text, obviously)
bytes | raw buffer |
length | size of data in buffer |
void kanzi::connect::VirtualFileWorkItem::setResultAsFile | ( | const string & | filename | ) |
Sets result as a file.
filename | full path to file. |
void kanzi::connect::VirtualFileWorkItem::setResultAsURI | ( | const string & | uri | ) |
Sets uri.
uri | the uri to set. |
void kanzi::connect::VirtualFileWorkItem::setSession | ( | shared_ptr< VirtualfileServiceConcept::Session > | session | ) |
Store session.
session | The session to store. |
bool kanzi::connect::VirtualFileWorkItem::waitUntilComplete | ( | int | ms | ) |
Waits for this object to be completed.
ms | how long to wait max. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
The URI to retrieve.
|
protected |
Wait object used with multiple threads.