00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _LIBRSTP_INC_RSTPCLIENTMCIF_H
00027 #define _LIBRSTP_INC_RSTPCLIENTMCIF_H
00028
00029 #include <string>
00030 #include <vector>
00031 #include <set>
00032 #include <map>
00033
00034 #include "rstpclientif.h"
00035
00036
00037 #if defined(WIN32) || defined(WIN_NATIVE)
00038 #ifdef LIBRADAR_STP_EXPORTS
00039 #define LIBRADAR_STP_INTERFACE __declspec(dllexport)
00040 #else
00041 #define LIBRADAR_STP_INTERFACE __declspec(dllimport)
00042 #endif
00043 #else
00044 #define LIBRADAR_STP_INTERFACE
00045 #endif
00046
00047
00048 namespace libradar_stp {
00049
00059 class
00060 LIBRADAR_STP_INTERFACE
00061 RSTPClientMCIf {
00062 public:
00063
00064 RSTPClientMCIf();
00065 ~RSTPClientMCIf();
00066
00075 int addConnection();
00076
00083 RSTPClientIf& connection( int conn_id );
00084 const RSTPClientIf& connection( int conn_id ) const;
00085
00093 bool start();
00094
00101 bool quit();
00102
00103 typedef void (*CBFUNCDATA)( void*, const std::string&, const std::string& );
00104 typedef void (*CBFUNCERR)( void*, const std::string& );
00105
00114 void setDataCallback( CBFUNCDATA func, void* arg = 0 );
00115
00125 void setErrorCallback( CBFUNCERR func, void* arg = 0 );
00126
00133 void setRepeatCheckEnabled( bool enabled = true );
00134
00140 void setRepeatCheckDBSize( int size = 200 );
00141
00148 bool loadFile( const std::string& filename );
00149
00155 bool readConfig( std::istream& confin );
00156
00182 void setRedundantPeerModeEnabled( bool enabled = true );
00183
00195 void setRedundantPeerModeMaxTicks( int ticks = 10 );
00196
00201 void eventRedundantPeerModeTick();
00202
00203 private:
00204
00205 CBFUNCDATA m_data_cb;
00206 void* m_data_cb_arg;
00207 CBFUNCERR m_error_cb;
00208 void* m_error_cb_arg;
00209
00210 std::vector<RSTPClientIf*> m_connections;
00211
00212 bool m_running;
00213 bool m_repeat_check;
00214 int m_repeat_db_size;
00215 std::set<std::string> m_repeat_db_1;
00216 std::set<std::string> m_repeat_db_2;
00217
00218 bool m_redun_peer_mode;
00219 typedef std::map< std::string, std::string > redun_db_tick_el_t;
00220 std::vector< redun_db_tick_el_t > m_redun_db;
00221 bool m_redun_db_lock;
00222 int m_redun_tick;
00223
00224 bool repeatCheckPassed( const std::string& data );
00225 std::string dataSignature( const std::string& data ) const;
00226
00227 public:
00228
00229 static void _data_cb( void* arg, const std::string& stream, const std::string& data );
00230 static void _error_cb( void* arg, const std::string& msg );
00231
00232 };
00233
00234 };
00235
00236
00237 #endif
00238