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::Placeholder< T > Class Template Reference

#include <Placeholder.h>

Inheritance diagram for Pyston::Placeholder< T >:
Inheritance graph
[legend]
Collaboration diagram for Pyston::Placeholder< T >:
Collaboration graph
[legend]

Public Member Functions

 Placeholder (const unsigned pos)
 
std::string repr () const final
 
eval (const Context &, const Arguments &args) const final
 
void visit (Visitor &visitor) const final
 
- Public Member Functions inherited from Pyston::Node< T >
 Node ()
 
virtual ~Node ()=default
 
template<typename... Args>
eval (const Context &context, Args... args) const
 
template<typename... Args>
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

unsigned m_pos
 

Additional Inherited Members

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

Detailed Description

template<typename T>
class Pyston::Placeholder< T >

Placeholder node, pretty much like a variable.

Template Parameters
TType of the placeholder

Definition at line 32 of file Placeholder.h.

Constructor & Destructor Documentation

◆ Placeholder()

template<typename T >
Pyston::Placeholder< T >::Placeholder ( const unsigned  pos)
inlineexplicit

Constructor

Parameters
posPosition of the Placeholder. It will be used to retrieve later the value assigned to it.

Definition at line 39 of file Placeholder.h.

Member Function Documentation

◆ eval()

template<typename T >
T Pyston::Placeholder< T >::eval ( const 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
Exceptions
std::out_of_rangeThere is no value assigned to this placeholder
boost::bad_getThe type of the value assigned to the placeholder does not correspond to the expected type T

Implements Pyston::Node< T >.

Definition at line 56 of file Placeholder.h.

References Pyston::Placeholder< T >::m_pos.

◆ repr()

template<typename T >
std::string Pyston::Placeholder< T >::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 44 of file Placeholder.h.

References Pyston::Placeholder< T >::m_pos, and std::to_string().

Here is the call graph for this function:

◆ visit()

template<typename T >
void Pyston::Placeholder< T >::visit ( Visitor visitor) const
inlinefinalvirtual

Entry point for the visitor

Implements Pyston::NodeBase.

Definition at line 63 of file Placeholder.h.

Member Data Documentation

◆ m_pos

template<typename T >
unsigned Pyston::Placeholder< T >::m_pos
private

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