www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
VecStore Class Reference
Inheritance diagram for VecStore:
[legend]

Public Member Functions

virtual void add (size_t obj_id, std::vector< std::unique_ptr< Attribute >> attribs) override
 
virtual std::vector< size_t > query (const std::vector< std::unique_ptr< Attribute >> &conds) override
 
virtual void set (size_t obj_id, std::vector< std::unique_ptr< Attribute >> attribs) override
 

Private Attributes

std::mutex _mutex
 
std::vector< std::vector< std::unique_ptr< Attribute > > > _data
 

Detailed Description

Definition at line 38 of file TheWarehouse.C.

Member Function Documentation

◆ add()

virtual void VecStore::add ( size_t  obj_id,
std::vector< std::unique_ptr< Attribute >>  attribs 
)
inlineoverridevirtual

Implements Storage.

Definition at line 41 of file TheWarehouse.C.

42  {
43  std::lock_guard<std::mutex> l(_mutex);
44  if (obj_id != _data.size())
45  throw std::runtime_error("object with id " + std::to_string(obj_id) + " already added");
46  _data.push_back(std::move(attribs));
47  }
std::vector< std::vector< std::unique_ptr< Attribute > > > _data
Definition: TheWarehouse.C:85
std::mutex _mutex
Definition: TheWarehouse.C:84

◆ query()

virtual std::vector<size_t> VecStore::query ( const std::vector< std::unique_ptr< Attribute >> &  conds)
inlineoverridevirtual

Implements Storage.

Definition at line 49 of file TheWarehouse.C.

50  {
51  std::vector<size_t> ids;
52  std::lock_guard<std::mutex> l(_mutex);
53  for (size_t i = 0; i < _data.size(); i++)
54  {
55  auto & data = _data[i];
56  bool ismatch = true;
57  for (auto & cond : conds)
58  {
59  if (!data[cond->id()]->isMatch(*cond))
60  {
61  ismatch = false;
62  break;
63  }
64  }
65  if (ismatch)
66  ids.push_back(i);
67  }
68  return ids;
69  }
std::vector< std::vector< std::unique_ptr< Attribute > > > _data
Definition: TheWarehouse.C:85
std::mutex _mutex
Definition: TheWarehouse.C:84

◆ set()

virtual void VecStore::set ( size_t  obj_id,
std::vector< std::unique_ptr< Attribute >>  attribs 
)
inlineoverridevirtual

Implements Storage.

Definition at line 71 of file TheWarehouse.C.

72  {
73  if (obj_id > _data.size())
74  throw std::runtime_error("unknown object id " + std::to_string(obj_id));
75 
76  std::lock_guard<std::mutex> l(_mutex);
77 
78  auto & dst = _data[obj_id];
79  for (auto & attrib : attribs)
80  dst[attrib->id()] = std::move(attrib);
81  }
std::vector< std::vector< std::unique_ptr< Attribute > > > _data
Definition: TheWarehouse.C:85
std::mutex _mutex
Definition: TheWarehouse.C:84

Member Data Documentation

◆ _data

std::vector<std::vector<std::unique_ptr<Attribute> > > VecStore::_data
private

Definition at line 85 of file TheWarehouse.C.

Referenced by add(), query(), and set().

◆ _mutex

std::mutex VecStore::_mutex
private

Definition at line 84 of file TheWarehouse.C.

Referenced by add(), query(), and set().


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