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

#include <Attributes.h>

Inheritance diagram for AttribMatrixTags:
[legend]

Public Types

typedef unsigned int Key
 

Public Member Functions

void setFrom (Key k)
 
 AttribMatrixTags (TheWarehouse &w)
 
 AttribMatrixTags (TheWarehouse &w, TagID tag)
 
 AttribMatrixTags (TheWarehouse &w, const std::set< TagID > &tags)
 
virtual void initFrom (const MooseObject *obj) override
 initFrom reads and stores the desired meta-data from obj for later matching comparisons. More...
 
 clonefunc (AttribMatrixTags)
 
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 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

Definition at line 90 of file Attributes.h.

Member Typedef Documentation

◆ Key

typedef unsigned int AttribMatrixTags::Key

Definition at line 93 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribMatrixTags() [1/3]

AttribMatrixTags::AttribMatrixTags ( TheWarehouse w)
inline

Definition at line 100 of file Attributes.h.

100 : AttribTagBase(w, "matrix_tags") {}
AttribTagBase(TheWarehouse &w, const std::string &attrib_name)
Definition: Attributes.h:69

◆ AttribMatrixTags() [2/3]

AttribMatrixTags::AttribMatrixTags ( TheWarehouse w,
TagID  tag 
)
inline

Definition at line 101 of file Attributes.h.

101 : AttribTagBase(w, tag, "matrix_tags") {}
AttribTagBase(TheWarehouse &w, const std::string &attrib_name)
Definition: Attributes.h:69

◆ AttribMatrixTags() [3/3]

AttribMatrixTags::AttribMatrixTags ( TheWarehouse w,
const std::set< TagID > &  tags 
)
inline

Definition at line 102 of file Attributes.h.

103  : AttribTagBase(w, tags, "matrix_tags")
104  {
105  }
AttribTagBase(TheWarehouse &w, const std::string &attrib_name)
Definition: Attributes.h:69

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().

◆ clonefunc()

AttribMatrixTags::clonefunc ( AttribMatrixTags  )

◆ 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  )
inherited

◆ 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()

void AttribMatrixTags::initFrom ( const MooseObject obj)
overridevirtual

initFrom reads and stores the desired meta-data from obj for later matching comparisons.

Implements Attribute.

Definition at line 106 of file Attributes.C.

107 {
108  _vals.clear();
109  auto t = dynamic_cast<const TaggingInterface *>(obj);
110  if (t)
111  {
112  for (auto & tag : t->getMatrixTags({}))
113  _vals.push_back(static_cast<int>(tag));
114  }
115 }
std::vector< TagID > _vals
Definition: Attributes.h:87

◆ isEqual()

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

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
overridevirtualinherited

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

◆ setFrom()

void AttribMatrixTags::setFrom ( Key  k)
inline

Definition at line 94 of file Attributes.h.

95  {
96  _vals.clear();
97  _vals.push_back(k);
98  }
std::vector< TagID > _vals
Definition: Attributes.h:87

Member Data Documentation

◆ _vals

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

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