Babel  1
The voip software that only works on your local network
Loading...
Searching...
No Matches
ThreadCapsule.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** epitech-ratrappage-babel (Workspace)
4** File description:
5** ThreadCapsule.hpp
6*/
7
13#pragma once
14
15#include <thread>
16#include <atomic>
17#include <chrono>
18#include <iostream>
19
20#include "CustomExceptions.hpp"
22
23namespace Controls
24{
29 public:
32
36 void startThread();
37
41 void stopThread(const unsigned int delay = 2);
42
48 const bool isRunning() const;
49
56 const std::string getInfo(const unsigned int indent = 0) const;
57
62 void setEcho(const bool echo);
63
68 void setHelp(const bool help);
69
74 void setPlaying(const bool playing);
75
80 void setLooping(const bool looping);
81
86 void setRecording(const bool recording);
87
92 void setUserChoice(const std::string &userChoice);
93
98 const bool isEcho() const;
99
104 const bool isHelp() const;
105
110 const bool isPlaying() const;
111
116 const bool isLooping() const;
117
122 const bool isRecording() const;
123
128 const bool hangUpTheCall() const;
129
133 void showPrompt() const;
134
138 void toggleEcho();
139
143 void toggleHelp();
144
148 void togglePlaying();
149
153 void toggleLooping();
154
158 void toggleRecording();
159
160 private:
161 std::thread _thread;
162 std::atomic<bool> _running;
163 UserControls _userControls;
164 };
165
173 std::ostream &operator<<(std::ostream &os, const ThreadCapsule &network);
174}
Aggregates custom exception headers.
This file contains the definition of the UserControls class, which manages user input and control sta...
Manages a thread for user controls.
const bool isRunning() const
Checks if the thread is running.
void toggleHelp()
Toggles the help state.
void toggleRecording()
Toggles the recording state.
const bool isLooping() const
Checks if looping is enabled.
void startThread()
Starts the thread to run the spamUserChoice function.
void toggleLooping()
Toggles the looping state.
void stopThread(const unsigned int delay=2)
Stops the thread safely.
void togglePlaying()
Toggles the playing state.
const bool isPlaying() const
Checks if playing is enabled.
void setUserChoice(const std::string &userChoice)
Processes the user choice.
const bool isHelp() const
Checks if help is enabled.
const bool isRecording() const
Checks if recording is enabled.
void setEcho(const bool echo)
Sets the echo state.
const std::string getInfo(const unsigned int indent=0) const
Dumps the current state of the variables for debugging purposes.
void setRecording(const bool recording)
Sets the recording state.
const bool hangUpTheCall() const
Checks if the call should be hung up.
void setPlaying(const bool playing)
Sets the playing state.
void setLooping(const bool looping)
Sets the looping state.
const bool isEcho() const
Checks if echo is enabled.
void toggleEcho()
Toggles the echo state.
void showPrompt() const
Displays the prompt to the user.
void setHelp(const bool help)
Sets the help state.
Manages user input and control states.
std::ostream & operator<<(std::ostream &os, const ThreadCapsule &network)
Overloads the stream insertion operator for ThreadCapsule.