Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
Property< T > Class Template Reference

Description

template<class T>
class Property< T >

Property is a templated wrapper around a C++ property object.

It provides it with _latex, str and repr methods. In order to have a quick way to figure out in Python whether an object is a property, we derive it from BaseProperty, which is an empty placeholder (in Python BaseProperty is called Property).

Properties can have arguments. These are not parsed by Python, but rather by the C++ side. There is a number of reasons for doing things this way. The most important of them is that this makes it a lot easier for Cadabra to provide useful feedback on parameters which are not valid. So all properties get initialised with two Cadabra Ex objects: the 1st is the pattern to which the property should be attached, the 2nd is the argument of the property, interpreted as a Cadabra expression.

Cadabra properties cannot be proper Python properties, because we need to give the latter names in order to prevent them from going out of scope. So Cadabra keeps a list of 'anonymous property objects in the current scope'.

The question is now what we do when Python keeps a pointer to these objects, and let that pointer escape local scope (e.g. by returning the Python property object). How do we keep it in scope?

#include <PythonCdb.hh>

Inheritance diagram for Property< T >:
BaseProperty

Public Member Functions

 Property (std::shared_ptr< cadabra::Ex > obj, std::shared_ptr< cadabra::Ex > params=0)
 
std::string str_ () const
 Human-readable form in text, i.e. no special formatting. More...
 
std::string latex_ () const
 Human-readable form using LaTeX markup. More...
 
std::string repr_ () const
 Python-parseable form. FIXME: not correct right now. More...
 
template<>
std::string latex_ () const
 

Private Attributes

T * prop
 
std::shared_ptr< cadabra::Exfor_obj
 

Constructor & Destructor Documentation

template<class Prop >
Property< Prop >::Property ( std::shared_ptr< cadabra::Ex obj,
std::shared_ptr< cadabra::Ex params = 0 
)

Member Function Documentation

template<class Prop >
std::string Property< Prop >::latex_ ( ) const

Human-readable form using LaTeX markup.

template<>
std::string Property< LaTeXForm >::latex_ ( ) const
template<class Prop >
std::string Property< Prop >::repr_ ( ) const

Python-parseable form. FIXME: not correct right now.

template<class Prop >
std::string Property< Prop >::str_ ( ) const

Human-readable form in text, i.e. no special formatting.

Member Data Documentation

template<class T >
std::shared_ptr<cadabra::Ex> Property< T >::for_obj
private
template<class T >
T* Property< T >::prop
private

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