Cadabra
Computer algebra system for field theory problems
|
Class holding a collection of properties attached to expressions.
Symbols and expressions do not have a default meaning in Cadabra. They get their meaning by attaching properties to them. When the core manipulator calls an algorithm object, it passes an instance of the Properties class along with the expression tree on which to act, so that the algorithm can figure out what the symbols in the expression tree mean.
#include <Props.hh>
Classes | |
class | registered_property_map_t |
Public Types | |
typedef std::pair< pattern *, const property * > | pat_prop_pair_t |
typedef std::multimap< nset_t::iterator, pat_prop_pair_t, nset_it_less > | property_map_t |
We keep two multi-maps: one from the pattern to the property (roughly) and one from the property to the pattern. More... | |
typedef std::multimap< const property *, pattern * > | pattern_map_t |
Public Member Functions | |
void | register_property (property *(*)(), const std::string &name) |
Registering properties. More... | |
std::string | master_insert (Ex proptree, const property *thepropbase) |
Register a property for the indicated Ex. More... | |
void | clear () |
template<class T > | |
const T * | get (Ex::iterator, bool ignore_parent_rel=false) const |
Normal search: given a pattern, get its property if any. More... | |
template<class T > | |
const T * | get (Ex::iterator, int &serialnum, bool doserial=true, bool ignore_parent_rel=false) const |
template<class T > | |
const T * | get (Ex::iterator, const std::string &label) const |
Ditto for labelled properties. More... | |
template<class T > | |
const T * | get (Ex::iterator, int &serialnum, const std::string &label, bool doserial=true) const |
template<class T > | |
const T * | get (Ex::iterator, Ex::iterator, bool ignore_parent_rel=false) const |
For list properties: given two patterns, get a common property. More... | |
template<class T > | |
const T * | get (Ex::iterator, Ex::iterator, int &, int &, bool ignore_parent_rel=false) const |
template<class T > | |
std::pair< const T *, const pattern * > | get_with_pattern (Ex::iterator, int &serialnum, const std::string &label, bool doserial=true, bool ignore_parent_rel=false) const |
General property finder, which will return not only the property but also the pattern which matched the given node. More... | |
template<class T > | |
std::pair< const T *, const pattern * > | get_with_pattern_ext (Ex::iterator, Ex_comparator &, int &serialnum, const std::string &label, bool doserial=true, bool ignore_parent_rel=false) const |
template<class T > | |
Ex::iterator | head (Ex::iterator, bool ignore_parent_rel=false) const |
Public Attributes | |
registered_property_map_t | registered_properties |
property_map_t | props |
The following two maps own the pointers to the properties and patterns stored in them; use clear() to clean up. More... | |
pattern_map_t | pats |
Private Member Functions | |
void | insert_prop (const Ex &, const property *) |
void | insert_list_prop (const std::vector< Ex > &, const list_property *) |
bool | check_label (const property *, const std::string &) const |
bool | check_label (const labelled_property *, const std::string &) const |
bool | has (const property *, Ex::iterator) |
int | serial_number (const property *, const pattern *) const |
Ex_comparator * | create_comparator () const |
void | destroy_comparator (Ex_comparator *) const |
typedef std::pair<pattern *, const property *> cadabra::Properties::pat_prop_pair_t |
typedef std::multimap<const property *, pattern *> cadabra::Properties::pattern_map_t |
typedef std::multimap<nset_t::iterator, pat_prop_pair_t, nset_it_less> cadabra::Properties::property_map_t |
We keep two multi-maps: one from the pattern to the property (roughly) and one from the property to the pattern.
These are both multi-maps because one pattern can have multiple properties assigned to it, and one property can be assigned to multiple properties.
When we delete properties, we check the pats map to see if the reference count for that property has dropped to zero.
|
private |
|
private |
void Properties::clear | ( | ) |
|
private |
|
private |
const T * cadabra::Properties::get | ( | Ex::iterator | it, |
bool | ignore_parent_rel = false |
||
) | const |
Normal search: given a pattern, get its property if any.
const T * cadabra::Properties::get | ( | Ex::iterator | it, |
const std::string & | label | ||
) | const |
Ditto for labelled properties.
const T * cadabra::Properties::get | ( | Ex::iterator | it1, |
Ex::iterator | it2, | ||
bool | ignore_parent_rel = false |
||
) | const |
For list properties: given two patterns, get a common property.
const T * cadabra::Properties::get | ( | Ex::iterator | it1, |
Ex::iterator | it2, | ||
int & | serialnum1, | ||
int & | serialnum2, | ||
bool | ignore_parent_rel = false |
||
) | const |
const T * cadabra::Properties::get | ( | Ex::iterator | it, |
int & | serialnum, | ||
bool | doserial = true , |
||
bool | ignore_parent_rel = false |
||
) | const |
const T * cadabra::Properties::get | ( | Ex::iterator | it, |
int & | serialnum, | ||
const std::string & | label, | ||
bool | doserial = true |
||
) | const |
std::pair< const T *, const pattern * > cadabra::Properties::get_with_pattern | ( | Ex::iterator | it, |
int & | serialnum, | ||
const std::string & | label, | ||
bool | doserial = true , |
||
bool | ignore_parent_rel = false |
||
) | const |
General property finder, which will return not only the property but also the pattern which matched the given node.
All 'get' functions above call this function; all functionality is contained in here.
std::pair< const T *, const pattern * > cadabra::Properties::get_with_pattern_ext | ( | Ex::iterator | it, |
Ex_comparator & | comp, | ||
int & | serialnum, | ||
const std::string & | label, | ||
bool | doserial = true , |
||
bool | ignore_parent_rel = false |
||
) | const |
|
private |
Ex::iterator cadabra::Properties::head | ( | Ex::iterator | it, |
bool | ignore_parent_rel = false |
||
) | const |
|
private |
Register a property for the indicated Ex.
Takes both normal and list properties and works out which insert calls to make. The property ownership is transferred to us on using this call.
void Properties::register_property | ( | property * | *)(, |
const std::string & | name | ||
) |
Registering properties.
When inserting a property or list_property, ownership of the property gets transferred to this class.
pattern_map_t cadabra::Properties::pats |
property_map_t cadabra::Properties::props |
The following two maps own the pointers to the properties and patterns stored in them; use clear() to clean up.
Note that pointers can sit in in more than one entry in this map (when they are pointing to list_property objects, which are shared between patterns).
registered_property_map_t cadabra::Properties::registered_properties |