cluck 1.0.1
The cluster lock service.
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
cluck_daemon::computer Class Reference

#include <computer.h>

Public Types

typedef std::map< std::string, pointer_tmap_t
 
typedef std::shared_ptr< computerpointer_t
 
typedef std::int8_t priority_t
 
typedef std::uint32_t random_t
 
typedef std::vector< pointer_tvector_t
 

Public Member Functions

 computer ()
 
 computer (std::string const &name, priority_t priority, addr::addr ip_address)
 
bool get_connected () const
 
std::string const & get_id () const
 
addr::addr const & get_ip_address () const
 
std::string const & get_name () const
 
priority_t get_priority () const
 
snapdev::timespec_ex const & get_start_time () const
 
bool is_self () const
 
void set_connected (bool connected)
 
bool set_id (std::string const &id)
 Initialize this computer object from id.
 
void set_start_time (snapdev::timespec_ex const &start_time)
 

Static Public Attributes

static priority_t const PRIORITY_DEFAULT = 14
 
static priority_t const PRIORITY_LEADER = 0
 
static priority_t const PRIORITY_MAX = 15
 
static priority_t const PRIORITY_MIN = 0
 
static priority_t const PRIORITY_OFF = 15
 
static priority_t const PRIORITY_UNDEFINED = -1
 
static priority_t const PRIORITY_USER_MIN = 1
 

Private Attributes

bool f_connected = true
 
std::string f_id = std::string()
 
addr::addr f_ip_address = addr::addr()
 
std::string f_name = std::string()
 
pid_t f_pid = 0
 
priority_t f_priority = PRIORITY_UNDEFINED
 
random_t f_random_id = 0
 
bool f_self = false
 
snapdev::timespec_ex f_start_time = snapdev::timespec_ex()
 

Detailed Description

Definition at line 44 of file computer.h.

Member Typedef Documentation

◆ map_t

typedef std::map<std::string, pointer_t> cluck_daemon::computer::map_t

Definition at line 50 of file computer.h.

◆ pointer_t

typedef std::shared_ptr<computer> cluck_daemon::computer::pointer_t

Definition at line 49 of file computer.h.

◆ priority_t

Definition at line 47 of file computer.h.

◆ random_t

typedef std::uint32_t cluck_daemon::computer::random_t

Definition at line 48 of file computer.h.

◆ vector_t

Definition at line 51 of file computer.h.

Constructor & Destructor Documentation

◆ computer() [1/2]

cluck_daemon::computer::computer ( )

Definition at line 76 of file computer.cpp.

◆ computer() [2/2]

cluck_daemon::computer::computer ( std::string const &  name,
priority_t  priority,
addr::addr  ip_address 
)

Definition at line 83 of file computer.cpp.

References f_name, f_priority, f_random_id, PRIORITY_MAX, and PRIORITY_USER_MIN.

Member Function Documentation

◆ get_connected()

bool cluck_daemon::computer::get_connected ( ) const

Definition at line 131 of file computer.cpp.

References f_connected.

◆ get_id()

std::string const & cluck_daemon::computer::get_id ( ) const

Definition at line 295 of file computer.cpp.

References f_id, f_ip_address, f_name, f_pid, f_priority, f_random_id, and PRIORITY_UNDEFINED.

◆ get_ip_address()

addr::addr const & cluck_daemon::computer::get_ip_address ( ) const

Definition at line 330 of file computer.cpp.

References f_ip_address.

◆ get_name()

std::string const & cluck_daemon::computer::get_name ( ) const

Definition at line 289 of file computer.cpp.

References f_name.

Referenced by cluck_daemon::cluckd::msg_lock_started().

◆ get_priority()

computer::priority_t cluck_daemon::computer::get_priority ( ) const

Definition at line 271 of file computer.cpp.

References f_priority.

◆ get_start_time()

snapdev::timespec_ex const & cluck_daemon::computer::get_start_time ( ) const

Definition at line 283 of file computer.cpp.

References f_start_time.

◆ is_self()

bool cluck_daemon::computer::is_self ( ) const

Definition at line 119 of file computer.cpp.

References f_self.

◆ set_connected()

void cluck_daemon::computer::set_connected ( bool  connected)

Definition at line 125 of file computer.cpp.

References f_connected.

Referenced by cluck_daemon::cluckd::msg_lock_started().

◆ set_id()

bool cluck_daemon::computer::set_id ( std::string const &  id)
Note
At the moment, the function is expected to work each time. This is used internally to the cluckd, so the errors are due primarily to a spurious message from a hacker. Otherwise, we would have to keep all the new parameter on the stack and save them in the object fields only if all are considered valid. (i.e. If the input string is invalid, the computer object is likely left in an invalid state.)
Exceptions
logic_errorIf the function was already called once successfully, then this exception is raised when trying to do call it again.
Returns
true if the id was considered 100% valid, false otherwise.

Definition at line 153 of file computer.cpp.

References f_id, f_ip_address, f_name, f_pid, f_priority, f_random_id, PRIORITY_MAX, PRIORITY_UNDEFINED, and PRIORITY_USER_MIN.

Referenced by cluck_daemon::cluckd::msg_lock_started().

◆ set_start_time()

void cluck_daemon::computer::set_start_time ( snapdev::timespec_ex const &  start_time)

Definition at line 277 of file computer.cpp.

References f_start_time.

Referenced by cluck_daemon::cluckd::msg_lock_started().

Member Data Documentation

◆ f_connected

bool cluck_daemon::computer::f_connected = true
private

Definition at line 83 of file computer.h.

Referenced by get_connected(), and set_connected().

◆ f_id

std::string cluck_daemon::computer::f_id = std::string()
mutableprivate

Definition at line 81 of file computer.h.

Referenced by get_id(), and set_id().

◆ f_ip_address

addr::addr cluck_daemon::computer::f_ip_address = addr::addr()
private

Definition at line 88 of file computer.h.

Referenced by get_id(), get_ip_address(), and set_id().

◆ f_name

std::string cluck_daemon::computer::f_name = std::string()
private

Definition at line 90 of file computer.h.

Referenced by computer(), get_id(), get_name(), and set_id().

◆ f_pid

pid_t cluck_daemon::computer::f_pid = 0
private

Definition at line 89 of file computer.h.

Referenced by get_id(), and set_id().

◆ f_priority

priority_t cluck_daemon::computer::f_priority = PRIORITY_UNDEFINED
private

Definition at line 86 of file computer.h.

Referenced by computer(), get_id(), get_priority(), and set_id().

◆ f_random_id

random_t cluck_daemon::computer::f_random_id = 0
private

Definition at line 87 of file computer.h.

Referenced by computer(), get_id(), and set_id().

◆ f_self

bool cluck_daemon::computer::f_self = false
private

Definition at line 84 of file computer.h.

Referenced by is_self().

◆ f_start_time

snapdev::timespec_ex cluck_daemon::computer::f_start_time = snapdev::timespec_ex()
private

Definition at line 92 of file computer.h.

Referenced by get_start_time(), and set_start_time().

◆ PRIORITY_DEFAULT

priority_t const cluck_daemon::computer::PRIORITY_DEFAULT = 14
static

Definition at line 57 of file computer.h.

◆ PRIORITY_LEADER

priority_t const cluck_daemon::computer::PRIORITY_LEADER = 0
static

Definition at line 55 of file computer.h.

◆ PRIORITY_MAX

priority_t const cluck_daemon::computer::PRIORITY_MAX = 15
static

Definition at line 59 of file computer.h.

Referenced by computer(), cluck_daemon::cluckd::msg_cluster_up(), and set_id().

◆ PRIORITY_MIN

priority_t const cluck_daemon::computer::PRIORITY_MIN = 0
static

Definition at line 54 of file computer.h.

◆ PRIORITY_OFF

priority_t const cluck_daemon::computer::PRIORITY_OFF = 15
static

◆ PRIORITY_UNDEFINED

priority_t const cluck_daemon::computer::PRIORITY_UNDEFINED = -1
static

Definition at line 53 of file computer.h.

Referenced by get_id(), and set_id().

◆ PRIORITY_USER_MIN

priority_t const cluck_daemon::computer::PRIORITY_USER_MIN = 1
static

Definition at line 56 of file computer.h.

Referenced by computer(), cluck_daemon::cluckd::msg_cluster_up(), and set_id().


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

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.