interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

TypeHelper Class Reference
[libtypehelper]

#include <typehelper/typehelper.hh>

List of all members.


Detailed Description

This class represents a helper program.

It also contains static information on all type helpers, which you can access with findVobjectHelpers, findDataHelpers, addHelper, etc.

This utility does not require VOS, but it includes special features to facilitate VOS applications.

Definition at line 89 of file typehelper.hh.

Public Types

Public Member Functions

Static Public Member Functions


Member Enumeration Documentation

Enumerator:
DATA 
VOBJECT 

Definition at line 91 of file typehelper.hh.


Constructor & Destructor Documentation

TypeHelper::TypeHelper (  )  [inline]

Create a new typehelper for Data with no associated type identifier.

Definition at line 102 of file typehelper.hh.

TypeHelper::TypeHelper ( std::string  init_type  )  [inline]

Create a new typehelper for Data with the givent type identifier.

Definition at line 107 of file typehelper.hh.

TypeHelper::TypeHelper ( std::string  init_type,
RunFunc  vobject_or_data,
std::string  init_target 
) [inline]

Create a new typehelper.

Parameters:
init_type Type of data or Vobject
vobject_or_data DATA or VOBJECT
init_target Temporary file if DATA, URL if VOBJECT.

Definition at line 117 of file typehelper.hh.


Member Function Documentation

static void TypeHelper::addHelper ( const std::string &  configline  )  [static]

Add a helper to the static list of helpers.

Parameters:
configline A string in one of these 2 forms:
  • For "Data" helpers: data(type) = command
  • For "Vobject helpers: vobject(type) = command
You can use the following special character sequences in command:
f
(Data helpers only) Make a temporary file, and replace f with its name
d
(Data helpers only) Replace d with the data.
u
(Vobject helpers only) Replace u with the URL of the starting object.

static void TypeHelper::addProcessEndCallback ( int  pid,
ProcessEndCallback pec 
) [static]

When checkProcesses sees that a process has ended, call the supplied callback function.

See also:
removeProcessEndCallback

checkProcesses

static void TypeHelper::checkProcesses (  )  [static]

If a process associated with a process-end callback has ended, then call the callback and remove the callback.

See also:
addProcessEndCallback

static std::deque<TypeHelper> TypeHelper::findDataHelpers ( const std::string &  type,
const std::string &  tempfile 
) [static]

Find helpers that can handle data with the given type.

Typically this is a MIME type (e.g. "audio/mpeg"). Information loaded from a config file by init() will be used, as well as Gnome handlers if libtypehelper was linked against Gnome libraries.

Returns:
List of matching helpers, in the order in which they were found in configuration files and platform config.
Parameters:
type Type identifier, typically a MIME type.
tempfile Name of a file to use for temporary storage, if one of the matching helpers needs one. (
Todo:
make tempfile optional and figure out our own according to platform policies

static std::deque<TypeHelper> TypeHelper::findVobjectHelpers ( const std::set< std::string > &  types,
const std::string &  objpath 
) [static]

Find helpers that can handle a VOS Vobject with one of the given types.

Returns:
List of helpers, in the order in which they were found in configuration files.
Parameters:
types If a helper is known that can handle one of these types, it is added to the return set.
objpath URL to pass to the helper when run.

std::string TypeHelper::getCommand (  ) 

What is the full command line that will be run for this helper?

const std::deque<std::string>& TypeHelper::getParameters (  )  [inline]

What are the command-line paramaters that will be passed to this helper?

Definition at line 202 of file typehelper.hh.

std::string TypeHelper::getType (  )  [inline]

What is the type for this helper?

Definition at line 197 of file typehelper.hh.

static void TypeHelper::init ( std::string  filename  )  [static]

Load helpers configuration from a config file.

Parameters:
filename Name of the configuration file
Todo:
load multiple filenames, including a default ~/.typehelpers.cfg and INSTALL_DIR/etc/typehelpers.cfg as well as the given filename.
Exceptions:
std::runtime_error if there is an error opening the file

static void TypeHelper::removeProcessEndCallback ( int  pid,
ProcessEndCallback pec 
) [static]

Remove a process-end callback.

See also:
addProcessEndCallback

int TypeHelper::run (  ) 

Run this helper.

Returns:
PID (Process ID) of the child process.

void TypeHelper::setCommand ( const std::string &  cmd  ) 

Set the full command line for this helper: it will be broken into individual arguments on spaces and tabs.

void TypeHelper::setParameters ( std::deque< std::string >  params  )  [inline]

Set the individual command-line parameters for this helper.

params[0] is the command to run, etc.

Definition at line 219 of file typehelper.hh.

void TypeHelper::setType ( std::string  t  )  [inline]

Set the type for this helper.

Definition at line 215 of file typehelper.hh.


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