www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
TheWarehouse::Query Class Reference

Query is a convenient way to construct and pass around (possible partially constructed) warehouse queries. More...

#include <TheWarehouse.h>

Public Member Functions

 Query (TheWarehouse &w)
 Creates a new query operating on the given warehouse w. More...
 
Queryoperator= (const Query &other)
 
 Query (const Query &other)
 
template<typename T , typename... Args>
Querycondition (Args &&... args)
 Adds a new condition to the query. More...
 
Query clone () const
 clone creates and returns an independent copy of the query in its current state. More...
 
size_t count ()
 count returns the number of results that match the query (this requires actually running the query). More...
 
std::vector< std::unique_ptr< Attribute > > attributes ()
 attribs returns a copy of the constructed Attribute list for the query in its current state. More...
 
template<typename T >
std::vector< T * > & queryInto (std::vector< T *> &results)
 queryInto executes the query and stores the results in the given vector. More...
 

Private Attributes

TheWarehouse_w = nullptr
 
std::vector< std::unique_ptr< Attribute > > _attribs
 

Detailed Description

Query is a convenient way to construct and pass around (possible partially constructed) warehouse queries.

The warehouse's "query()" function should generally be used to create new Query objects rather than constructing them directly. A Query object holds a list of conditions used to filter/select objects from the warehouse. When the query is executed/run, results are filtered by "and"ing each condition together - i.e. only objects that match all conditions are returned.

Definition at line 155 of file TheWarehouse.h.

Constructor & Destructor Documentation

◆ Query() [1/2]

TheWarehouse::Query::Query ( TheWarehouse w)
inline

Creates a new query operating on the given warehouse w.

You should generally use TheWarehouse::query() instead.

Definition at line 160 of file TheWarehouse.h.

Referenced by clone().

160 : _w(&w) { _attribs.reserve(5); }
TheWarehouse * _w
Definition: TheWarehouse.h:208
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209

◆ Query() [2/2]

TheWarehouse::Query::Query ( const Query other)
inline

Definition at line 174 of file TheWarehouse.h.

174  : _w(other._w)
175  {
176  _attribs.reserve(other._attribs.size());
177  for (auto & attrib : other._attribs)
178  _attribs.push_back(attrib->clone());
179  }
TheWarehouse * _w
Definition: TheWarehouse.h:208
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209

Member Function Documentation

◆ attributes()

std::vector<std::unique_ptr<Attribute> > TheWarehouse::Query::attributes ( )
inline

attribs returns a copy of the constructed Attribute list for the query in its current state.

Definition at line 197 of file TheWarehouse.h.

197 { return clone()._attribs; }
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209
Query clone() const
clone creates and returns an independent copy of the query in its current state.
Definition: TheWarehouse.h:191

◆ clone()

Query TheWarehouse::Query::clone ( ) const
inline

clone creates and returns an independent copy of the query in its current state.

Definition at line 191 of file TheWarehouse.h.

Referenced by attributes(), FEProblemBase::computeUserObjects(), ComputeNodalUserObjectsThread::onNode(), ComputeUserObjectsThread::queryBoundary(), ComputeUserObjectsThread::querySubdomain(), and ComputeUserObjectsThread::subdomainChanged().

191 { return Query(*this); }
Query(TheWarehouse &w)
Creates a new query operating on the given warehouse w.
Definition: TheWarehouse.h:160

◆ condition()

template<typename T , typename... Args>
Query& TheWarehouse::Query::condition ( Args &&...  args)
inline

◆ count()

size_t TheWarehouse::Query::count ( )
inline

count returns the number of results that match the query (this requires actually running the query).

Definition at line 194 of file TheWarehouse.h.

194 { return _w->count(_attribs); }
TheWarehouse * _w
Definition: TheWarehouse.h:208
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209
size_t count(const std::vector< std::unique_ptr< Attribute >> &conds)
count returns the number of objects that match the provided query conditions.
Definition: TheWarehouse.C:215

◆ operator=()

Query& TheWarehouse::Query::operator= ( const Query other)
inline

Definition at line 162 of file TheWarehouse.h.

163  {
164  if (this == &other)
165  return *this;
166 
167  _w = other._w;
168  _attribs.clear();
169  _attribs.reserve(other._attribs.size());
170  for (auto & attrib : other._attribs)
171  _attribs.push_back(attrib->clone());
172  return *this;
173  }
TheWarehouse * _w
Definition: TheWarehouse.h:208
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209

◆ queryInto()

template<typename T >
std::vector<T *>& TheWarehouse::Query::queryInto ( std::vector< T *> &  results)
inline

queryInto executes the query and stores the results in the given vector.

All results must be castable to the templated type T.

Definition at line 202 of file TheWarehouse.h.

Referenced by FEProblemBase::joinAndFinalize().

203  {
204  return _w->queryInto(_attribs, results);
205  }
TheWarehouse * _w
Definition: TheWarehouse.h:208
std::vector< std::unique_ptr< Attribute > > _attribs
Definition: TheWarehouse.h:209
std::vector< T * > & queryInto(const std::vector< std::unique_ptr< Attribute >> &conds, std::vector< T *> &results)
queryInto takes the given conditions (i.e.
Definition: TheWarehouse.h:277

Member Data Documentation

◆ _attribs

std::vector<std::unique_ptr<Attribute> > TheWarehouse::Query::_attribs
private

Definition at line 209 of file TheWarehouse.h.

Referenced by attributes(), condition(), count(), operator=(), Query(), and queryInto().

◆ _w

TheWarehouse* TheWarehouse::Query::_w = nullptr
private

Definition at line 208 of file TheWarehouse.h.

Referenced by condition(), count(), operator=(), and queryInto().


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