cluck 1.0.1
The cluster lock service.
computer.h
Go to the documentation of this file.
1// Copyright (c) 2016-2025 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/cluck
4// contact@m2osw.com
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18#pragma once
19
20// libaddr
21//
22#include <libaddr/addr.h>
23
24
25// snapdev
26//
27#include <snapdev/timespec_ex.h>
28
29
30// C++
31//
32#include <map>
33#include <memory>
34#include <string>
35#include <vector>
36
37
38
39namespace cluck_daemon
40{
41
42
43
45{
46public:
47 typedef std::int8_t priority_t;
48 typedef std::uint32_t random_t;
49 typedef std::shared_ptr<computer> pointer_t;
50 typedef std::map<std::string, pointer_t> map_t;
51 typedef std::vector<pointer_t> vector_t;
52
53 static priority_t const PRIORITY_UNDEFINED = -1;
54 static priority_t const PRIORITY_MIN = 0;
55 static priority_t const PRIORITY_LEADER = 0;
56 static priority_t const PRIORITY_USER_MIN = 1;
57 static priority_t const PRIORITY_DEFAULT = 14;
58 static priority_t const PRIORITY_OFF = 15;
59 static priority_t const PRIORITY_MAX = 15;
60
61 computer();
63 std::string const & name
64 , priority_t priority
65 , addr::addr ip_address);
66
67 bool is_self() const;
68 void set_connected(bool connected);
69 bool get_connected() const;
70 bool set_id(std::string const & id);
72 void set_start_time(snapdev::timespec_ex const & start_time);
73 snapdev::timespec_ex const &
74 get_start_time() const;
75
76 std::string const & get_name() const;
77 std::string const & get_id() const;
78 addr::addr const & get_ip_address() const;
79
80private:
81 mutable std::string f_id = std::string();
82
83 bool f_connected = true;
84 bool f_self = false;
85
88 addr::addr f_ip_address = addr::addr();
89 pid_t f_pid = 0;
90 std::string f_name = std::string();
91
92 snapdev::timespec_ex f_start_time = snapdev::timespec_ex();
93};
94
95
96
97} // namespace cluck_daemon
98// vim: ts=4 sw=4 et
void set_start_time(snapdev::timespec_ex const &start_time)
Definition computer.cpp:277
void set_connected(bool connected)
Definition computer.cpp:125
std::string const & get_name() const
Definition computer.cpp:289
bool get_connected() const
Definition computer.cpp:131
snapdev::timespec_ex const & get_start_time() const
Definition computer.cpp:283
static priority_t const PRIORITY_UNDEFINED
Definition computer.h:53
addr::addr const & get_ip_address() const
Definition computer.cpp:330
static priority_t const PRIORITY_LEADER
Definition computer.h:55
std::vector< pointer_t > vector_t
Definition computer.h:51
static priority_t const PRIORITY_MIN
Definition computer.h:54
static priority_t const PRIORITY_USER_MIN
Definition computer.h:56
std::map< std::string, pointer_t > map_t
Definition computer.h:50
std::uint32_t random_t
Definition computer.h:48
std::string f_name
Definition computer.h:90
addr::addr f_ip_address
Definition computer.h:88
static priority_t const PRIORITY_MAX
Definition computer.h:59
priority_t f_priority
Definition computer.h:86
static priority_t const PRIORITY_DEFAULT
Definition computer.h:57
static priority_t const PRIORITY_OFF
Definition computer.h:58
snapdev::timespec_ex f_start_time
Definition computer.h:92
std::int8_t priority_t
Definition computer.h:47
bool set_id(std::string const &id)
Initialize this computer object from id.
Definition computer.cpp:153
priority_t get_priority() const
Definition computer.cpp:271
std::shared_ptr< computer > pointer_t
Definition computer.h:49
std::string const & get_id() const
Definition computer.cpp:295

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.