Kanzi Connect  3.9.9
Kanzi Connect C++ API
kanzi::connect::VirtualFileWorkItem Class Reference

HTTP Virtual File specific work item. More...

#include <virtualfileworkitem.hpp>

Inheritance diagram for kanzi::connect::VirtualFileWorkItem:
kanzi::connect::ConnectWorkItem

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< TimerInfom_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...
 

Detailed Description

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).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
WORK_ITEM_TYPE 

Custom type for work items.

Constructor & Destructor Documentation

◆ ~VirtualFileWorkItem()

virtual kanzi::connect::VirtualFileWorkItem::~VirtualFileWorkItem ( )
inlinevirtual

C++ destructor.

◆ VirtualFileWorkItem()

kanzi::connect::VirtualFileWorkItem::VirtualFileWorkItem ( int32_t  priority,
string  uri 
)

Constructor.

Parameters
priorityPriority of the work item.

Member Function Documentation

◆ getHandle()

int kanzi::connect::VirtualFileWorkItem::getHandle ( ) const

Retrieve handle.

Returns
handle

◆ getMime()

const string& kanzi::connect::VirtualFileWorkItem::getMime ( ) const

Retrieve MIME type.

Returns
The MIME type.

◆ getResultAsData()

const string kanzi::connect::VirtualFileWorkItem::getResultAsData ( ) const

Retrieve result file content.

Returns
result data.

◆ getResultAsFile()

const string kanzi::connect::VirtualFileWorkItem::getResultAsFile ( ) const

Retrieves the filepath.

Returns
filepath

◆ getResultAsURI()

const string kanzi::connect::VirtualFileWorkItem::getResultAsURI ( ) const

Retrieves the uri.

Returns
uri

◆ getSession()

shared_ptr<VirtualfileServiceConcept::Session> kanzi::connect::VirtualFileWorkItem::getSession ( ) const

Retrieve session.

Returns
The retrieved session.

◆ getUri()

const string& kanzi::connect::VirtualFileWorkItem::getUri ( ) const

Retrieve the uri where from the content is to be retrieved.

Returns
uri

◆ hasResultAsData()

bool kanzi::connect::VirtualFileWorkItem::hasResultAsData ( ) const

Determine whether result file content is set.

Returns
true if result file content is in place.

◆ hasResultAsFile()

bool kanzi::connect::VirtualFileWorkItem::hasResultAsFile ( ) const

Determine whether filepath is defined.

Returns
true if filepath type.

◆ hasResultAsUri()

bool kanzi::connect::VirtualFileWorkItem::hasResultAsUri ( ) const

Determine whether uri is defined.

Returns
true if defined.

◆ notifyComplete()

void kanzi::connect::VirtualFileWorkItem::notifyComplete ( )

Completes the pending object.

◆ setHandle()

void kanzi::connect::VirtualFileWorkItem::setHandle ( int  handle)

Store the handle.

Parameters
handlehandle to store.

◆ setMime()

void kanzi::connect::VirtualFileWorkItem::setMime ( const string &  mime)

Store the MIME type of the returned object.

Parameters
mimeThe MIME type.

◆ setResultAsData() [1/2]

void kanzi::connect::VirtualFileWorkItem::setResultAsData ( const string &  fileContent)

Sets the result file content.

Parameters
fileContentbuffer containing the dat.a

◆ setResultAsData() [2/2]

void kanzi::connect::VirtualFileWorkItem::setResultAsData ( const unsigned char *  bytes,
size_t  length 
)

Sets result file content as a binary (can also be text, obviously)

Parameters
bytesraw buffer
lengthsize of data in buffer

◆ setResultAsFile()

void kanzi::connect::VirtualFileWorkItem::setResultAsFile ( const string &  filename)

Sets result as a file.

Parameters
filenamefull path to file.

◆ setResultAsURI()

void kanzi::connect::VirtualFileWorkItem::setResultAsURI ( const string &  uri)

Sets uri.

Parameters
urithe uri to set.

◆ setSession()

void kanzi::connect::VirtualFileWorkItem::setSession ( shared_ptr< VirtualfileServiceConcept::Session >  session)

Store session.

Parameters
sessionThe session to store.

◆ waitUntilComplete()

bool kanzi::connect::VirtualFileWorkItem::waitUntilComplete ( int  ms)

Waits for this object to be completed.

Parameters
mshow long to wait max.

Member Data Documentation

◆ m_handle

int kanzi::connect::VirtualFileWorkItem::m_handle
protected

◆ m_mime

string kanzi::connect::VirtualFileWorkItem::m_mime
protected

◆ m_resultContent

optional<string> kanzi::connect::VirtualFileWorkItem::m_resultContent
protected

◆ m_resultFilePath

optional<string> kanzi::connect::VirtualFileWorkItem::m_resultFilePath
protected

◆ m_resultRedirectUri

optional<string> kanzi::connect::VirtualFileWorkItem::m_resultRedirectUri
protected

◆ m_session

shared_ptr<VirtualfileServiceConcept::Session> kanzi::connect::VirtualFileWorkItem::m_session
protected

◆ m_uri

string kanzi::connect::VirtualFileWorkItem::m_uri
protected

The URI to retrieve.

◆ m_waiter

Wait kanzi::connect::VirtualFileWorkItem::m_waiter
protected

Wait object used with multiple threads.


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