49 template<
class VectorType>
51 const VectorType&
field,
58 {{
"name",
field.name},
95 std::string
id()
const;
110 template<
class VectorType>
113 return doc_.
get<VectorType&>(
"field");
122 template<
class VectorType>
125 return doc_.
get<
const VectorType&>(
"field");
300 template<
class VectorType>
304 field,
"attempting to retrieve VectorCollection from unregistered field"
306 return instance(field.db(), field.fieldCollectionName);
315 template<
class VectorType>
319 field,
"attempting to retrieve VectorCollection from unregistered field"
334 template<
class VectorType>
340 throw std::runtime_error {
"Document is not valid"};
345 VectorType& field = fd.
field<VectorType>();
347 field.fieldCollectionName =
name();
366template<
typename VectorType>
373 std::int64_t
timeIndex = std::numeric_limits<std::int64_t>::max();
387 if (
field.registered())
391 if (
timeIndex == std::numeric_limits<std::int64_t>::max())
399 if (
subCycleIndex == std::numeric_limits<std::int64_t>::max())
A mixin class for collection of documents in a database to simplify the implementation of common oper...
const std::string & name() const
Gets the name of the collection.
const NeoN::Database & db() const
Gets a const reference to the database.
Document & doc(const std::string &id)
Retrieves a document by its ID.
A type-erased interface collection types.
CollectionType & as()
Casts the collection to a specific collection type.
Collection & at(const std::string &name)
Retrieves a collection by its name.
T & get(const std::string &key)
Retrieves the value associated with the given key, casting it to the specified type.
A class representing a document in a database.
Represents the domain fields for a computational domain.
Creates a VectorDocument from an existing field.
std::int64_t iterationIndex
VectorDocument operator()(Database &db)
std::int64_t subCycleIndex
A class representing a collection of field documents in a database.
VectorCollection(const VectorCollection &)=delete
A VectorCollection is not copyable, but moveable.
VectorCollection(NeoN::Database &db, std::string name)
Constructs a VectorCollection with the given database and name.
static const VectorCollection & instance(const NeoN::Database &db, std::string name)
Retrieves the instance of the VectorCollection with the given name (const version).
VectorType & registerVector(CreateFunction createFunc)
Registers a field in the collection.
const VectorDocument & fieldDoc(const std::string &id) const
Retrieves a field document by its ID (const version).
static VectorCollection & instance(VectorType &field)
Retrieves the instance of the VectorCollection from a const registered VectorType.
VectorDocument & fieldDoc(const std::string &id)
Retrieves a field document by its ID.
std::string insert(const VectorDocument &fd)
Inserts a field document into the collection.
VectorCollection(VectorCollection &&)=default
A VectorCollection is move constructable, but not copyable.
static const VectorCollection & instance(const VectorType &field)
Retrieves the instance of the VectorCollection from a const registered VectorType.
VectorCollection & operator=(const VectorCollection &)=delete
A VectorCollection is not copyable, but moveable.
VectorCollection & operator=(VectorCollection &&)=delete
A VectorCollection is not move-assign-able, but move-construct-able.
bool contains(const std::string &id) const
Checks if the collection contains a field with the given ID.
static VectorCollection & instance(NeoN::Database &db, std::string name)
Retrieves the instance of the VectorCollection with the given name.
A class representing a field document in a database.
static std::string typeName()
Retrieves the type name of the field.
const VectorType & field() const
Retrieves the field from the document (const version).
std::string id() const
Retrieves the unique identifier of the field collection.
VectorDocument(const VectorType &field, std::int64_t timeIndex, std::int64_t iterationIndex, std::int64_t subCycleIndex)
Constructs a VectorDocument with the given field and metadata.
std::int64_t subCycleIndex() const
Retrieves the sub-cycle index of the field.
const Document & doc() const
Retrieves the underlying Document (const version).
std::int64_t & timeIndex()
Retrieves the time index of the field.
std::int64_t timeIndex() const
Retrieves the time index of the field.
Document & doc()
Retrieves the underlying Document.
std::string name() const
Retrieves the name of the field.
std::int64_t & iterationIndex()
Retrieves the iteration index of the field.
std::int64_t iterationIndex() const
Retrieves the iteration index of the field.
VectorType & field()
Retrieves the field from the document.
std::string & name()
Retrieves the time index of the field.
std::int64_t & subCycleIndex()
Retrieves the sub-cycle index of the field.
VectorDocument(const Document &doc)
Constructs a VectorDocument with the given Document.
bool validateVectorDoc(const Document &doc)
Validates a VectorDocument.
std::function< VectorDocument(NeoN::Database &db)> CreateFunction
A function type for creating a VectorDocument.
void validateRegistration(const Type &field, const std::string &errorMessage)
Validates that a field is registered in the database.