rstpclientmcif.h

00001 /* libradar_stp
00002  * <http://www.k9nl.net/radar/> <radar@k9nl.net>
00003  * 
00004  * rstpclientifmc.h - RSTP client class interface
00005  * for multiple connections
00006  *
00007  * Copyright (C) 2007 Nicholas J. Luther
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License,
00011  * version 2, as published by the Free Software Foundation.
00012  * 
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021  * You may contact the author by writing to Nick Luther, 1655 South
00022  * Westhaven Drive, Oshkosh, Wisconsin 54904, USA.
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 // Windows DLL stuff
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   }; // class
00233   
00234 }; // namespace
00235 
00236 
00237 #endif
00238 

Generated on Tue Jul 1 20:25:26 2008 for libradar_stp by  doxygen 1.4.7