EasyFlow  0.2.1
A Framework for Workflow Management and Application Hosting
 All Classes Namespaces Functions Variables Enumerations
BaseApp Class Referenceabstract

The client-side integration layer. More...

#include <BaseApp.h>

Inheritance diagram for BaseApp:
Collaboration diagram for BaseApp:

Public Member Functions

 BaseApp (std::string addr, int port, int http_port, std::string host_addr, int host_port, std::string doc_root, std::string ext_addr)
 
void start ()
 
- Public Member Functions inherited from AppHandler
 AppHandler (std::string addr, std::string host_addr, int host_port, std::string ext_addr, std::string doc_root)
 
bool setState (const appHost::State::type newState)
 
appHost::State::type getState ()
 
void getAppUUID (appHost::UUID &_return)
 
bool getStatus (const std::string &codingScheme, const std::string &code)
 
bool notifyDataAvailable (const appHost::UUID &senderUUID, const appHost::AvailableData &data, const bool lastData)
 
void getData (std::vector< appHost::ObjectLocator > &_return, const appHost::UUID &senderUUID, const std::vector< appHost::UUID > &objectUUIDs)
 
void releaseData (const appHost::UUID &senderUUID, const std::vector< appHost::UUID > &objectUUIDs)
 
boost::shared_ptr
< appHost::HostClient
getClient ()
 
::appHost::State::type getState ()
 
bool setState (const ::appHost::State::type newState)
 
void getAppUUID (::appHost::UUID &_return)
 
bool getStatus (const std::string &codingScheme, const std::string &code)
 
- Public Member Functions inherited from TaskIf
virtual bool initTask ()=0
 
virtual bool releaseTask ()=0
 

Protected Member Functions

void buildInputFiles (const std::map< std::string, std::vector< appHost::ObjectLocator > > &input)
 
void buildOutputURIs (appHost::URI outputLocation, std::vector< appHost::URI > &results)
 
void prepareStatus (const appHost::Status &status)
 
void registerUsedFiles (std::string path)
 
void registerUsedFiles (const std::vector< std::string > &pathList)
 
virtual void setPreferredProtocols ()=0
 
void execTask (const std::map< std::string, std::vector< appHost::ObjectLocator > > &input, const std::vector< std::string > &inputParams, appHost::URI outputLocation, std::vector< appHost::URI > &results)
 
appHost::Status createStatus (const appHost::StatusType::type &statusType, const std::string &codingScheme="", const std::string &code="", const std::string &codeMeaning="", const std::string &codeValue="")
 
appHost::Status createDiskUsageStatus ()
 
appHost::Status createMemoryUsageStatus ()
 
appHost::Status createElapsedTimeStatus ()
 
appHost::Status getStatusByKeys (const std::string &codingScheme, const std::string &code)
 

Protected Attributes

std::vector< std::string > m_preferredProtocols
 
std::map< std::string,
std::vector< std::string > > 
m_inFilepaths
 
std::string m_inDir
 
std::vector< std::string > m_outFilenames
 
std::vector< std::string > m_outFullpaths
 
- Protected Attributes inherited from AppHandler
appHost::State::type m_currState
 
bool m_changeIsAllowed
 
bool m_lastData
 
bool m_isInterrupted
 
std::string m_addr
 
std::string m_host_addr
 
int m_host_port
 
std::string m_doc_root
 
boost::shared_ptr
< appHost::HostClient
m_host
 
std::map< appHost::UUID,
appHost::URI > 
m_map
 
boost::shared_ptr< boost::thread > m_execThread
 
boost::shared_ptr< boost::thread > m_getTaskDataThread
 
appHost::UUID m_appUUID
 
boost::thread_group m_threadGroup
 
appHost::UUID m_workitemUUID
 
CodingSchemes m_codingSchemes
 
std::ofstream m_logfile
 
std::string m_ext_addr
 

Detailed Description

The client-side integration layer.

This class represents the client-side integration layer. It is derived from AppHandler class, thereby inheriting its interaction functionalities, and from the TaskIf interface.

The latter is the interface that must be implemented by a third-party developer in order to create a hosted application.

Constructor & Destructor Documentation

BaseApp::BaseApp ( std::string  addr,
int  port,
int  http_port,
std::string  host_addr,
int  host_port,
std::string  doc_root,
std::string  ext_addr 
)

Constructor

Constructs both the web service server, to listen on the specified TCP/IP address and port, and the http server, to listen on the specified TCP/IP address and port and serve up files from the given directory, of the application. Also stores the web server's TCP/IP address and port of the host.

Parameters
[in]addrIP address or domain (host name) of the application web service and http servers
[in]portTCP port of the application web service server
[in]http_portTCP port of the application http server
[in]host_addrIP address or domain (host name) of the host web service and http servers
[in]host_portTCP port of the host web service server
[in]doc_rootPath of the application http server document root

Member Function Documentation

void BaseApp::buildInputFiles ( const std::map< std::string, std::vector< appHost::ObjectLocator > > &  input)
protected

Builds the paths of the input files from the map of lists of appHost::ObjectLocator objects. The folder where the input files will be saved must be specified setting the m_input field before calling this method; After the call the field m_inFilepaths will be populated with the lists of paths of the input files.

This method should be called inside the TaskIf::execTask method that must be implemented by a third-party developer in order to create a hosted application.

Parameters
[in]inputmap of lists of appHost::ObjectLocator objects used to get the the paths of the input files
void BaseApp::buildOutputURIs ( appHost::URI  outputLocation,
std::vector< appHost::URI > &  results 
)
protected

Builds the URIs for the output results.

This method should be called inside the TaskIf::execTask method that must be implemented by a third-party developer in order to create a hosted application.

Parameters
[in]outputLocationThe URI of the output folder
[out]resultsList containing the URIs of the output files
Status BaseApp::createDiskUsageStatus ( )
protectedvirtual

Creates the status containing the application current disk space usage

Returns
the status object

Implements AppHandler.

Status BaseApp::createElapsedTimeStatus ( )
protectedvirtual

Creates the status containing the application and the task elapsed time

Returns
the status object

Implements AppHandler.

Status BaseApp::createMemoryUsageStatus ( )
protectedvirtual

Creates the status containing the application current memory usage

Returns
the status object

Implements AppHandler.

Status BaseApp::createStatus ( const appHost::StatusType::type &  statusType,
const std::string &  codingScheme = "",
const std::string &  code = "",
const std::string &  codeMeaning = "",
const std::string &  codeValue = "" 
)
protectedvirtual

Creates a status object using the input data

Parameters
[in]statusTypeThe type of the status
[in]codingSchemeThe coding scheme of the status
[in]codeThe code of the status
[in]codeValueThe code value of the status
Returns
the created status object

Implements AppHandler.

void BaseApp::execTask ( const std::map< std::string, std::vector< appHost::ObjectLocator > > &  input,
const std::vector< std::string > &  inputParams,
appHost::URI  outputLocation,
std::vector< appHost::URI > &  results 
)
protectedvirtual

Prepares the inputs and output(s) data needed to execute an application task. The third-party developer must call it inside its implementation of this method in order to prepare, in an automatic way, the inputs and output(s) data.

Before calling this method, the third-party developer has only to set the m_outDir and m_outFilenames fields, accordingly to its task implementation.

Implements TaskIf.

Status BaseApp::getStatusByKeys ( const std::string &  codingScheme,
const std::string &  code 
)
protectedvirtual

Gets the status referred to the input keys

Parameters
[in]codingSchemeThe coding scheme
[in]codeThe code
Returns
the status object

Implements AppHandler.

void BaseApp::prepareStatus ( const appHost::Status status)
protectedvirtual

Informs the host of notable events that may occur during execution. This method wraps the call to the HostIf::notifyStatus method.

Parameters
[in]statusThe status of the notification

Implements AppHandler.

void BaseApp::registerUsedFiles ( std::string  path)
protected

Allows a third-party developer to register a local file, in order to keep trace of all the files owned by the application. Thanks to this registration it is possible to retrieve informations about the resources used by the application, such as the disk space usage.

Overloaded method.

Parameters
[in]pathThe path of the local file
void BaseApp::registerUsedFiles ( const std::vector< std::string > &  pathList)
protected

Allows a third-party developer to register a list of local files, in order to keep trace of all the files owned by the application. Thanks to this registration it is possible to retrieve informations about the resources used by the application, such as the disk space usage.

Overloaded method.

Parameters
[in]pathListThe list of the paths of the local files
virtual void BaseApp::setPreferredProtocols ( )
protectedpure virtual

Allows a third-party developer to specify the preferred protocols, in order of preference, that the application can use to store data. The application shall at least support both the http: and the file: protocols. The Host selects the most appropriate protocol and uses it in setting up the resources and generating the URI returned to the application

This method must be implemented by a third-party developer in order to create a hosted application.

void BaseApp::start ( )

Starts both the web service and the http servers

Member Data Documentation

std::string BaseApp::m_inDir
protected

Folder where the input files will be saved

std::map< std::string, std::vector<std::string> > BaseApp::m_inFilepaths
protected

Map of lists of paths of the input files

std::vector<std::string> BaseApp::m_outFilenames
protected

List of the file names of the output results

std::vector<std::string> BaseApp::m_outFullpaths
protected

List of the local full paths of the output results

std::vector<std::string> BaseApp::m_preferredProtocols
protected

List of the preferred protocols


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