-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultIO.cpp
More file actions
47 lines (42 loc) · 1.17 KB
/
DefaultIO.cpp
File metadata and controls
47 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include "DefaultIO.h"
const std::map<std::string, Instruction> ConsoleIO::_instructionMap =
{
{"play", Instruction::PLAY},
{"pause", Instruction::PAUSE},
{"stop", Instruction::STOP},
{"quit", Instruction::QUIT},
{"+", Instruction::VOLUME_UP},
{"-", Instruction::VOLUME_DOWN},
{"mute", Instruction::MUTE},
{"next", Instruction::NEXT},
{"prev", Instruction::PREVIOUS}
};
const std::map<State, std::string> ConsoleIO::_stateMap =
{
{State::PLAYING, "playing"},
{State::PAUSED, "paused...."},
{State::STOPPED, "stopped"},
{State::QUITTING, "Bye :)"},
{State::VOLUME_SET, "Volume set"},
{State::MUTE, "toggled mute"},
{State::ERROR, "error"}
};
Instruction ConsoleIO::getInstruction()
{
std::string in;
std::cout << ">> ";
if(std::getline(std::cin,in) );
{
std::map<std::string, Instruction>::const_iterator ci = _instructionMap.find(in);
if(ci != _instructionMap.end())
{
return ci->second;
}
}
return Instruction::STOP;
}
void ConsoleIO::sendState(const State& state)
{
std::cout << _stateMap.find(state)->second << std::endl;
}