1
0
Fork 0
flightgear/src/Network/protocol.hxx

118 lines
3.1 KiB
C++
Raw Normal View History

1999-11-19 02:10:24 +00:00
// protocol.hxx -- High level protocal class
//
// Written by Curtis Olson, started November 1999.
//
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
1999-11-19 02:10:24 +00:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// $Id$
#ifndef _PROTOCOL_HXX
#define _PROTOCOL_HXX
2000-02-15 03:30:01 +00:00
#include <simgear/compiler.h>
Bernie Bright: Here is the new super improved telnet property interface. CVS changelog is at the end of this message. Once this new telnet code is in and compiles every where we can remove Network/props.[ch]xx. I've added a --telnet=<port> command line option to invoke the new server. Later on we could remove the --props option, or least change it to invoke the new server. I'll let you decide. I've added some new commands to the telnet interface: view next Select the next view. view prev Select the previous view. view set <n> Select view 'n' view get Return index of current view I'm not sure if these same effects could be achieved through property operations. The commands provide a convenient shortcut in any case. I'm also planning on adding a panel command to manipulate panels and objects contained therein (eg simulated mouse clicks). There is going to be some commonality with the command objects so we may need to rationalize this in the near future. Finally, I've also included my python stuff. This is still very much a work in progress, basically I've been using it to test the new telnet server. I have tested it with python 2.2. Feel free to add it to the repository if you want. I would suggest a scripts/python directory CVS Changelog Network/telnet.cxx: New property telnet protocol interface. It supports the same user interface provided by the --props server. Additionally it handles multiple simultaneous connections. Added "view" command to manipulate viewmgr. Network/protocol.hxx: Added protocol configuration exception. Main/fg_io.cxx: Added new "telnet" protocol. Added protocol configuration parse exceptions. Simplified protocol configuration parsing. Main/options.cxx: Added --telnet=<port> command line option and help message.
2002-05-15 21:44:34 +00:00
#include <simgear/io/iochannel.hxx>
1999-11-19 02:10:24 +00:00
#include STL_STRING
#include <vector>
2001-03-23 22:59:18 +00:00
SG_USING_STD(string);
SG_USING_STD(vector);
1999-11-19 02:10:24 +00:00
#define FG_MAX_MSG_SIZE 16384
class FGProtocol {
private:
double hz;
double count_down;
long count;
1999-11-19 02:10:24 +00:00
SGProtocolDir dir;
1999-11-19 02:10:24 +00:00
// string protocol_str;
// char buf[FG_MAX_MSG_SIZE];
// int length;
bool enabled;
SGIOChannel *io;
1999-11-19 02:10:24 +00:00
public:
FGProtocol();
virtual ~FGProtocol();
virtual bool open();
virtual bool process();
virtual bool close();
inline SGProtocolDir get_direction() const { return dir; }
Bernie Bright: Here is the new super improved telnet property interface. CVS changelog is at the end of this message. Once this new telnet code is in and compiles every where we can remove Network/props.[ch]xx. I've added a --telnet=<port> command line option to invoke the new server. Later on we could remove the --props option, or least change it to invoke the new server. I'll let you decide. I've added some new commands to the telnet interface: view next Select the next view. view prev Select the previous view. view set <n> Select view 'n' view get Return index of current view I'm not sure if these same effects could be achieved through property operations. The commands provide a convenient shortcut in any case. I'm also planning on adding a panel command to manipulate panels and objects contained therein (eg simulated mouse clicks). There is going to be some commonality with the command objects so we may need to rationalize this in the near future. Finally, I've also included my python stuff. This is still very much a work in progress, basically I've been using it to test the new telnet server. I have tested it with python 2.2. Feel free to add it to the repository if you want. I would suggest a scripts/python directory CVS Changelog Network/telnet.cxx: New property telnet protocol interface. It supports the same user interface provided by the --props server. Additionally it handles multiple simultaneous connections. Added "view" command to manipulate viewmgr. Network/protocol.hxx: Added protocol configuration exception. Main/fg_io.cxx: Added new "telnet" protocol. Added protocol configuration parse exceptions. Simplified protocol configuration parsing. Main/options.cxx: Added --telnet=<port> command line option and help message.
2002-05-15 21:44:34 +00:00
void set_direction( const string& d );
1999-11-19 02:10:24 +00:00
inline double get_hz() const { return hz; }
inline void set_hz( double t ) { hz = t; }
inline double get_count_down() const { return count_down; }
inline void set_count_down( double c ) { count_down = c; }
inline void inc_count_down( double amt ) { count_down += amt; }
inline void dec_count_down( double amt ) { count_down -= amt; }
inline void inc_count() { count++; }
inline long get_count() { return count; }
1999-11-19 02:10:24 +00:00
virtual bool gen_message();
virtual bool parse_message();
// inline string get_protocol() const { return protocol_str; }
// inline void set_protocol( const string& str ) { protocol_str = str; }
// inline char *get_buf() { return buf; }
// inline int get_length() const { return length; }
// inline void set_length( int l ) { length = l; }
inline bool is_enabled() const { return enabled; }
inline void set_enabled( const bool b ) { enabled = b; }
inline SGIOChannel *get_io_channel() const { return io; }
inline void set_io_channel( SGIOChannel *c ) { io = c; }
1999-11-19 02:10:24 +00:00
};
typedef vector < FGProtocol * > io_container;
typedef io_container::iterator io_iterator;
typedef io_container::const_iterator const_io_iterator;
Bernie Bright: Here is the new super improved telnet property interface. CVS changelog is at the end of this message. Once this new telnet code is in and compiles every where we can remove Network/props.[ch]xx. I've added a --telnet=<port> command line option to invoke the new server. Later on we could remove the --props option, or least change it to invoke the new server. I'll let you decide. I've added some new commands to the telnet interface: view next Select the next view. view prev Select the previous view. view set <n> Select view 'n' view get Return index of current view I'm not sure if these same effects could be achieved through property operations. The commands provide a convenient shortcut in any case. I'm also planning on adding a panel command to manipulate panels and objects contained therein (eg simulated mouse clicks). There is going to be some commonality with the command objects so we may need to rationalize this in the near future. Finally, I've also included my python stuff. This is still very much a work in progress, basically I've been using it to test the new telnet server. I have tested it with python 2.2. Feel free to add it to the repository if you want. I would suggest a scripts/python directory CVS Changelog Network/telnet.cxx: New property telnet protocol interface. It supports the same user interface provided by the --props server. Additionally it handles multiple simultaneous connections. Added "view" command to manipulate viewmgr. Network/protocol.hxx: Added protocol configuration exception. Main/fg_io.cxx: Added new "telnet" protocol. Added protocol configuration parse exceptions. Simplified protocol configuration parsing. Main/options.cxx: Added --telnet=<port> command line option and help message.
2002-05-15 21:44:34 +00:00
#include <stdexcept>
SG_USING_STD(invalid_argument);
//namespace flightgear { namespace network {
class FGProtocolConfigError : public invalid_argument
{
public:
FGProtocolConfigError( const string& what_string )
: invalid_argument(what_string) {}
};
//}} // end namespace flightgear::network
1999-11-19 02:10:24 +00:00
#endif // _PROTOCOL_HXX