Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Pyston::Cast< To, From > Class Template Reference

#include <Cast.h>

Inheritance diagram for Pyston::Cast< To, From >:
Inheritance graph
[legend]
Collaboration diagram for Pyston::Cast< To, From >:
Collaboration graph
[legend]

Public Member Functions

 Cast (const std::shared_ptr< Node< From > > &node)
 
std::string repr () const final
 
To eval (const Context &context, const Arguments &args) const final
 
void visit (Visitor &visitor) const final
 
- Public Member Functions inherited from Pyston::Node< To >
 Node ()
 
virtual ~Node ()=default
 
To eval (const Context &context, Args... args) const
 
To eval (Args... args) const
 
- Public Member Functions inherited from Pyston::NodeBase
 NodeBase (const std::type_index &type_index)
 
virtual ~NodeBase ()=default
 
const std::type_indextype () const
 

Private Attributes

std::shared_ptr< Node< From > > m_node
 

Additional Inherited Members

- Protected Member Functions inherited from Pyston::Node< To >
To eval_helper (const Context &context, Arguments &arguments) const
 
To eval_helper (const Context &context, Arguments &arguments, A0 v0, AN... an) const
 

Detailed Description

template<typename To, typename From>
class Pyston::Cast< To, From >

Node type that casts one type of value into another. This is required so we can, for instance, add a boolean to a float.

Template Parameters
ToCast type
FromCasted type

Definition at line 42 of file Cast.h.

Constructor & Destructor Documentation

◆ Cast()

template<typename To , typename From >
Pyston::Cast< To, From >::Cast ( const std::shared_ptr< Node< From > > &  node)
inlineexplicit

Constructor

Parameters
nodeWrapped node, for which its eval result will be casted to To

Definition at line 49 of file Cast.h.

Member Function Documentation

◆ eval()

template<typename To , typename From >
To Pyston::Cast< To, From >::eval ( const Context context,
const Arguments args 
) const
inlinefinalvirtual

Evaluate the computing tree

In principle one could avoid to pass any values here, and assign directly the final value to the placeholders that were used to create this tree. However, this would cause the placeholders not to be thread-safe, and a tree would have to be either cloned, either protected by a mutex. Passing the values as an argument allows making the full tree immutable once built, and fully thread safe.

Returns
Result of the evaluation

Implements Pyston::Node< To >.

Definition at line 61 of file Cast.h.

References Pyston::Cast< To, From >::m_node.

◆ repr()

template<typename To , typename From >
std::string Pyston::Cast< To, From >::repr ( ) const
inlinefinalvirtual

Returns
A human readable representation of the node
Note
It should not include the representation of the children, if any. That's what visitors are for.

Implements Pyston::NodeBase.

Definition at line 54 of file Cast.h.

◆ visit()

template<typename To , typename From >
void Pyston::Cast< To, From >::visit ( Visitor visitor) const
inlinefinalvirtual

Entry point for the visitor

Implements Pyston::NodeBase.

Definition at line 68 of file Cast.h.

References Pyston::Cast< To, From >::m_node.

Member Data Documentation

◆ m_node

template<typename To , typename From >
std::shared_ptr<Node<From> > Pyston::Cast< To, From >::m_node
private

Definition at line 75 of file Cast.h.

Referenced by Pyston::Cast< To, From >::eval(), and Pyston::Cast< To, From >::visit().


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