ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
active::serialise::Inventory Class Reference

#include <Inventory.h>

Inheritance diagram for active::serialise::Inventory:
Inheritance graph
[legend]
Collaboration diagram for active::serialise::Inventory:
Collaboration graph
[legend]

Public Types

using value = Entry
 Inventory value type, i.e. entries.
 
using base = std::vector<value>
 Base storage class - entry keyed by ID/name.
 
using size_type = base::size_type
 Inventory size_type.
 
using iterator = typename base::iterator
 Base storage class - entry keyed by ID/name.
 
using Option = std::optional<Inventory>
 An optional inventory.
 
using Item = value
 An inventory item pairing an entry with its ID/name.
 
using ItemOption = std::optional<Inventory::Item>
 An optional inventory item.
 
using Sequence = std::vector<std::pair<int16_t, const_iterator>>
 Inventory contents sequenced by the entry index (NB: invalidated if the inventory changes)
 

Public Member Functions

 Inventory ()
 
 Inventory (base entries)
 
bool isFilled () const
 True if entries have been filled into the inventory.
 
size_type attributeSize (bool isRequiredOnly=false) const
 
Sequence sequence () const
 
InventorywithType (const std::type_info *ownerType)
 
Inventorymerge (const Inventory &inventory)
 
iterator registerIncoming (const Identity &identity)
 
void resetAvailable ()
 
iterator findEntry (const Identity &identity, const std::type_info *owner=nullptr)
 
iterator findEntry (int16_t ind, const std::type_info *owner=nullptr)
 
bool setRequired (bool mustHave, int16_t ind, const std::type_info *owner=nullptr)
 

Public Attributes

bool isEveryItemAccepted = false
 True if cargo with any item ID can be accepted by the package inventory.
 

Detailed Description

Interface for the inventory of a package (describing package/item content)

Constructor & Destructor Documentation

◆ Inventory() [1/2]

active::serialise::Inventory::Inventory ( )
inline

Default constructor

◆ Inventory() [2/2]

active::serialise::Inventory::Inventory ( base entries)
inline

Constructor

Parameters
entriesThe inventory entries

Member Function Documentation

◆ attributeSize()

Inventory::size_type Inventory::attributeSize ( bool isRequiredOnly = false) const

Count the number of attributes in the inventory

Parameters
isRequiredOnlyTrue if only required attributes should be counted
Returns
The number of attributes

◆ findEntry() [1/2]

Inventory::iterator Inventory::findEntry ( const Identity & identity,
const std::type_info * owner = nullptr )

Find an entry by identity and optionally owner type

Parameters
identityThe entry identity
ownerThe entry owner type
Returns
An iterator at the requested entry (end() on failure)
Here is the caller graph for this function:

◆ findEntry() [2/2]

Inventory::iterator Inventory::findEntry ( int16_t ind,
const std::type_info * owner = nullptr )

Find an entry by field index and optionally owner type

Parameters
indThe field index
ownerThe entry owner type
Returns
An iterator at the requested entry (end() on failure)

◆ merge()

Inventory & Inventory::merge ( const Inventory & inventory)

Merge another inventory with this

Parameters
inventoryThe inventory to merge
Returns
A reference to this
Here is the caller graph for this function:

◆ registerIncoming()

Inventory::iterator Inventory::registerIncoming ( const Identity & identity)

Register an incoming item in the inventory

Parameters
identityThe item identity
Returns
The registered item (nullopt == not found)
Here is the call graph for this function:

◆ resetAvailable()

void Inventory::resetAvailable ( )

Reset the availability per entry to zero (typically just prior to importing)

◆ sequence()

Inventory::Sequence Inventory::sequence ( ) const

Get the inventory handling sequence, e.g. to package in the correct order for transport

Returns
The inventory handling sequence (ordered by entry.index). Invalidated if the inventory changes

◆ setRequired()

bool Inventory::setRequired ( bool mustHave,
int16_t ind,
const std::type_info * owner = nullptr )

Set the required state of a specified field (for export)

Parameters
mustHaveTrue if the field is required for export
indThe field index
ownerThe entry owner type
Returns
True if the field was found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ withType()

Inventory & Inventory::withType ( const std::type_info * ownerType)

Set the owner type for the inventory entries

Parameters
ownerTypeThe owner type (typically used to link entries to objects within a hierarchical structure)
Returns
A reference to this

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