www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
AttribTagBase Class Referenceabstract

AttribTagBase tracks all (vector or matrix) tags associated with an object. More...

#include <Attributes.h>

Inheritance diagram for AttribTagBase:
[legend]

Public Member Functions

 AttribTagBase (TheWarehouse &w, const std::string &attrib_name)
 
 AttribTagBase (TheWarehouse &w, TagID tag, const std::string &attrib_name)
 
 AttribTagBase (TheWarehouse &w, const std::set< TagID > &tags, const std::string &attrib_name)
 
virtual bool isMatch (const Attribute &other) const override
 isMatch returns true if the meta-data stored in this attribute is equivalent to that stored in other. More...
 
virtual bool isEqual (const Attribute &other) const override
 isEqual returns true if the meta-data stored in this attribute is identical to that stored in other. More...
 
 hashfunc (_vals)
 
bool operator== (const Attribute &other) const
 
bool operator!= (const Attribute &other) const
 
unsigned int id () const
 returns the unique attribute ID associated with all attributes that have the same (mose derived) class as this object. More...
 
virtual std::size_t hash () const =0
 This function must return a deterministic value that is uniquely determined by the data the attribute holds (i.e. More...
 
virtual void initFrom (const MooseObject *obj)=0
 initFrom reads and stores the desired meta-data from obj for later matching comparisons. More...
 
virtual std::unique_ptr< Attributeclone () const =0
 clone creates and returns and identical (deep) copy of this attribute - i.e. More...
 

Protected Attributes

std::vector< TagID_vals
 

Detailed Description

AttribTagBase tracks all (vector or matrix) tags associated with an object.

When running queries, an object matches true if it has at least one tag in common with the tags in the query attribute.

Definition at line 66 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribTagBase() [1/3]

AttribTagBase::AttribTagBase ( TheWarehouse w,
const std::string &  attrib_name 
)
inline

Definition at line 69 of file Attributes.h.

69 : Attribute(w, attrib_name) {}
Attribute(TheWarehouse &w, const std::string name)
Constructs/initializes a new attribute with the specified name for use in warehouse w...
Definition: TheWarehouse.C:36

◆ AttribTagBase() [2/3]

AttribTagBase::AttribTagBase ( TheWarehouse w,
TagID  tag,
const std::string &  attrib_name 
)
inline

Definition at line 70 of file Attributes.h.

71  : Attribute(w, attrib_name)
72  {
73  _vals.push_back(tag);
74  }
Attribute(TheWarehouse &w, const std::string name)
Constructs/initializes a new attribute with the specified name for use in warehouse w...
Definition: TheWarehouse.C:36
std::vector< TagID > _vals
Definition: Attributes.h:87

◆ AttribTagBase() [3/3]

AttribTagBase::AttribTagBase ( TheWarehouse w,
const std::set< TagID > &  tags,
const std::string &  attrib_name 
)
inline

Definition at line 75 of file Attributes.h.

76  : Attribute(w, attrib_name)
77  {
78  for (auto tag : tags)
79  _vals.push_back(tag);
80  }
Attribute(TheWarehouse &w, const std::string name)
Constructs/initializes a new attribute with the specified name for use in warehouse w...
Definition: TheWarehouse.C:36
std::vector< TagID > _vals
Definition: Attributes.h:87

Member Function Documentation

◆ clone()

virtual std::unique_ptr<Attribute> Attribute::clone ( ) const
pure virtualinherited

clone creates and returns and identical (deep) copy of this attribute - i.e.

the result of clone should return true if passed into isMatch.

Referenced by TheWarehouse::update().

◆ hash()

virtual std::size_t Attribute::hash ( ) const
pure virtualinherited

This function must return a deterministic value that is uniquely determined by the data the attribute holds (i.e.

is initialized with). Ideally, the data should be uniformly and randomly distributed across the domain of size_t values - e.g. 1 and 2 should hash to completely unrelated values. Use of std::hash for POD is encouraged. A convenience hash_combine function is also provided to combine the results an existing hash with one or more other values.

Referenced by std::hash< Attribute >::operator()().

◆ hashfunc()

AttribTagBase::hashfunc ( _vals  )

◆ id()

unsigned int Attribute::id ( ) const
inlineinherited

returns the unique attribute ID associated with all attributes that have the same (mose derived) class as this object.

This ID is determined at construction time this

Definition at line 67 of file TheWarehouse.h.

Referenced by std::hash< Attribute >::operator()().

67 { return _id; }

◆ initFrom()

virtual void Attribute::initFrom ( const MooseObject obj)
pure virtualinherited

◆ isEqual()

bool AttribTagBase::isEqual ( const Attribute other) const
overridevirtual

isEqual returns true if the meta-data stored in this attribute is identical to that stored in other.

isEqual does not need to check/compare the values from the instances' id() functions.

Implements Attribute.

Definition at line 93 of file Attributes.C.

94 {
95  auto a = dynamic_cast<const AttribTagBase *>(&other);
96  if (!a || a->_vals.size() != _vals.size())
97  return false;
98 
99  for (size_t i = 0; i < a->_vals.size(); i++)
100  if (a->_vals[i] != _vals[i])
101  return false;
102  return true;
103 }
std::vector< TagID > _vals
Definition: Attributes.h:87
AttribTagBase tracks all (vector or matrix) tags associated with an object.
Definition: Attributes.h:66

◆ isMatch()

bool AttribTagBase::isMatch ( const Attribute other) const
overridevirtual

isMatch returns true if the meta-data stored in this attribute is equivalent to that stored in other.

This is is for query matching - not exact equivalence. isMatch does not need to check/compare the values from the instances' id() functions.

Implements Attribute.

Definition at line 77 of file Attributes.C.

78 {
79  auto a = dynamic_cast<const AttribTagBase *>(&other);
80  if (!a)
81  return false;
82  if (a->_vals.size() == 0)
83  return true; // the condition is empty tags - which we take to mean any tag should match
84 
85  // return true if any single tag matches between the two attribute objects
86  for (auto val : _vals)
87  if (std::find(a->_vals.begin(), a->_vals.end(), val) != a->_vals.end())
88  return true;
89  return false;
90 }
std::vector< TagID > _vals
Definition: Attributes.h:87
AttribTagBase tracks all (vector or matrix) tags associated with an object.
Definition: Attributes.h:66

◆ operator!=()

bool Attribute::operator!= ( const Attribute other) const
inlineinherited

Definition at line 62 of file TheWarehouse.h.

62 { return !(*this == other); }

◆ operator==()

bool Attribute::operator== ( const Attribute other) const
inlineinherited

Definition at line 58 of file TheWarehouse.h.

59  {
60  return _id == other._id && isEqual(other);
61  }
virtual bool isEqual(const Attribute &other) const =0
isEqual returns true if the meta-data stored in this attribute is identical to that stored in other...

Member Data Documentation

◆ _vals

std::vector<TagID> AttribTagBase::_vals
protected

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