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

Attribute is an abstract class that can be implemented in order to track custom metadata about MooseObject instances - enabling warehouse queries over the attribute. More...

#include <TheWarehouse.h>

Inheritance diagram for Attribute:
[legend]

Public Member Functions

 Attribute (TheWarehouse &w, const std::string name)
 Constructs/initializes a new attribute with the specified name for use in warehouse w. More...
 
virtual ~Attribute ()
 
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 bool isMatch (const Attribute &other) const =0
 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 =0
 isEqual returns true if the meta-data stored in this attribute is identical to that stored in other. More...
 
virtual std::unique_ptr< Attributeclone () const =0
 clone creates and returns and identical (deep) copy of this attribute - i.e. More...
 

Private Attributes

int _id = -1
 

Detailed Description

Attribute is an abstract class that can be implemented in order to track custom metadata about MooseObject instances - enabling warehouse queries over the attribute.

Attribute subclasses must be registered with the warehouse (i.e. via TheWarehouse::registerAttribute) where they will be used before objects are added to that warehouse. Specific Attribute instances cannot (and should not) generally be created before the class is registered with a warehouse.

In order to work with QueryCache objects, attribute classes should include a public typedef for a Key type, as well as a setFromKey function that takes this type as an argument:

class FooAttribute : public Attribute { public: typedef [type-for-foo] Key;

void setFrom(Key k) { // code to mutate/reinitialize FooAttribute using k } }

Definition at line 50 of file TheWarehouse.h.

Constructor & Destructor Documentation

◆ Attribute()

Attribute::Attribute ( TheWarehouse w,
const std::string  name 
)

Constructs/initializes a new attribute with the specified name for use in warehouse w.

The attribute must have been previously registered with w prior to calling this constructor.

Definition at line 36 of file TheWarehouse.C.

36 : _id(w.attribID(name)) {}
unsigned int attribID(const std::string &name)
Returns a unique ID associated with the given attribute name - i.e.
Definition: TheWarehouse.h:443

◆ ~Attribute()

virtual Attribute::~Attribute ( )
inlinevirtual

Definition at line 56 of file TheWarehouse.h.

56 {}

Member Function Documentation

◆ clone()

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

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 virtual

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

◆ id()

unsigned int Attribute::id ( ) const
inline

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 virtual

◆ isEqual()

virtual bool Attribute::isEqual ( const Attribute other) const
pure virtual

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.

Implemented in AttribDisplaced, AttribInterfaces, AttribVar, AttribResidualObject, AttribSystem, AttribName, AttribPostAux, AttribPreAux, AttribPreIC, AttribSysNum, AttribExecutionOrderGroup, AttribThread, AttribBoundaries, AttribSubdomains, AttribExecOns, AttribSorted, and AttribTagBase.

Referenced by operator==().

◆ isMatch()

virtual bool Attribute::isMatch ( const Attribute other) const
pure virtual

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.

Implemented in AttribDisplaced, AttribInterfaces, AttribVar, AttribResidualObject, AttribSystem, AttribName, AttribPostAux, AttribPreAux, AttribPreIC, AttribSysNum, AttribExecutionOrderGroup, AttribThread, AttribBoundaries, AttribSubdomains, AttribExecOns, AttribSorted, and AttribTagBase.

◆ operator!=()

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

Definition at line 62 of file TheWarehouse.h.

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

◆ operator==()

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

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

◆ _id

int Attribute::_id = -1
private

Definition at line 92 of file TheWarehouse.h.

Referenced by id(), and operator==().


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