class eosio::singleton
Class List > eosio :: singleton
Classes
Type | Name |
---|---|
struct | row |
Public Functions
Type | Name |
---|---|
singleton (name code, uint64_t scope) | |
bool | exists () |
T | get () Get the value stored inside the singleton table. |
T | get_or_default (const T & def = T()) |
T | get_or_create (name bill_to_account, const T & def = T()) |
void | set (const T & value, name bill_to_account) |
void | remove () |
Detailed Description
This wrapper uses a single table to store named objects various types.
Template parameters:
- SingletonName - the name of this singleton variable
- T - the type of the singleton
Public Functions Documentation
function singleton
eosio::singleton< SingletonName, T >::singleton(
name code,
uint64_t scope
)
Construct a new singleton object given the table's owner and the scope
Parameters:
- code - The table's owner
- scope - The scope of the table
function exists
bool eosio::singleton< SingletonName, T >::exists()
Check if the singleton table exists
Returns:
true - if exists
Returns:
false - otherwise
function get
T eosio::singleton< SingletonName, T >::get()
Get the value stored inside the singleton table.
Get the value stored inside the singleton table. Will throw an exception if it doesn't exist
Returns:
T - The value stored
function get_or_default
T eosio::singleton< SingletonName, T >::get_or_default(
const T & def = T()
)
Get the value stored inside the singleton table. If it doesn't exist, it will return the specified default value
Parameters:
- def - The default value to be returned in case the data doesn't exist
Returns:
T - The value stored
function get_or_create
T eosio::singleton< SingletonName, T >::get_or_create(
name bill_to_account,
const T & def = T()
)
Get the value stored inside the singleton table. If it doesn't exist, it will create a new one with the specified default value
Parameters:
- bill_to_account - The account to bill for the newly created data if the data doesn't exist
- def - The default value to be created in case the data doesn't exist
Returns:
T - The value stored
function set
void eosio::singleton< SingletonName, T >::set(
const T & value,
name bill_to_account
)
Set new value to the singleton table
Parameters:
- value - New value to be set
- bill_to_account - Account to pay for the new value
function remove
void eosio::singleton< SingletonName, T >::remove()
Remove the only data inside singleton table
The documentation for this class was generated from the following file: libraries/eosiolib/contracts/eosio/singleton.hpp