Alexandria 2.31.4
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Pyston::Placeholder< AttributeSet > Class Reference

#include <AttributeSet.h>

Inheritance diagram for Pyston::Placeholder< AttributeSet >:
Collaboration diagram for Pyston::Placeholder< AttributeSet >:

Classes

struct  AttrGetterFactory

Public Member Functions

 Placeholder (const unsigned pos, const AttributeSet &attrs)
boost::python::object get (const std::string &name) const
std::string repr () const final
AttributeSet 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
AttributeSet m_attrs

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

Specialization of Placeholder for object-like variables. Note that, unlike other placeholders, this is used only during the evaluation. The final tree uses AttrGetter instances

Definition at line 85 of file AttributeSet.h.

Constructor & Destructor Documentation

◆ Placeholder()

Pyston::Placeholder< AttributeSet >::Placeholder ( const unsigned pos,
const AttributeSet & attrs )
inline

Constructor

Parameters
nameName of the Placeholder. It will be used to retrieve later the value assigned to it.
attrsAcceptable attribute names, with an instance of the acceptable type

Definition at line 94 of file AttributeSet.h.

References m_attrs, and m_pos.

Member Function Documentation

◆ eval()

AttributeSet Pyston::Placeholder< AttributeSet >::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.

◆ get()

boost::python::object Pyston::Placeholder< AttributeSet >::get ( const std::string & name) const
inline

Unfortunately we have to return directly a python object wrapping the appropiate AttrGetter

Parameters
nameParameter name
Exceptions
UnrecoverableErrorIf the name is not a known parameter. Fallback to Python interpretation will not help.

It uses a boost visitor to generate the right AttrGetter depending on the value stored on the prototype object passed to the constructor

Definition at line 107 of file AttributeSet.h.

References m_attrs, and m_pos.

◆ repr()

std::string Pyston::Placeholder< AttributeSet >::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.

◆ visit()

void Pyston::Placeholder< AttributeSet >::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_attrs

Definition at line 115 of file AttributeSet.h.

Referenced by get(), and Placeholder().

◆ m_pos

unsigned Pyston::Placeholder< AttributeSet >::m_pos
private

Definition at line 114 of file AttributeSet.h.

Referenced by get(), and Placeholder().


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