]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/protocol.hxx
Update 'magic' for more consistant cross platform padding.
[flightgear.git] / src / Network / protocol.hxx
index 8c6535b520448d5bfe14c8832265595336616801..b0c82c558305bf84316ef475e12da6a14e2e5e13 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started November 1999.
 //
-// Copyright (C) 1999  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1999  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -26,6 +26,7 @@
 
 
 #include <simgear/compiler.h>
+#include <simgear/io/iochannel.hxx>
 
 #include STL_STRING
 #include <vector>
@@ -36,16 +37,13 @@ SG_USING_STD(vector);
 
 #define FG_MAX_MSG_SIZE 16384
 
-// forward declaration
-class SGIOChannel;
-
-
 class FGProtocol {
 
 private:
 
     double hz;
-    int count_down;
+    double count_down;
+    long count;
 
     SGProtocolDir dir;
 
@@ -68,23 +66,16 @@ public:
     virtual bool close();
 
     inline SGProtocolDir get_direction() const { return dir; }
-    inline void set_direction( const string& d ) {
-       if ( d == "in" ) {
-           dir = SG_IO_IN;
-       } else if ( d == "out" ) {
-           dir = SG_IO_OUT;
-       } else if ( d == "bi" ) {
-           dir = SG_IO_BI;
-       } else {
-           dir = SG_IO_NONE;
-       }
-    }
+    void set_direction( const string& d );
 
     inline double get_hz() const { return hz; }
     inline void set_hz( double t ) { hz = t; }
-    inline int get_count_down() const { return count_down; }
-    inline void set_count_down( int c ) { count_down = c; }
-    inline void dec_count_down( int c ) { count_down -= c; }
+    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; }
 
     virtual bool gen_message();
     virtual bool parse_message();
@@ -108,6 +99,18 @@ typedef vector < FGProtocol * > io_container;
 typedef io_container::iterator io_iterator;
 typedef io_container::const_iterator const_io_iterator;
 
+#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
+
 
 #endif // _PROTOCOL_HXX