]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/command.h
Rewrite command/reply system
[r2c2.git] / source / libmarklin / command.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef COMMAND_H_
9 #define COMMAND_H_
10
11 #include <ostream>
12 #include <string>
13 #include <sigc++/sigc++.h>
14 #include "constants.h"
15
16 namespace Marklin {
17
18 class Reply;
19
20 class Command
21 {
22 private:
23         Cmd cmd;
24         unsigned char data[128];
25         unsigned len;
26         bool sent;
27
28 public:
29         sigc::signal<void, const Reply &> signal_done;
30
31         Command(Cmd, const unsigned char *, unsigned);
32
33         void send(int);
34         bool get_sent() const   { return sent; }
35         Cmd get_command() const { return cmd; }
36
37         friend std::ostream &operator<<(std::ostream &, const Command &);
38 };
39
40 } // namespace Marklin
41
42 #endif