A type-erased interface collection types.
More...
#include <collection.hpp>
|
template<typename CollectionType > |
| Collection (CollectionType collection) |
| Constructs a Collection from a specific collection type.
|
|
| Collection (const Collection &other)=delete |
| A Collection is not copyable, only moveable.
|
|
Collection & | operator= (const Collection &other)=delete |
| A Collection is not copyable, only moveable.
|
|
| Collection (Collection &&other)=default |
| A Collection is moveable, but not copyable.
|
|
Collection & | operator= (Collection &&other)=default |
| A Collection is moveable, but not copyable.
|
|
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.
|
|
size_t | size () const |
| Returns the number of documents in the collection.
|
|
std::string | type () const |
| Returns the type of the collection.
|
|
std::string | name () const |
| Returns the name of the collection.
|
|
Database & | db () |
| Returns a reference to the database containing the collection.
|
|
const Database & | db () const |
| Returns a const reference to the database containing the collection.
|
|
template<typename CollectionType > |
CollectionType & | as () |
| Casts the collection to a specific collection type.
|
|
template<typename CollectionType > |
const CollectionType & | as () const |
| Casts the collection to a specific collection type (const version).
|
|
A type-erased interface collection types.
The Collection class provides a type-erased interface for different collection types. It allows operations such as retrieving documents, finding documents based on predicates, and accessing collection metadata.
Definition at line 28 of file collection.hpp.
◆ Collection() [1/3]
template<typename CollectionType >
NeoFOAM::Collection::Collection |
( |
CollectionType |
collection | ) |
|
|
inline |
Constructs a Collection from a specific collection type.
- Template Parameters
-
CollectionType | The type of the collection to be wrapped. |
- Parameters
-
collection | The collection instance to be wrapped. |
Definition at line 39 of file collection.hpp.
◆ Collection() [2/3]
NeoFOAM::Collection::Collection |
( |
const Collection & |
other | ) |
|
|
delete |
◆ Collection() [3/3]
NeoFOAM::Collection::Collection |
( |
Collection && |
other | ) |
|
|
default |
◆ as() [1/2]
template<typename CollectionType >
CollectionType & NeoFOAM::Collection::as |
( |
| ) |
|
|
inline |
Casts the collection to a specific collection type.
- Template Parameters
-
CollectionType | The type to cast to. |
- Returns
- CollectionType& A reference to the casted collection.
- Exceptions
-
std::bad_cast | if the cast fails. |
Definition at line 131 of file collection.hpp.
◆ as() [2/2]
template<typename CollectionType >
const CollectionType & NeoFOAM::Collection::as |
( |
| ) |
const |
|
inline |
Casts the collection to a specific collection type (const version).
- Template Parameters
-
CollectionType | The type to cast to. |
- Returns
- const CollectionType& A const reference to the casted collection.
- Exceptions
-
std::bad_cast | if the cast fails. |
Definition at line 150 of file collection.hpp.
◆ db() [1/2]
Returns a reference to the database containing the collection.
- Returns
- Database& A reference to the database.
◆ db() [2/2]
const Database & NeoFOAM::Collection::db |
( |
| ) |
const |
Returns a const reference to the database containing the collection.
- Returns
- const Database& A const reference to the database.
◆ doc() [1/2]
Document & NeoFOAM::Collection::doc |
( |
const std::string & |
id | ) |
|
Retrieves a document by its ID.
- Parameters
-
id | The ID of the document to retrieve. |
- Returns
- Document& A reference to the document.
◆ doc() [2/2]
const Document & NeoFOAM::Collection::doc |
( |
const std::string & |
id | ) |
const |
Retrieves a document by its ID (const version).
- Parameters
-
id | The ID of the document to retrieve. |
- Returns
- const Document& A const reference to the document.
◆ find()
std::vector< std::string > NeoFOAM::Collection::find |
( |
const std::function< bool(const Document &)> & |
predicate | ) |
const |
Finds documents that match a given predicate.
- Parameters
-
predicate | A function that takes a Document and returns true if it matches the criteria. |
- Returns
- std::vector<std::string> A vector of document IDs that match the predicate.
◆ name()
std::string NeoFOAM::Collection::name |
( |
| ) |
const |
Returns the name of the collection.
- Returns
- std::string The name of the collection.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ size()
size_t NeoFOAM::Collection::size |
( |
| ) |
const |
Returns the number of documents in the collection.
- Returns
- size_t The number of documents.
◆ type()
std::string NeoFOAM::Collection::type |
( |
| ) |
const |
Returns the type of the collection.
- Returns
- std::string The type of the collection.
The documentation for this class was generated from the following file:
- /home/runner/work/NeoFOAM/NeoFOAM/include/NeoFOAM/core/database/collection.hpp