]> git.mxchange.org Git - flightgear.git/blob - src/Network/protocol.hxx
Revert to pre-wind-sticking ground reaction forces until they can be debugged.
[flightgear.git] / src / Network / protocol.hxx
1 // protocol.hxx -- High level protocal class
2 //
3 // Written by Curtis Olson, started November 1999.
4 //
5 // Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _PROTOCOL_HXX
25 #define _PROTOCOL_HXX
26
27
28 #include <simgear/compiler.h>
29
30 #include STL_STRING
31 #include <vector>
32
33 SG_USING_STD(string);
34 SG_USING_STD(vector);
35
36
37 #define FG_MAX_MSG_SIZE 16384
38
39 // forward declaration
40 class SGIOChannel;
41
42
43 class FGProtocol {
44
45 private:
46
47     double hz;
48     int count_down;
49
50     SGProtocolDir dir;
51
52     // string protocol_str;
53
54     // char buf[FG_MAX_MSG_SIZE];
55     // int length;
56
57     bool enabled;
58
59     SGIOChannel *io;
60
61 public:
62
63     FGProtocol();
64     virtual ~FGProtocol();
65
66     virtual bool open();
67     virtual bool process();
68     virtual bool close();
69
70     inline SGProtocolDir get_direction() const { return dir; }
71     inline void set_direction( const string& d ) {
72         if ( d == "in" ) {
73             dir = SG_IO_IN;
74         } else if ( d == "out" ) {
75             dir = SG_IO_OUT;
76         } else if ( d == "bi" ) {
77             dir = SG_IO_BI;
78         } else {
79             dir = SG_IO_NONE;
80         }
81     }
82
83     inline double get_hz() const { return hz; }
84     inline void set_hz( double t ) { hz = t; }
85     inline int get_count_down() const { return count_down; }
86     inline void set_count_down( int c ) { count_down = c; }
87     inline void dec_count_down( int c ) { count_down -= c; }
88
89     virtual bool gen_message();
90     virtual bool parse_message();
91
92     // inline string get_protocol() const { return protocol_str; }
93     // inline void set_protocol( const string& str ) { protocol_str = str; }
94
95     // inline char *get_buf() { return buf; }
96     // inline int get_length() const { return length; }
97     // inline void set_length( int l ) { length = l; }
98
99     inline bool is_enabled() const { return enabled; }
100     inline void set_enabled( const bool b ) { enabled = b; }
101
102     inline SGIOChannel *get_io_channel() const { return io; }
103     inline void set_io_channel( SGIOChannel *c ) { io = c; }
104 };
105
106
107 typedef vector < FGProtocol * > io_container;
108 typedef io_container::iterator io_iterator;
109 typedef io_container::const_iterator const_io_iterator;
110
111
112 #endif // _PROTOCOL_HXX
113
114