iochannel.hxx

Go to the documentation of this file.
00001 
00006 // Written by Curtis Olson, started November 1999.
00007 //
00008 // Copyright (C) 1999  Curtis L. Olson - http://www.flightgear.org/~curt
00009 //
00010 // This program is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License as
00012 // published by the Free Software Foundation; either version 2 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This program is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU General Public License
00021 // along with this program; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 //
00024 // $Id: iochannel_8hxx-source.html,v 1.15 2007-12-17 15:37:04 curt Exp $
00025 
00026 
00027 #ifndef _IOCHANNEL_HXX
00028 #define _IOCHANNEL_HXX
00029 
00030 
00031 #include <simgear/compiler.h>
00032 
00033 // #include "protocol.hxx"
00034 
00035 #include STL_STRING
00036 #include <vector>
00037 
00038 SG_USING_STD(vector);
00039 SG_USING_STD(string);
00040 
00041 
00042 #define SG_IO_MAX_MSG_SIZE 16384
00043 
00048 enum SGProtocolDir {
00049     SG_IO_NONE = 0,
00050     SG_IO_IN = 1,
00051     SG_IO_OUT = 2,
00052     SG_IO_BI = 3
00053 };
00054 
00058 enum SGChannelType {
00059     sgFileType = 0,
00060     sgSerialType = 1,
00061     sgSocketType = 2
00062 };
00063 
00064 
00076 class SGIOChannel {
00077 
00078     SGChannelType type;
00079     SGProtocolDir dir;
00080     bool valid;
00081 
00082 public:
00083 
00085     SGIOChannel();
00086 
00088     virtual ~SGIOChannel();
00089 
00101     virtual bool open( const SGProtocolDir d );
00102 
00115     virtual int read( char *buf, int length );
00116 
00124     virtual int readline( char *buf, int length );
00125 
00126 
00136     virtual int write( const char *buf, const int length );
00137 
00145     virtual int writestring( const char *str );
00146 
00153     virtual bool close();
00154 
00161     virtual bool eof();
00162 
00163     inline void set_type( SGChannelType t ) { type = t; }
00164     inline SGChannelType get_type() const { return type; }
00165 
00166     inline void set_dir( const SGProtocolDir d ) { dir = d; }
00167     inline SGProtocolDir get_dir() const { return dir; }
00168     inline bool isvalid() const { return valid; }
00169     inline void set_valid( const bool v ) { valid = v; }
00170 };
00171 
00172 
00173 #endif // _IOCHANNEL_HXX
00174 
00175 

Generated on Mon Dec 17 09:30:54 2007 for SimGear by  doxygen 1.5.1