Bitshares-Core  2.0.181105
BitShares blockchain implementation and command-line interface software
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
graphene::chain::vote_id_type Struct Reference

An ID for some votable object. More...

#include <vote.hpp>

Public Types

enum  vote_type { committee, witness, worker, VOTE_TYPE_COUNT }
 

Public Member Functions

 vote_id_type ()
 Default constructor. Sets type and instance to 0. More...
 
 vote_id_type (vote_type type, uint32_t instance=0)
 Construct this vote_id_type with provided type and instance. More...
 
 vote_id_type (const std::string &serial)
 Construct this vote_id_type from a serial string in the form "type:instance". More...
 
void set_type (vote_type type)
 Set the type of this vote_id_type. More...
 
vote_type type () const
 Get the type of this vote_id_type. More...
 
void set_instance (uint32_t instance)
 Set the instance of this vote_id_type. More...
 
uint32_t instance () const
 Get the instance of this vote_id_type. More...
 
vote_id_typeoperator= (vote_id_type other)
 
vote_id_typeoperator= (uint32_t instance)
 Set the instance of this vote_id_type. More...
 
 operator uint32_t () const
 Get the instance of this vote_id_type. More...
 
 operator std::string () const
 Convert this vote_id_type to a serial string in the form "type:instance". More...
 

Public Attributes

uint32_t content
 Lower 8 bits are type; upper 24 bits are instance. More...
 

Friends

size_t hash_value (vote_id_type v)
 

Detailed Description

An ID for some votable object.

This class stores an ID for a votable object. The ID is comprised of two fields: a type, and an instance. The type field stores which kind of object is being voted on, and the instance stores which specific object of that type is being referenced by this ID.

A value of vote_id_type is implicitly convertible to an unsigned 32-bit integer containing only the instance. It may also be implicitly assigned from a uint32_t, which will update the instance. It may not, however, be implicitly constructed from a uint32_t, as in this case, the type would be unknown.

On the wire, a vote_id_type is represented as a 32-bit integer with the type in the lower 8 bits and the instance in the upper 24 bits. This means that types may never exceed 8 bits, and instances may never exceed 24 bits.

In JSON, a vote_id_type is represented as a string "type:instance", i.e. "1:5" would be type 1 and instance 5.

Note
In the Graphene protocol, vote_id_type instances are unique across types; that is to say, if an object of type 1 has instance 4, an object of type 0 may not also have instance 4. In other words, the type is not a namespace for instances; it is only an informational field.

Definition at line 56 of file vote.hpp.

Member Enumeration Documentation

◆ vote_type

Enumerator
committee 
witness 
worker 
VOTE_TYPE_COUNT 

Definition at line 62 of file vote.hpp.

Constructor & Destructor Documentation

◆ vote_id_type() [1/3]

graphene::chain::vote_id_type::vote_id_type ( )
inline

Default constructor. Sets type and instance to 0.

Definition at line 71 of file vote.hpp.

◆ vote_id_type() [2/3]

graphene::chain::vote_id_type::vote_id_type ( vote_type  type,
uint32_t  instance = 0 
)
inline

Construct this vote_id_type with provided type and instance.

Definition at line 73 of file vote.hpp.

◆ vote_id_type() [3/3]

graphene::chain::vote_id_type::vote_id_type ( const std::string &  serial)
inlineexplicit

Construct this vote_id_type from a serial string in the form "type:instance".

Definition at line 77 of file vote.hpp.

Member Function Documentation

◆ instance()

uint32_t graphene::chain::vote_id_type::instance ( ) const
inline

Get the instance of this vote_id_type.

Definition at line 104 of file vote.hpp.

◆ operator std::string()

graphene::chain::vote_id_type::operator std::string ( ) const
inlineexplicit

Convert this vote_id_type to a serial string in the form "type:instance".

Definition at line 127 of file vote.hpp.

◆ operator uint32_t()

graphene::chain::vote_id_type::operator uint32_t ( ) const
inline

Get the instance of this vote_id_type.

Definition at line 121 of file vote.hpp.

◆ operator=() [1/2]

vote_id_type& graphene::chain::vote_id_type::operator= ( vote_id_type  other)
inline

Definition at line 109 of file vote.hpp.

◆ operator=() [2/2]

vote_id_type& graphene::chain::vote_id_type::operator= ( uint32_t  instance)
inline

Set the instance of this vote_id_type.

Definition at line 115 of file vote.hpp.

◆ set_instance()

void graphene::chain::vote_id_type::set_instance ( uint32_t  instance)
inline

Set the instance of this vote_id_type.

Definition at line 97 of file vote.hpp.

◆ set_type()

void graphene::chain::vote_id_type::set_type ( vote_type  type)
inline

Set the type of this vote_id_type.

Definition at line 85 of file vote.hpp.

◆ type()

vote_type graphene::chain::vote_id_type::type ( ) const
inline

Get the type of this vote_id_type.

Definition at line 91 of file vote.hpp.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( vote_id_type  v)
friend

Definition at line 61 of file vote.hpp.

Member Data Documentation

◆ content

uint32_t graphene::chain::vote_id_type::content

Lower 8 bits are type; upper 24 bits are instance.

Definition at line 59 of file vote.hpp.


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