40 bool match(
const Properties&,
const Ex::iterator&,
bool ignore_parent_rel=
false)
const;
50 typedef std::pair<std::string, Ex::iterator>
kvpair_t;
139 virtual void latex(std::ostream&)
const;
141 virtual std::string
name()
const=0;
187 virtual std::string
name()
const {
return std::string(
"Stay Away"); };
195 virtual std::string
name()
const {
return std::string(
"PropertyInherit"); };
216 typedef internal_property_map_t::iterator
iterator;
236 typedef std::multimap<nset_t::iterator, pat_prop_pair_t, nset_it_less>
property_map_t;
254 template<
class T>
const T*
get(Ex::iterator,
bool ignore_parent_rel=
false)
const;
255 template<
class T>
const T*
get()
const;
256 template<
class T>
const T*
get_composite(Ex::iterator,
bool ignore_parent_rel=
false)
const;
257 template<
class T>
const T*
get_composite(Ex::iterator,
int& serialnum,
bool doserial=
true,
bool ignore_parent_rel=
false)
const;
259 template<
class T>
const T*
get_composite(Ex::iterator,
const std::string& label)
const;
260 template<
class T>
const T*
get_composite(Ex::iterator,
int& serialnum,
const std::string& label,
bool doserial=
true)
const;
262 template<
class T>
const T*
get_composite(Ex::iterator, Ex::iterator,
bool ignore_parent_rel=
false)
const;
263 template<
class T>
const T*
get_composite(Ex::iterator, Ex::iterator,
int&,
int&,
bool ignore_parent_rel=
false)
const;
267 template<
class T> Ex::iterator
head(Ex::iterator,
bool ignore_parent_rel=
false)
const;
292 return get_composite<T>(it, ignore_parent_rel);
299 return get_composite<T>(it, tmp,
false, ignore_parent_rel);
310 std::pair<property_map_t::const_iterator, property_map_t::const_iterator> pit=
props.equal_range(it->name_only());
315 bool wildcards=
false;
317 property_map_t::const_iterator walk=pit.first;
318 while(walk!=pit.second) {
319 if(wildcards==(*walk).second.first->children_wildcard()) {
321 ret=dynamic_cast<const T *>((*walk).second.second);
323 if((*walk).second.first->match(*
this, it, ignore_parent_rel)) {
325 std::pair<pattern_map_t::const_iterator, pattern_map_t::const_iterator>
326 pm=
pats.equal_range((*walk).second.second);
328 while(pm.first!=pm.second) {
329 if((*pm.first).second==(*walk).second.first)
339 if(dynamic_cast<const PropertyInherit *>((*walk).second.second))
341 else if(
dynamic_cast<const Inherit<T> *
>((*walk).second.second))
346 if(!wildcards && !ret) {
357 if(!ret && inherits) {
359 Ex::sibling_iterator sib=it.begin();
360 while(sib!=it.end()) {
361 const T* tmp=get_composite<T>((Ex::iterator)(sib), serialnum, doserial);
378 return get_composite<T>(it, tmp, label,
false);
386 std::pair<property_map_t::const_iterator, property_map_t::const_iterator> pit=
props.equal_range(it->name_only());
391 bool wildcards=
false;
393 property_map_t::const_iterator walk=pit.first;
394 while(walk!=pit.second) {
395 if(wildcards==(*walk).second.first->children_wildcard()) {
396 if((*walk).second.first->match(*
this, it)) {
397 ret=dynamic_cast<const T *>((*walk).second.second);
400 if(ret->label!=label && ret->label!=
"all")
404 serialnum=
serial_number( (*walk).second.second, (*walk).second.first );
408 if(dynamic_cast<const PropertyInherit *>((*walk).second.second))
410 else if(
dynamic_cast<const Inherit<T> *
>((*walk).second.second))
416 if(!wildcards && !ret) wildcards=
true;
421 if(!ret && inherits) {
422 Ex::sibling_iterator sib=it.begin();
423 while(sib!=it.end()) {
424 const T* tmp=get_composite<T>((Ex::iterator)(sib), serialnum, label, doserial);
439 return get_composite<T>(it1,it2,tmp1,tmp2, ignore_parent_rel);
449 bool inherits1=
false, inherits2=
false;
450 std::pair<property_map_t::const_iterator, property_map_t::const_iterator> pit1=
props.equal_range(it1->name_only());
451 std::pair<property_map_t::const_iterator, property_map_t::const_iterator> pit2=
props.equal_range(it2->name_only());
453 property_map_t::const_iterator walk1=pit1.first;
454 while(walk1!=pit1.second) {
455 if((*walk1).second.first->match(*
this, it1, ignore_parent_rel)) {
456 ret1=dynamic_cast<const T *>((*walk1).second.second);
458 property_map_t::const_iterator walk2=pit2.first;
459 while(walk2!=pit2.second) {
460 if((*walk2).second.first->match(*
this, it2, ignore_parent_rel)) {
461 ret2=dynamic_cast<const T *>((*walk2).second.second);
463 if(ret1==ret2 && walk1!=walk2) {
464 serialnum1=
serial_number( (*walk1).second.second, (*walk1).second.first );
465 serialnum2=
serial_number( (*walk2).second.second, (*walk2).second.first );
471 if(dynamic_cast<const PropertyInherit *>((*walk2).second.second))
476 if(dynamic_cast<const PropertyInherit *>((*walk1).second.second))
483 if(!found && (inherits1 || inherits2)) {
484 Ex::sibling_iterator sib1, sib2;
485 if(inherits1) sib1=it1.begin();
487 bool keepgoing1=
true;
489 bool keepgoing2=
true;
490 if(inherits2) sib2=it2.begin();
493 const T* tmp=get_composite<T>((Ex::iterator)(sib1), (Ex::iterator)(sib2), serialnum1, serialnum2, ignore_parent_rel);
499 if(!inherits2 || ++sib2==it2.end())
502 if(!inherits1 || ++sib1==it1.end())
517 nset_t::iterator nit=
name_set.insert(std::string(
"")).first;
518 std::pair<property_map_t::const_iterator, property_map_t::const_iterator> pit=
519 props.equal_range(nit);
520 while(pit.first!=pit.second) {
521 ret=dynamic_cast<const T *>((*pit.first).second.second);
533 if(get<PropertyInherit>(dn, ignore_parent_rel)) {
bool hidden_
Definition: Props.hh:161
void register_property(property *(*)(), const std::string &name)
Registering properties.
Definition: Props.cc:169
bool parse_to_keyvals(const Ex &, keyval_t &)
Definition: Props.cc:268
bool match(const Properties &, const Ex::iterator &, bool ignore_parent_rel=false) const
Definition: Props.cc:43
match_t
Definition: Props.hh:150
bool has(const property *, Ex::iterator)
Definition: Props.cc:129
Basic storage class for symbolic mathemematical expressions.
Definition: Storage.hh:139
Ex::iterator head(Ex::iterator, bool ignore_parent_rel=false) const
Definition: Props.hh:529
const T * get() const
Definition: Props.hh:513
Ex obj
Definition: Props.hh:43
PropertyInherit is like Inherit<T> for all properties.
Definition: Props.hh:193
virtual ~property()
Definition: Props.hh:110
void insert_prop(const Ex &, const property *)
Definition: Props.cc:338
void erase(iterator)
Definition: Props.cc:211
const T * get_composite(Ex::iterator, bool ignore_parent_rel=false) const
Definition: Props.hh:296
std::pair< pattern *, const property * > pat_prop_pair_t
Definition: Props.hh:227
void insert_list_prop(const std::vector< Ex > &, const list_property *)
Definition: Props.cc:424
void clear()
Definition: Props.cc:145
virtual void validate(const Kernel &, const Ex &) const
Definition: Props.cc:244
std::string label
Definition: Props.hh:167
kvlist_t keyvals
Definition: Props.hh:65
Arguments to properties get parsed into a keyval_t structure.
Definition: Props.hh:48
bool parse_one_argument(Ex::iterator arg, keyval_t &keyvals)
Definition: Props.cc:248
pattern_map_t pats
Definition: Props.hh:251
registered_property_map_t registered_properties
Definition: Props.hh:226
Base class for all properties, handling argument parsing and defining the interface.
Definition: Props.hh:107
kvlist_t::iterator iterator
Definition: Props.hh:54
const_iterator end() const
Definition: Props.cc:201
const_iterator find(const std::string &) const
Definition: Props.cc:174
virtual void latex(std::ostream &) const
Display the property on the stream.
Definition: Props.cc:294
std::multimap< const property *, pattern * > pattern_map_t
Definition: Props.hh:237
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 t...
Definition: Props.hh:236
virtual bool parse(Kernel &, std::shared_ptr< Ex >, keyval_t &) override
Definition: Props.cc:309
~registered_property_map_t()
Definition: Props.cc:164
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Algorithm.cc:1006
void push_back(const kvpair_t &)
Definition: Props.cc:206
property_map_t props
The following two maps own the pointers to the properties and patterns stored in them; use clear() to...
Definition: Props.hh:250
virtual std::string name() const
Definition: Props.hh:187
const_iterator begin() const
Definition: Props.cc:196
pattern()
Definition: Props.cc:34
std::map< std::string, property *(*)()> internal_property_map_t
Definition: Props.hh:215
Something cannot be both a list property and a normal property at the same time, so we can safely inh...
Definition: Props.hh:173
int serial_number(const property *, const pattern *) const
Definition: Props.cc:519
nset_t name_set
Definition: Storage.cc:31
virtual std::string name() const =0
internal_property_map_t store
Definition: Props.hh:218
kvpair_t value_type
Definition: Props.hh:55
If a property X derives from Inherit<Y>, and get<Y> is called on an object which has an X property (b...
Definition: Props.hh:184
virtual match_t equals(const property *) const
Definition: Props.cc:304
bool children_wildcard() const
Definition: Props.cc:121
kvlist_t::const_iterator const_iterator
Definition: Props.hh:53
virtual std::string name() const
Definition: Props.hh:195
virtual ~Inherit()
Definition: Props.hh:186
std::list< kvpair_t > kvlist_t
Definition: Props.hh:51
std::string master_insert(Ex proptree, property *thepropbase)
Register a property for the indicated Ex.
Definition: Props.cc:569
internal_property_map_t::iterator iterator
Definition: Props.hh:216
bool hidden(void) const
Definition: Props.cc:227
Class holding a collection of properties attached to expressions.
Definition: Props.hh:208
property(bool hidden=false)
Definition: Props.cc:217
virtual bool parse(Kernel &, keyval_t &keyvals)
Definition: Props.cc:232
virtual std::string unnamed_argument() const
Definition: Props.cc:299
std::pair< std::string, Ex::iterator > kvpair_t
Definition: Props.hh:50