Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

TypeChain Class Reference

This class helps you decode data with known encodings. More...

#include <typechain.hh>

List of all members.

Public Member Functions

Static Public Member Functions

Static Public Attributes


Detailed Description

This class helps you decode data with known encodings.

Use it's static methods for registering and unregistering type/encoding handlers (TypeHandler), and for processing data according to typechain identifiers. Typechain is described in more detail in the Virtual Object System manual (see http://interreality.org/doc/manual/html)

Todo:
encoding

methods that operate on streams

support "?" (unknown type): if type is unknown (no type identifier given), attempt to find a magic number or otherwise guess the datatype, and re-decode until next type in typestring (or an unknown type) is reached.

See also:
TypeHandler
Author:
Reed Hedges <reed@zerohour.net> February, 2002

Definition at line 68 of file typechain.hh.


Member Function Documentation

int TypeChain::countEncodings const string &  type  ) 
 

Definition at line 333 of file typechain.cc.

string TypeChain::decode string &  data,
const string &  type
[inline, static]
 

Decode data, with no params list.

Definition at line 136 of file typechain.hh.

string TypeChain::decode string &  data,
const string &  type,
map< string, string > &  params
[static]
 

Decode data (stored in a string) according to a type identifier.

For each unit in the type identifier, the first type handler in the handlers list is

Parameters:
data Reference to the data being processed: will be replaced with the new data. (your old data WILL be clobbered!!)
type type identifier. (not clobbered)
params parameters may be passed to and from the handlers using this map.
Returns:
the new type identifier for the new data.

Definition at line 235 of file typechain.cc.

Referenced by Property::checkDecoded(), main(), and FileProperty::read().

void TypeChain::deleteHandler const string &  type  )  [static]
 

Unregister a type handler, and also delete it: it will be removed from internal list, and the C++ handler object will be destroyed with 'delete'.

Parameters:
type type/encoding identifier.

Definition at line 265 of file typechain.cc.

void TypeChain::encode string &  data,
const string &  type
[inline, static]
 

Encode data, with no params list.

Definition at line 152 of file typechain.hh.

void TypeChain::encode string &  data,
const string &  type,
map< string, string > &  params
[static]
 

Encode data according to type identifier, analagous to decode.

Parameters:
data Reference to data to encode. it will be replaced by new encoded data.
type type identifier to encode towards.
Returns:
the new type identifer (ie, should be identical to param type if successful)
Warning:
does nothing currently

Definition at line 244 of file typechain.cc.

Referenced by main().

string TypeChain::guessTypeFromFilename const string &  filename  )  [static]
 

Guess at the type of a file, given the filename with an abbreviated extension, based on currently registered set of type handlers.

Definition at line 278 of file typechain.cc.

Referenced by main().

void TypeChain::initialize const char *  dirname,
... 
[static]
 

Initialize plugins.

Parameters:
dirname,... search these directories for plugins as well as standard location. terminate list with 0.
See also:
initialize();
Bug:
On Mac OSX: crashes if there are any files in a plugins directory that are not MH_BUNDLE files.

Definition at line 189 of file typechain.cc.

void TypeChain::initialize  )  [static]
 

Initialize plugins.

Scans the plugins directory and loads (or schedules for later loading) dynamically loadable libraries whose names match a certain form. The plugin libraries should be named like this: Plugins should have a void function with no arguments named plugin_init(), which should call TypeChain::registerHandler().

Bug:
On Mac OSX: crashes if there are any files in the plugins directory that are not MH_BUNDLE files.

Definition at line 183 of file typechain.cc.

Referenced by main().

string TypeChain::makeFilename const string &  type,
const string &  basename
[static]
 

Construct useful filename from type.

Definition at line 297 of file typechain.cc.

Referenced by main().

void TypeChain::registerHandler TypeHandler handler  )  [static]
 

Register a type handler.

If it already exists, it will be replaced.

Parameters:
handler instance of a TypeHandler derivation. don't use the same handler pointer twice: the uninitialize() method will attempt to delete it twice.

Definition at line 250 of file typechain.cc.

Referenced by initialize().

TypeHandler * TypeChain::removeHandler const string &  type  )  [static]
 

Unregister a type handler (remove from internal list).

Returns:
the handler removed (TypeHandler*). You probably want to delete it if you're not going to use it anymore.
Parameters:
type type/encoding identifier.

Definition at line 258 of file typechain.cc.

void TypeChain::uninitialize  )  [static]
 

Uninitialize typechain: all handlers are deleted and DLL's are closed.

Definition at line 212 of file typechain.cc.

Referenced by main().


Member Data Documentation

map< string, string > TypeChain::filename_extensions [static]
 

internal list of abbreviated type names for filename "extensions" and type names: used by guessTypeFromFilename().

Definition at line 180 of file typechain.cc.

Referenced by guessTypeFromFilename(), registerHandler(), and uninitialize().

map< string, TypeHandler * > TypeChain::handlers [static]
 

the internal handlers list, which is a map<string, TypeHandler*>.

If a key exists, but the type handler is a PluginPlaceholder, that means that the handler was detected as a plugin, but not loaded.

Note:
Modify this map at your own risk. There are no garauntees here, especially regarding future version compatability.

Definition at line 179 of file typechain.cc.

Referenced by deleteHandler(), registerHandler(), removeHandler(), and uninitialize().


The documentation for this class was generated from the following files:
Generated on Tue Aug 12 03:55:58 2003 for Interreality Project - VOS by doxygen 1.3.2