X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2Fprotocol.hxx;h=f02ef57554f6a828cad01be595004c8a22d39858;hb=a739fad66484506ebb71fc802bf8f1a0c2ab4c6c;hp=f3c7fe4d68959e169d3e0edf82f987106edb586a;hpb=485230b443de22c97d5c4ddfda98598fb52ce98a;p=flightgear.git diff --git a/src/Network/protocol.hxx b/src/Network/protocol.hxx index f3c7fe4d6..f02ef5755 100644 --- a/src/Network/protocol.hxx +++ b/src/Network/protocol.hxx @@ -26,37 +26,26 @@ #include +#include #include STL_STRING #include -FG_USING_STD(string); -FG_USING_STD(vector); +SG_USING_STD(string); +SG_USING_STD(vector); #define FG_MAX_MSG_SIZE 16384 -// forward declaration -class FGIOChannel; - - class FGProtocol { -public: - - enum fgProtocolDir { - none = 0, - in = 1, - out = 2, - bi = 3 - }; - private: double hz; - int count_down; + double count_down; + long count; - fgProtocolDir dir; + SGProtocolDir dir; // string protocol_str; @@ -65,7 +54,7 @@ private: bool enabled; - FGIOChannel *io; + SGIOChannel *io; public: @@ -76,24 +65,17 @@ public: virtual bool process(); virtual bool close(); - inline fgProtocolDir get_direction() const { return dir; } - inline void set_direction( const string& d ) { - if ( d == "in" ) { - dir = in; - } else if ( d == "out" ) { - dir = out; - } else if ( d == "bi" ) { - dir = bi; - } else { - dir = none; - } - } + inline SGProtocolDir get_direction() const { return dir; } + 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,8 +90,8 @@ public: inline bool is_enabled() const { return enabled; } inline void set_enabled( const bool b ) { enabled = b; } - inline FGIOChannel *get_io_channel() const { return io; } - inline void set_io_channel( FGIOChannel *c ) { io = c; } + inline SGIOChannel *get_io_channel() const { return io; } + inline void set_io_channel( SGIOChannel *c ) { io = c; } }; @@ -117,6 +99,18 @@ typedef vector < FGProtocol * > io_container; typedef io_container::iterator io_iterator; typedef io_container::const_iterator const_io_iterator; +#include +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