Change license from LGPL to GPL version 2 + linking exception. This fixes C++ templat...
[libt2n] / src / command_client.hxx
CommitLineData
19facd85
TJ
1/*
2Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
3
4The software in this package is distributed under the GNU General
5Public License version 2 (with a special exception described below).
6
7A copy of GNU General Public License (GPL) is included in this distribution,
8in the file COPYING.GPL.
9
10As a special exception, if other files instantiate templates or use macros
11or inline functions from this file, or you compile this file and link it
12with other works to produce a work based on this file, this file
13does not by itself cause the resulting work to be covered
14by the GNU General Public License.
15
16However the source code for this file must still be made available
17in accordance with section (3) of the GNU General Public License.
18
19This exception does not invalidate any other reasons why a work based
20on this file might be covered by the GNU General Public License.
21*/
7087e187
GE
22#ifndef __LIBT2N_COMMAND_CLIENT
23#define __LIBT2N_COMMAND_CLIENT
24
b5922184
GE
25#include <functional>
26#include <string>
27
7087e187
GE
28#include "client.hxx"
29#include "container.hxx"
30
31namespace libt2n
32{
33
34/// a client sending out commands to a server
35class command_client
36{
0ea6d528 37 public:
2c49df2a
GE
38 static const long long command_timeout_usec_default=90000000;
39 static const long long hello_timeout_usec_default=30000000;
40
7087e187 41 private:
fb3345ad 42 client_connection *c;
7087e187 43
45a2ebc9
GE
44 long long hello_timeout_usec;
45 long long command_timeout_usec;
46
8104c8f7 47 void read_hello();
45a2ebc9 48 std::string read_packet(const long long &usec_timeout);
b2ba0928 49 bool check_hello(const std::string& hellostr);
8104c8f7 50
696c95c2 51 t2n_exception *constructorException;
b5922184 52
7087e187 53 public:
fb3345ad 54 command_client(client_connection* _c,
2c49df2a
GE
55 long long _command_timeout_usec=command_timeout_usec_default,
56 long long _hello_timeout_usec=hello_timeout_usec_default);
696c95c2 57 virtual ~command_client();
7087e187 58
fb3345ad 59 void replace_connection(client_connection* _c);
af84dfb5 60
7087e187 61 void send_command(command* cmd, result_container &res);
a64066eb
GE
62
63 void set_command_timeout_usec(long long _command_timeout_usec=command_timeout_usec_default)
64 { command_timeout_usec=_command_timeout_usec; }
65 void set_hello_timeout_usec(long long _hello_timeout_usec=hello_timeout_usec_default)
66 { hello_timeout_usec=_hello_timeout_usec; }
67 long long get_command_timeout_usec(void)
68 { return command_timeout_usec; }
69 long long get_hello_timeout_usec(void)
70 { return hello_timeout_usec; }
b5922184
GE
71 bool is_connection_closed(void)
72 { return c->is_closed(); }
73 t2n_exception* get_constuctor_exception(void)
696c95c2 74 { return constructorException; }
7087e187
GE
75};
76
77}
78
79#endif
80