llama_ros: llama.cpp for ROS 2
Loading...
Searching...
No Matches
spinner.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2023 Miguel Ángel González Santamarta
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21// SOFTWARE.
22
23#ifndef LLAMA_UTILS__SPINNER_HPP
24#define LLAMA_UTILS__SPINNER_HPP
25
26#include <cstdio>
27#include <string>
28
29namespace llama_utils {
30
31class Spinner {
32
33public:
35 this->spinner = "-\\|/";
36 this->index = 0;
37 }
38
39 void spin(std::string text) {
40 fprintf(stderr, "%c %s\n", spinner[index], text.c_str());
41 fflush(stderr);
42 fprintf(stderr, "\033[1A\033[2K");
43 index = (index + 1) % 4;
44 }
45 void spin() { this->spin(""); }
46
47private:
48 const char *spinner;
49 int index = 0;
50};
51
52} // namespace llama_utils
53
54#endif
int index
Definition spinner.hpp:49
Spinner()
Definition spinner.hpp:34
const char * spinner
Definition spinner.hpp:48
void spin(std::string text)
Definition spinner.hpp:39
void spin()
Definition spinner.hpp:45
Definition llama_params.hpp:37