Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
ItemStorage< ITEM > Class Template Reference

#include <item_storage.h>

Public Member Functions

bool get (const std::string &name, ITEM &item) const
bool store (const std::string &name, ITEM item)

Private Attributes

std::map< std::string, ITEM > warehouse

Detailed Description

template<typename ITEM>
class ItemStorage< ITEM >

A generic storage class for storing items, such as variable values or function pointers. The storage class can store any type of item that does not require a constructor call, i.e., it does not create a new copy of an item when one is requested.

Definition at line 36 of file item_storage.h.

Member Function Documentation

◆ get()

template<typename ITEM>
bool ItemStorage< ITEM >::get ( const std::string & name,
ITEM & item ) const
inline

Get an item (product) with the given name.

Parameters
nameThe name of the item.
funcThe requested item is stored here, if it was found.
Returns
If true, variable func contains a valid item.

Definition at line 50 of file item_storage.h.

◆ store()

template<typename ITEM>
bool ItemStorage< ITEM >::store ( const std::string & name,
ITEM item )
inline

Register a item (product) to the factory. This function will fail to succeed if the factory already contains an item (product) with the same name.

Parameters
nameA unique name for the item (product).
funcRegistered item (product).
Returns
If true, the item was added to the factory.

Definition at line 63 of file item_storage.h.

Member Data Documentation

◆ warehouse

template<typename ITEM>
std::map<std::string,ITEM> ItemStorage< ITEM >::warehouse
private

Container for all stored items.

Definition at line 42 of file item_storage.h.


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