NeoFOAM
WIP Prototype of a modern OpenFOAM core
|
A mixin class for collection of documents in a database to simplify the implementation of common operations. More...
#include <collection.hpp>
Public Member Functions | |
CollectionMixin (NeoFOAM::Database &db, std::string name) | |
Constructs a CollectionMixin with the given database and collection name. | |
CollectionMixin (const CollectionMixin &)=delete | |
CollectionMixin & | operator= (const CollectionMixin &)=delete |
CollectionMixin (CollectionMixin &&)=default | |
CollectionMixin & | operator= (CollectionMixin &&)=delete |
Document & | doc (const std::string &id) |
Retrieves a document by its ID. | |
const Document & | doc (const std::string &id) const |
Retrieves a document by its ID (const version). | |
std::vector< std::string > | find (const std::function< bool(const Document &)> &predicate) const |
Finds documents that match a given predicate. | |
std::size_t | size () const |
Gets the number of documents in the collection. | |
const NeoFOAM::Database & | db () const |
Gets a const reference to the database. | |
NeoFOAM::Database & | db () |
Gets a reference to the database. | |
const std::string & | name () const |
Gets the name of the collection. | |
std::string | type () const |
Gets the type name of the documents in the collection. | |
std::vector< std::string > | sortedKeys () const |
Gets the sorted keys of the documents in the collection. | |
Protected Attributes | |
std::unordered_map< std::string, DocumentType > | docs_ |
The map of document IDs to documents. | |
NeoFOAM::Database & | db_ |
The reference to the database. | |
std::string | name_ |
The name of the collection. | |
A mixin class for collection of documents in a database to simplify the implementation of common operations.
DocumentType | The type of documents stored in the collection. |
Definition at line 214 of file collection.hpp.
|
inline |
Constructs a CollectionMixin with the given database and collection name.
db | The database reference. |
name | The name of the collection. |
Definition at line 225 of file collection.hpp.
|
delete |
@biref A CollectionMixin is not copyable, only moveable.
|
default |
@biref A CollectionMixin is moveable, but not copyable.
|
inline |
Gets a reference to the database.
Definition at line 301 of file collection.hpp.
|
inline |
Gets a const reference to the database.
Definition at line 294 of file collection.hpp.
|
inline |
Retrieves a document by its ID.
id | The ID of the document. |
Definition at line 253 of file collection.hpp.
|
inline |
Retrieves a document by its ID (const version).
id | The ID of the document. |
Definition at line 261 of file collection.hpp.
|
inline |
Finds documents that match a given predicate.
predicate | A function that takes a const reference to a Document and returns a bool. |
Definition at line 269 of file collection.hpp.
|
inline |
Gets the name of the collection.
Definition at line 308 of file collection.hpp.
|
delete |
@biref A CollectionMixin is not move-assign-able.
|
delete |
@biref A CollectionMixin is not copyable, only moveable.
|
inline |
Gets the number of documents in the collection.
Definition at line 287 of file collection.hpp.
|
inline |
Gets the sorted keys of the documents in the collection.
Definition at line 322 of file collection.hpp.
|
inline |
Gets the type name of the documents in the collection.
Definition at line 315 of file collection.hpp.
|
protected |
The reference to the database.
Definition at line 336 of file collection.hpp.
|
protected |
The map of document IDs to documents.
Definition at line 335 of file collection.hpp.
|
protected |
The name of the collection.
Definition at line 337 of file collection.hpp.