class Dispatcher

Link between elements and operations. Executes operations on elments. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

Public Types

Public Methods


Detailed Description

Implementation of multimethods. Insipred/copied from Alexandrescu [Modern C++ Design].

By taking base element arguments and an operation, it will execute the correct operation based on the concrete type of the arguments.

Similar to an ElementFactory.

typedef vector<const Element*> ArgList

ArgList

 Dispatcher ()

Dispatcher

OpNotFound (class)

OpNotFound

If there is no combination for the given operation and element types.

template<class L, class R, Element* (*funct)(const L&,const R&)> void  add (const BinOper& op)

add

Method to register a binary operation callback with dispatcher.

Parameters:

Lconcrete class of first argument
Rconcrete class of second argument
functfunction to be called to perform operation.
opbinary operation to be registered.
template<class T, Element* (*funct)(const T&)> void  add (const UnOper& op)

add

Method to register a unary operation callback with dispatcher.

Parameters:

Tconcrete class of argument
functfunction to be called to perform operation.
opunary operation to be registered.
Element*  run (const Oper& op, unsigned argc, const Element** argv)

run

[const]

Execute an n-ary operation.

Throws an exception on failure.

Parameters:

opoperation to dispatch.
argsarguments of operation.

Returns: result of operation.

Element*  run (const UnOper& op, const Element& arg)

run

[const]

Execute an unary operation.

Parameters:

opOperation to perform.
argArgument of operation.

Returns: Result of operation. Caller is responsible for delete.

Element*  run (const BinOper& op, const Element& left, const Element& right)

run

[const]

Execute a binary operation.

Parameters:

opOperation to perform.
leftfirst argument.
rightsecond argument.

Returns: result of operation. Caller is responsible for delete.


Generated by: pavlin on possum.icir.org on Thu Mar 9 04:43:23 2006, using kdoc $.