tbx  0.7.6
Public Types | Public Member Functions | Static Public Member Functions | List of all members
tbx::URI Class Reference

Class to take a URI and dispatch it to the Wimp for processing. More...

#include <uri.h>

Inheritance diagram for tbx::URI:
tbx::WimpRecordedMessageListener

Public Types

enum  State {
  NotDispatched, Dispatched, DispatchError, WaitingForResult,
  Claimed, NotClaimed
}
 

Public Member Functions

 URI (const std::string &uri)
 Create a URI object to dispatch a URI. More...
 
virtual ~URI ()
 When the object is destroyed the result handler is cancelled.
 
void uri (const std::string &new_uri)
 Reset the URI. More...
 
bool dispatch ()
 Dispatch the URI. More...
 
bool check ()
 Check if an application is open that can process the URI. More...
 
void set_result_handler (URIResultHandler *handler)
 Set the object to handle the result status of a dispatch or check call. More...
 
State state () const
 

Static Public Member Functions

static int version ()
 Get the URI version. More...
 
static bool dispatch (const std::string &uri)
 static method to give a simple method of launching a uri More...
 
static bool ensure_uri_handler ()
 Ensure the URI handler is started. More...
 
static bool uri_handler_started ()
 Check if the uri_handler has been started. More...
 

Detailed Description

Class to take a URI and dispatch it to the Wimp for processing.

To use successfully the AcornURI module must be loaded and started. Either add the correct field to the !Run file or use the method ensure_uri_handler in this class.

Constructor & Destructor Documentation

◆ URI()

tbx::URI::URI ( const std::string &  uri)

Create a URI object to dispatch a URI.

Parameters
uri to dispatch

Member Function Documentation

◆ check()

bool tbx::URI::check ( )

Check if an application is open that can process the URI.

The result of this call only fails on the initial dispatch use set_result_handler to check if it would be claimed.

returns true if check can start, false otherwise

◆ dispatch() [1/2]

bool tbx::URI::dispatch ( )

Dispatch the URI.

The result of this call only fails on the initial dispatch use set_result_handler to check if it was claimed.

Returns
true if dispatched, false otherwise

◆ dispatch() [2/2]

bool tbx::URI::dispatch ( const std::string &  uri)
static

static method to give a simple method of launching a uri

Returns
true if uri is dispatched (this doesn't mean it has been claimed by anything)

◆ ensure_uri_handler()

bool tbx::URI::ensure_uri_handler ( )
static

Ensure the URI handler is started.

Checks if the URI handler (AcornURI) has been started and attempts to start it if it has not.

This can only be called from a Wimp task after the application has been initialised.

Caches the result so does nothing after the first successful call.

Returns
true if successful

◆ set_result_handler()

void tbx::URI::set_result_handler ( URIResultHandler handler)

Set the object to handle the result status of a dispatch or check call.

The handler must be set before the dispatch or check call to be actioned.

Parameters
handlerinterface to handle the result or nullptr to clear the handler.

◆ uri()

void tbx::URI::uri ( const std::string &  new_uri)

Reset the URI.

If the previous URI had been dispatched, this will stop the result handler being called for the old uri.

Parameters
new_urithe new URI to use

◆ uri_handler_started()

bool tbx::URI::uri_handler_started ( )
static

Check if the uri_handler has been started.

If not started from this task, will use version() to check if it exists and caches the result.

Returns
true if it has been started

◆ version()

int tbx::URI::version ( )
static

Get the URI version.

Returns
URI module version * 100 or 0 on error.

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