BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
graphene::protocol::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 BitShares 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 51 of file vote.hpp.

Member Enumeration Documentation

Enumerator
committee 
witness 
worker 
VOTE_TYPE_COUNT 

Definition at line 57 of file vote.hpp.

Constructor & Destructor Documentation

graphene::protocol::vote_id_type::vote_id_type ( )
inline

Default constructor. Sets type and instance to 0.

Definition at line 66 of file vote.hpp.

graphene::protocol::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 68 of file vote.hpp.

graphene::protocol::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 72 of file vote.hpp.

Member Function Documentation

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

Get the instance of this vote_id_type.

Definition at line 99 of file vote.hpp.

graphene::protocol::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 122 of file vote.hpp.

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

Get the instance of this vote_id_type.

Definition at line 116 of file vote.hpp.

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

Definition at line 104 of file vote.hpp.

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

Set the instance of this vote_id_type.

Definition at line 110 of file vote.hpp.

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

Set the instance of this vote_id_type.

Definition at line 92 of file vote.hpp.

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

Set the type of this vote_id_type.

Definition at line 80 of file vote.hpp.

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

Get the type of this vote_id_type.

Definition at line 86 of file vote.hpp.

Friends And Related Function Documentation

size_t hash_value ( vote_id_type  v)
friend

Definition at line 56 of file vote.hpp.

Member Data Documentation

uint32_t graphene::protocol::vote_id_type::content

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

Definition at line 54 of file vote.hpp.


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