RIT VEXU Core API
Loading...
Searching...
No Matches
VDP::Number< NumT, schemaType > Class Template Reference

#include <types.hpp>

Inheritance diagram for VDP::Number< NumT, schemaType >:
VDP::Part

Public Types

using FetchFunc = std::function<NumberType()>
 

Public Member Functions

 Number (std::string field_name, FetchFunc fetcher=[]() { return(NumberType) 0;})
 
void fetch () override
 
void set_value (NumberType val)
 
NumberType get_value ()
 
void pprint (std::stringstream &ss, size_t indent) const override
 
void pprint_data (std::stringstream &ss, size_t indent) const override
 
void read_data_from_message (PacketReader &reader) override
 
- Public Member Functions inherited from VDP::Part
 Part (std::string name)
 
std::string pretty_print () const
 
std::string pretty_print_data () const
 

Protected Member Functions

void write_schema (PacketWriter &sofar) const override
 
void write_message (PacketWriter &sofar) const override
 

Detailed Description

template<typename NumT, Type schemaType>
class VDP::Number< NumT, schemaType >

A number conveyed as a part

Member Typedef Documentation

◆ FetchFunc

template<typename NumT, Type schemaType>
using VDP::Number< NumT, schemaType >::FetchFunc = std::function<NumberType()>

Function to run when fetching this number

Constructor & Destructor Documentation

◆ Number()

template<typename NumT, Type schemaType>
VDP::Number< NumT, schemaType >::Number ( std::string field_name,
FetchFunc fetcher = []() { return (NumberType)0; } )
inlineexplicit

creates a number with a name and fetcher

Parameters
fieldname for the number part
fetcherthe function to run when fetching this number

Member Function Documentation

◆ fetch()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::fetch ( )
inlineoverridevirtual

sets the value of the number stored to the value returned by its fetcher

Implements VDP::Part.

◆ get_value()

template<typename NumT, Type schemaType>
NumberType VDP::Number< NumT, schemaType >::get_value ( )
inline
Returns
the currently stored number value

◆ pprint()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::pprint ( std::stringstream & ss,
size_t indent ) const
inlineoverridevirtual

prints the Number with the format "[indent]name: schema_string"

Parameters
ssthe stream of strings to print to
indentthe amount of indents to use

Implements VDP::Part.

◆ pprint_data()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::pprint_data ( std::stringstream & ss,
size_t indent ) const
inlineoverridevirtual

prints the data the number holds with the format "[indent]name: value"

Parameters
ssthe stream of strings to print to
indentthe amount of indents to use

Implements VDP::Part.

◆ read_data_from_message()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::read_data_from_message ( PacketReader & reader)
inlineoverridevirtual

sets the value of the number stored to the value read by a PacketReader

Parameters
readerthe packet reader to get the number from

Implements VDP::Part.

◆ set_value()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::set_value ( NumberType val)
inline

sets the value of the number stored

Parameters
valthe value to store

◆ write_message()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::write_message ( PacketWriter & sofar) const
inlineoverrideprotectedvirtual

writes the number's data to a packet

Parameters
sofarthe packet writer to write with

Implements VDP::Part.

◆ write_schema()

template<typename NumT, Type schemaType>
void VDP::Number< NumT, schemaType >::write_schema ( PacketWriter & sofar) const
inlineoverrideprotectedvirtual

writes the number's schematic to a packet

Parameters
sofarthe packet writer to write with

Implements VDP::Part.


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