Main Page
Namespaces
Classes
Files
File List
File Members
libswarmio
include
swarmio
tool
Loop.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <string>
4
#include <mutex>
5
#include <replxx.hxx>
6
#include <
swarmio/tool/Command.h
>
7
#include <
swarmio/tool/LogBuffer.h
>
8
#include <
swarmio/profiles/ClientProfile.h
>
9
#include <
swarmio/transport/zyre/ZyreEndpoint.h
>
10
#include <
swarmio/services/telemetry/UpdateAwaiter.h
>
11
#include <swarmio/data/Variant.pb.h>
12
13
namespace
swarmio::tool
14
{
19
class
Loop
final :
private
profiles::ClientProfile
20
{
21
private
:
22
27
replxx::Replxx
_repl
;
28
33
const
Node
*
_selectedNode
=
nullptr
;
34
39
LogBuffer
*
_logBuffer
=
nullptr
;
40
46
std::string
GetPrompt
();
47
52
std::vector<const Node*>
_nodes
;
53
58
std::list<services::telemetry::UpdateAwaiter>
_subscriptions
;
59
64
std::mutex
_mutex
;
65
71
virtual
void
NodeWasDiscovered
(
const
Node
* node) noexcept
override
;
72
79
data::Variant
ConvertToVariant
(
const
std::string& value);
80
87
bool
ExecuteCommand
(
const
std::string& command);
88
94
void
ExecuteMembersCommand
(
const
Command
& command);
95
101
void
ExecuteSelectCommand
(
const
Command
& command);
102
108
void
ExecutePingCommand
(
const
Command
& command);
109
115
void
ExecuteInfoCommand
(
const
Command
& command);
116
122
void
ExecuteEventCommand
(
const
Command
& command);
123
129
void
ExecuteSetCommand
(
const
Command
& command);
130
136
void
ExecuteGetCommand
(
const
Command
& command);
137
143
void
ExecuteRediscoverCommand
(
const
Command
& command);
144
150
void
ExecuteSubscriptionsCommand
(
const
Command
& command);
151
157
void
ExecuteSubscribeCommand
(
const
Command
& command);
158
164
void
ExecuteUnsubscribeCommand
(
const
Command
& command);
165
171
void
ExecuteLogCommand
(
const
Command
& command);
172
173
public
:
174
181
Loop
(
Endpoint
* endpoint,
LogBuffer
* logBuffer);
182
187
void
Run
();
188
};
189
190
}
swarmio::tool
Definition:
Command.h:7
swarmio::tool::Loop
The command line interface for the tool.
Definition:
Loop.h:19
swarmio::tool::Loop::ExecuteMembersCommand
void ExecuteMembersCommand(const Command &command)
Execute a 'members' command.
Definition:
Loop.cpp:319
swarmio::tool::Loop::_nodes
std::vector< const Node * > _nodes
Nodes and their indices.
Definition:
Loop.h:52
swarmio::tool::Loop::_mutex
std::mutex _mutex
Mutex to protect nodes vector.
Definition:
Loop.h:64
swarmio::tool::Loop::ExecuteSetCommand
void ExecuteSetCommand(const Command &command)
Execute an 'set' command.
Definition:
Loop.cpp:201
swarmio::tool::Loop::ExecuteEventCommand
void ExecuteEventCommand(const Command &command)
Execute an 'event' command.
Definition:
Loop.cpp:273
swarmio::tool::LogBuffer
Definition:
LogBuffer.h:10
swarmio::tool::Loop::Loop
Loop(Endpoint *endpoint, LogBuffer *logBuffer)
Construct a new Loop object.
Definition:
Loop.cpp:17
swarmio::tool::Loop::_subscriptions
std::list< services::telemetry::UpdateAwaiter > _subscriptions
Currently held subscriptions.
Definition:
Loop.h:58
swarmio::tool::Loop::ExecuteLogCommand
void ExecuteLogCommand(const Command &command)
Execute an 'log' command.
Definition:
Loop.cpp:458
swarmio::tool::Loop::ExecutePingCommand
void ExecutePingCommand(const Command &command)
Execute a 'ping' command.
Definition:
Loop.cpp:236
swarmio::tool::Loop::GetPrompt
std::string GetPrompt()
Build prompt string.
Definition:
Loop.cpp:33
swarmio::tool::Loop::ExecuteGetCommand
void ExecuteGetCommand(const Command &command)
Execute an 'get' command.
Definition:
Loop.cpp:152
swarmio::tool::Loop::_selectedNode
const Node * _selectedNode
Selected node.
Definition:
Loop.h:33
ZyreEndpoint.h
swarmio::tool::Loop::Run
void Run()
Run the command loop.
Definition:
Loop.cpp:45
swarmio::Endpoint
Abstract base class for Endpoint implementations.
Definition:
Endpoint.h:25
swarmio::tool::Loop::ExecuteSelectCommand
void ExecuteSelectCommand(const Command &command)
Execute a 'select' command.
Definition:
Loop.cpp:339
swarmio::tool::Loop::_logBuffer
LogBuffer * _logBuffer
Log buffer.
Definition:
Loop.h:39
swarmio::tool::Loop::ExecuteCommand
bool ExecuteCommand(const std::string &command)
Execute a command given by the user.
Definition:
Loop.cpp:473
swarmio::tool::Loop::ExecuteSubscribeCommand
void ExecuteSubscribeCommand(const Command &command)
Execute a 'subscribe' command.
Definition:
Loop.cpp:410
swarmio::tool::Loop::ExecuteRediscoverCommand
void ExecuteRediscoverCommand(const Command &command)
Execute an 'rediscover' command.
Definition:
Loop.cpp:146
swarmio::tool::Loop::ConvertToVariant
data::Variant ConvertToVariant(const std::string &value)
Convert a string parameter to a variant.
Definition:
Loop.cpp:572
LogBuffer.h
swarmio::tool::Loop::_repl
replxx::Replxx _repl
REPL interface.
Definition:
Loop.h:27
swarmio::tool::Loop::ExecuteSubscriptionsCommand
void ExecuteSubscriptionsCommand(const Command &command)
Execute a 'subscriptions' command.
Definition:
Loop.cpp:371
swarmio::tool::Loop::ExecuteInfoCommand
void ExecuteInfoCommand(const Command &command)
Execute an 'info' command.
Definition:
Loop.cpp:82
swarmio::Node
Represents a Node the Endpoint knows about and can send messages to.
Definition:
libswarmio/include/swarmio/Node.h:11
Command.h
swarmio::tool::Command
Parser for commands of the default form.
Definition:
Command.h:15
swarmio::tool::Loop::ExecuteUnsubscribeCommand
void ExecuteUnsubscribeCommand(const Command &command)
Execute an 'unsubscribe' command.
Definition:
Loop.cpp:443
ClientProfile.h
swarmio::profiles::ClientProfile
Service profile for non-member clients.
Definition:
ClientProfile.h:12
swarmio::tool::Loop::NodeWasDiscovered
virtual void NodeWasDiscovered(const Node *node) noexceptoverride
Called when a new Node has been discovered.
Definition:
Loop.cpp:25
UpdateAwaiter.h
swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48