SXEval 1.0.3
A generic s-expression interpreter library.
Loading...
Searching...
No Matches
sxeval::operations::OperationsFactory< T > Class Template Reference

The OperationsFactory class is used to manage operations. More...

#include <OperationsFactory.hpp>

Public Member Functions

 OperationsFactory ()
 Default constructor.
 
template<typename OP >
std::enable_if< std::is_base_of< sxeval::AOperation< T >, OP >::value >::type add ()
 Register an operation.
 
std::unique_ptr< AOperation< T > > create (const std::string &key, const std::vector< IInstruction< T > * > args)
 Instantiate an operation from its key and arguments.
 
T compute (const std::string &key, const std::vector< IInstruction< T > * > args) const
 Compute the result of an operation from its key and arguments.
 

Detailed Description

template<typename T>
class sxeval::operations::OperationsFactory< T >

The OperationsFactory class is used to manage operations.

Template Parameters
TThe type of values handled by the SXEval library. The supported types are int, signed char, short int, long int, unsigned int, unsigned char, unsigned long int, float, double and long double.

Constructor & Destructor Documentation

◆ OperationsFactory()

template<typename T >
sxeval::operations::OperationsFactory< T >::OperationsFactory ( )

Default constructor.

Member Function Documentation

◆ add()

template<typename T >
template<typename OP >
std::enable_if< std::is_base_of< sxeval::AOperation< T >, OP >::value >::type sxeval::operations::OperationsFactory< T >::add ( )

Register an operation.

Template Parameters
OPThe operation to register. The operation must inherit from sxeval::AOperation<T> and provide the static members KEY, ARITY_MIN and ARITY_MAX.

◆ compute()

template<typename T >
T sxeval::operations::OperationsFactory< T >::compute ( const std::string &  key,
const std::vector< IInstruction< T > * >  args 
) const

Compute the result of an operation from its key and arguments.

Parameters
keyThe key of the operation to compute.
argsThe arguments of the operation.
Returns
The result of the operation.
Exceptions
std::invalid_argumentif the key is unknown or if the number of arguments is not valid for the operation.

◆ create()

template<typename T >
std::unique_ptr< sxeval::AOperation< T > > sxeval::operations::OperationsFactory< T >::create ( const std::string &  key,
const std::vector< IInstruction< T > * >  args 
)

Instantiate an operation from its key and arguments.

Parameters
keyThe key of the operation to create.
argsThe arguments of the operation.
Returns
A unique pointer to the created operation.
Exceptions
std::invalid_argumentif the key is unknown or if the number of arguments is not valid for the operation.

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