Cadabra
Computer algebra system for field theory problems
|
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>
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::Ex > | for_obj |
Property< Prop >::Property | ( | std::shared_ptr< cadabra::Ex > | obj, |
std::shared_ptr< cadabra::Ex > | params = 0 |
||
) |
std::string Property< Prop >::latex_ | ( | ) | const |
Human-readable form using LaTeX markup.
std::string Property< Prop >::repr_ | ( | ) | const |
Python-parseable form. FIXME: not correct right now.
std::string Property< Prop >::str_ | ( | ) | const |
Human-readable form in text, i.e. no special formatting.
|
private |
|
private |