garlic::Model Class Reference

An object to describe a Model. More...

#include <constraints.h>

Data Structures

struct  FieldDescriptor
 Field Record. More...
 

Public Member Functions

 Model ()
 Create an empty Model.
 
 Model (text &&name)
 Create an empty Model by name.
 
void add_field (text &&name, field_pointer field, bool required=true)
 Add a new field. More...
 
template<typename KeyType >
field_pointer get_field (KeyType &&name) const
 
auto & annotations () noexcept
 
const auto & annotations () const noexcept
 
const textname () const noexcept
 
const_field_iterator begin_fields () const noexcept
 
const_field_iterator end_fields () const noexcept
 
const_field_iterator find_field (const text &name) const noexcept
 
template<GARLIC_VIEW Layer>
bool quick_test (const Layer &layer) const noexcept
 Run a quick test on a layer.
 
template<GARLIC_VIEW Layer>
ConstraintResult validate (const Layer &layer) const noexcept
 Validate a layer and return a detailed ConstraintResult.
 

Detailed Description

An object to describe a Model.

A model will contain a table basic_text -> {field: Field, required: bool}

Member Function Documentation

◆ add_field()

void garlic::Model::add_field ( text &&  name,
field_pointer  field,
bool  required = true 
)
inline

Add a new field.

Parameters
namethe name/key of the member.
fieldstd::shared_ptr<Field>
requiredwhether or not this field is required.
Note
If a member by such name already exists, this function will not do anything.

◆ annotations() [1/2]

const auto& garlic::Model::annotations ( ) const
inlinenoexcept

Returns
the model's annotations map.

◆ annotations() [2/2]

auto& garlic::Model::annotations ( )
inlinenoexcept
Returns
the model's annotations map.

◆ begin_fields()

const_field_iterator garlic::Model::begin_fields ( ) const
inlinenoexcept
Returns
an iterator (const) pointing to the first (basic_text, FieldDescriptor) pair.

◆ end_fields()

const_field_iterator garlic::Model::end_fields ( ) const
inlinenoexcept
Returns
an iterator (const) pointing to one past the last (basic_text, FieldDescriptor) pair.

◆ find_field()

const_field_iterator garlic::Model::find_field ( const text name) const
inlinenoexcept
Returns
an iterator (const) pointing to found (basic_text, FieldDescriptor) pair or end_fields()

◆ get_field()

template<typename KeyType >
field_pointer garlic::Model::get_field ( KeyType &&  name) const
inline
Returns
a shared pointer to the Field instance or nullptr if such key is not defined yet.

◆ name()

const text& garlic::Model::name ( ) const
inlinenoexcept
Returns
name of the Model.

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