www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
AttribBoundaries Class Referenceabstract

#include <Attributes.h>

Inheritance diagram for AttribBoundaries:
[legend]

Public Member Functions

 AttribBoundaries (TheWarehouse &w, BoundaryID id, bool must_be_restricted=false)
 
virtual void initFrom (const MooseObject *obj) override
 initFrom reads and stores the desired meta-data from obj for later matching comparisons. More...
 
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, _must_be_restricted)
 
 clonefunc (AttribBoundaries)
 
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 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...
 

Private Attributes

std::vector< BoundaryID_vals
 
bool _must_be_restricted
 

Detailed Description

Definition at line 118 of file Attributes.h.

Constructor & Destructor Documentation

◆ AttribBoundaries()

AttribBoundaries::AttribBoundaries ( TheWarehouse w,
BoundaryID  id,
bool  must_be_restricted = false 
)
inline

Definition at line 121 of file Attributes.h.

122  : Attribute(w, "boundaries"), _must_be_restricted(must_be_restricted)
123  {
124  _vals.push_back(id);
125  }
bool _must_be_restricted
Definition: Attributes.h:134
std::vector< BoundaryID > _vals
Definition: Attributes.h:133
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

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

AttribBoundaries::clonefunc ( AttribBoundaries  )

◆ hash()

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

AttribBoundaries::hashfunc ( _vals  ,
_must_be_restricted   
)

◆ 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 48 of file TheWarehouse.h.

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

48 { return _id; }

◆ initFrom()

void AttribBoundaries::initFrom ( const MooseObject obj)
overridevirtual

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

Implements Attribute.

Definition at line 168 of file Attributes.C.

169 {
170  _vals.clear();
171  auto bnd = dynamic_cast<const BoundaryRestrictable *>(obj);
172  if (bnd && bnd->boundaryRestricted())
173  {
174  for (auto & bound : bnd->boundaryIDs())
175  _vals.push_back(bound);
176  }
177  else
178  _vals.push_back(Moose::ANY_BOUNDARY_ID);
179 }
std::vector< BoundaryID > _vals
Definition: Attributes.h:133
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:321

◆ isEqual()

bool AttribBoundaries::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 200 of file Attributes.C.

201 {
202  auto a = dynamic_cast<const AttribBoundaries *>(&other);
203  if (!a || a->_vals.size() != _vals.size())
204  return false;
205 
206  for (size_t i = 0; i < a->_vals.size(); i++)
207  if (a->_vals[i] != _vals[i])
208  return false;
209  return true;
210 }
std::vector< BoundaryID > _vals
Definition: Attributes.h:133

◆ isMatch()

bool AttribBoundaries::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 182 of file Attributes.C.

183 {
184  auto a = dynamic_cast<const AttribBoundaries *>(&other);
185  if (!a || a->_vals.size() < 1)
186  return false;
187 
188  auto cond = a->_vals[0];
189  if (cond == Moose::ANY_BOUNDARY_ID)
190  return true;
191  for (auto id : _vals)
192  {
193  if (id == cond || (!a->_must_be_restricted && (id == Moose::ANY_BOUNDARY_ID)))
194  return true;
195  }
196  return false;
197 }
std::vector< BoundaryID > _vals
Definition: Attributes.h:133
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:321

◆ operator!=()

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

Definition at line 43 of file TheWarehouse.h.

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

◆ operator==()

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

Definition at line 39 of file TheWarehouse.h.

40  {
41  return _id == other._id && isEqual(other);
42  }
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

◆ _must_be_restricted

bool AttribBoundaries::_must_be_restricted
private

Definition at line 134 of file Attributes.h.

◆ _vals

std::vector<BoundaryID> AttribBoundaries::_vals
private

Definition at line 133 of file Attributes.h.

Referenced by AttribBoundaries(), initFrom(), isEqual(), and isMatch().


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