gusimplewhiteboard
NXT_Sound_Control.hpp
Go to the documentation of this file.
1#ifndef NXT_Sound_Control_DEFINED
2#define NXT_Sound_Control_DEFINED
3
4#include <cstdlib>
5#include <stdlib.h>
6#include <cstring>
7#include <sstream>
8#include <gu_util.h>
9#include "gusimplewhiteboard.h"
10#include "wb_sound.h"
11
12namespace guWhiteboard {
18 public:
21
22#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
24 NXT_Sound_Control(const std::string &name) {
25 from_string(name);
26 }
27
29 std::string description() {
30 std::ostringstream ss;
31 ss << static_cast<int>(frequency()) << ",";
32 ss << static_cast<int>(duration()) << ",";
33 return ss.str();
34 }
35
37 void from_string (std::string str) {
38 using namespace std;
39 set_frequency(0);
40 set_duration(false);
41 vector<string> elements = components_of_string_separated(str, ',', true);
42
43 if (elements.size() == 0) return; // nothin in the string ESCAPE
44
45 // ONE ELEMNET
46 set_frequency( static_cast<uint16_t>(atoi(elements[0].c_str()) ));
47 if (elements.size() < 2) return; // only one lement in the string =>ESCAPE
48 set_duration( static_cast<uint16_t>(atoi(elements[0].c_str()) ));
49 }
50#endif
53 bool temp = true;
54 if (frequency()!= s.frequency() )
55 return false;
56 if (duration()!= s.duration() )
57 return false;
58
59 return temp;
60 }
61
62 };
63}
64#endif //NXT_Sound_Control_DEFINED
Class for controlling differential robots Defines whiteboard message.
NXT_Sound_Control(const std::string &name)
String constructor.
void from_string(std::string str)
string conversion
bool operator==(const NXT_Sound_Control &s)
override equality operator so we can compare instances
NXT_Sound_Control()
Designated constructor.
std::string description()
get message description
/file APM_Interface.h
/file wb_sound.h
Definition: wb_sound.h:18