Cadabra
Computer algebra system for field theory problems
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
cadabra::Properties Class Reference

Description

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_lessproperty_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, 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_comparatorcreate_comparator () const
 
void destroy_comparator (Ex_comparator *) const
 

Member Typedef Documentation

◆ pat_prop_pair_t

typedef std::pair<pattern *, const property *> cadabra::Properties::pat_prop_pair_t

◆ pattern_map_t

typedef std::multimap<const property *, pattern *> cadabra::Properties::pattern_map_t

◆ property_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.

Member Function Documentation

◆ check_label() [1/2]

bool Properties::check_label ( const labelled_property p,
const std::string &  label 
) const
private

◆ check_label() [2/2]

bool Properties::check_label ( const property p,
const std::string &  label 
) const
private

◆ clear()

void Properties::clear ( )

◆ create_comparator()

Ex_comparator * Properties::create_comparator ( ) const
private

◆ destroy_comparator()

void Properties::destroy_comparator ( Ex_comparator c) const
private

◆ get() [1/6]

template<class T >
const T * cadabra::Properties::get ( Ex::iterator  it,
bool  ignore_parent_rel = false 
) const

Normal search: given a pattern, get its property if any.

◆ get() [2/6]

template<class T >
const T * cadabra::Properties::get ( Ex::iterator  it,
const std::string &  label 
) const

Ditto for labelled properties.

◆ get() [3/6]

template<class T >
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.

◆ get() [4/6]

template<class T >
const T * cadabra::Properties::get ( Ex::iterator  it1,
Ex::iterator  it2,
int &  serialnum1,
int &  serialnum2,
bool  ignore_parent_rel = false 
) const

◆ get() [5/6]

template<class T >
const T * cadabra::Properties::get ( Ex::iterator  it,
int &  serialnum,
bool  doserial = true,
bool  ignore_parent_rel = false 
) const

◆ get() [6/6]

template<class T >
const T * cadabra::Properties::get ( Ex::iterator  it,
int &  serialnum,
const std::string &  label,
bool  doserial = true 
) const

◆ get_with_pattern()

template<class T >
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.

◆ get_with_pattern_ext()

template<class T >
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

◆ has()

bool Properties::has ( const property pb,
Ex::iterator  it 
)
private

◆ head()

template<class T >
Ex::iterator cadabra::Properties::head ( Ex::iterator  it,
bool  ignore_parent_rel = false 
) const

◆ insert_list_prop()

void Properties::insert_list_prop ( const std::vector< Ex > &  its,
const list_property pr 
)
private

◆ insert_prop()

void Properties::insert_prop ( const Ex et,
const property pr 
)
private

◆ master_insert()

std::string Properties::master_insert ( Ex  proptree,
property thepropbase 
)

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.

◆ register_property()

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.

◆ serial_number()

int Properties::serial_number ( const property listprop,
const pattern pat 
) const
private

Member Data Documentation

◆ pats

pattern_map_t cadabra::Properties::pats

◆ props

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_properties

registered_property_map_t cadabra::Properties::registered_properties

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