Clingo
Loading...
Searching...
No Matches
Clingo::Stats Class Reference

Class modeling a mutable view on a statistics entry. More...

#include <stats.hh>

Inheritance diagram for Clingo::Stats:
Clingo::ConstStats

Public Member Functions

 Stats (clingo_stats_t *stats, uint64_t key)
 Construct a statistics entry from a pointer to the C API and a key.
 
auto array () const -> StatsArray
 Get a view on the array of statistics entries if the entry is an array.
 
auto at (size_t index) const -> Stats
 Get a statistics entry at the given index if the entry is an array.
 
auto operator[] (size_t index) const -> Stats
 Get a statistics entry at the given index if the entry is an array.
 
auto map () const -> StatsMap
 Get a view on the map of statistics entries if the entry is a map.
 
auto get (std::string_view name) const -> Stats
 Get a statistics entry with the given name if the entry is a map.
 
auto operator[] (std::string_view name) const -> Stats
 Get a statistics entry with the given name if the entry is a map.
 
void value (double value) const
 Set the value of the statistics entry if it is a value.
 
auto operator= (double value) const -> Stats
 Set the value of the statistics entry if it is a value.
 
auto value () const -> double
 Get the value of the statistics entry if it is a value.
 
- Public Member Functions inherited from Clingo::ConstStats
 ConstStats (clingo_stats_t const *stats, uint64_t key)
 Construct a statistics entry from a pointer to the C API and a key.
 
auto type () const -> StatsType
 Get the type of the statistics entry.
 
auto array () const -> ConstStatsArray
 Get a view on the array of statistics entries if the entry is an array.
 
auto at (size_t index) const -> ConstStats
 Get a statistics entry at the given index if the entry is an array.
 
auto operator[] (size_t index) const -> ConstStats
 Get a statistics entry at the given index if the entry is an array.
 
auto map () const -> ConstStatsMap
 Get a view on the map of statistics entries if the entry is a map.
 
auto get (std::string_view name) const -> ConstStats
 Get a statistics entry with the given name if the entry is a map.
 
auto operator[] (std::string_view name) const -> ConstStats
 Get a statistics entry with the given name if the entry is a map.
 
auto value () const -> double
 Get the value of the statistics entry if it is a value.
 
auto operator* () const -> double
 Get the value of the statistics entry if it is a value.
 
auto to_string () const -> std::string
 Get a string representation of the statistics entry.
 

Friends

auto c_cast (Stats const &stats) -> clingo_stats_t *
 Cast to the underlying C API type.
 

Detailed Description

Class modeling a mutable view on a statistics entry.

Constructor & Destructor Documentation

◆ Stats()

Clingo::Stats::Stats ( clingo_stats_t stats,
uint64_t  key 
)
inlineexplicit

Construct a statistics entry from a pointer to the C API and a key.

Member Function Documentation

◆ operator=()

auto Clingo::Stats::operator= ( double  value) const -> Stats
inline

Set the value of the statistics entry if it is a value.

Parameters
valuethe value to set
Returns
a reference to the statistics entry

◆ operator[]() [1/2]

auto Clingo::Stats::operator[] ( size_t  index) const -> Stats
inline

Get a statistics entry at the given index if the entry is an array.

Parameters
indexthe index of the statistics entry to get
Returns
a statistics entry at the given index

◆ operator[]() [2/2]

auto Clingo::Stats::operator[] ( std::string_view  name) const -> Stats
inline

Get a statistics entry with the given name if the entry is a map.

Parameters
namethe name of the statistics entry to get
Returns
a statistics entry with the given name

◆ value() [1/2]

auto Clingo::ConstStats::value ( ) const -> double
inline

Get the value of the statistics entry if it is a value.

Returns
the value of the statistics entry

◆ value() [2/2]

void Clingo::Stats::value ( double  value) const
inline

Set the value of the statistics entry if it is a value.

Parameters
valuethe value to set

Friends And Related Symbol Documentation

◆ c_cast

auto c_cast ( Stats const stats) -> clingo_stats_t *
friend

Cast to the underlying C API type.

Parameters
statsthe statistics entry to cast
Returns
the underlying C API type

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