state.h

00001 #ifndef _DHT_KADC_STATE_H_
00002 #define _DHT_KADC_STATE_H_
00003 
00004 #include "client.h"
00005 #include "observer_info.h"
00006 #include "../notify_handler.h"
00007 
00008 namespace dht {
00009 namespace kadc {
00010     class state {
00011         const char *_id;
00012     protected:
00013         void change_state(client *d, state *s, int t) {
00014             d->_change_state(s);
00015             d->_change_state_out(t);
00016         }
00017         void kad_context(client *d, KadCcontext kcc) {
00018             d->_kad_context(kcc); 
00019         }
00020         KadCcontext *kad_context(client *d) {
00021             return d->_kad_context();
00022         }
00023 
00024         client::message_queue_type *message_queue(client *d) {
00025             return d->_message_queue();
00026         }
00027         
00028         inline event_observer_notifier *observer_notifier(client *d) {
00029             return d->observer_notifier();
00030         }
00031         void task_add(client *d, task *t) {
00032             d->_task_add(t);
00033         }
00034         void quit_all_tasks(client *d) {
00035             d->_quit_all_tasks();
00036         }
00037         int running_tasks_size(client *d) {
00038             return d->_running_tasks_size();
00039         }
00040          
00041         void attach_observer_messages(client *d, const observer_info &oi) {
00042             d->_attach_observer_messages(oi);
00043         }
00044         bool detach_observer_messages(client *d, observer_info *oi) {
00045             return d->_detach_observer_messages(oi);
00046         }
00047         
00048         inline void external_addr(client *d, const addr_inet_type &a) { 
00049             d->_external_addr(a);
00050         }
00051 
00052         inline bool kadc_started(client *d) const { 
00053             return d->_kadc_started();
00054         }
00055         inline void kadc_started(client *d, bool t) { 
00056             return d->_kadc_started(t);
00057         }
00058                 
00059         void notify(client *d, const class message *m, notify_handler *n);
00060         int  search_result(client *d, const class message *m, notify_handler *n);
00061         void search_done(client *d, const class message *m, notify_handler *n);
00062         
00063         state(const char *id = "");
00064         virtual ~state();
00065     public:
00066         virtual void connect(client *d, notify_handler *n) = 0;
00067         virtual void disconnect(client *d, notify_handler *n) = 0;
00068 
00069         virtual void find(client *d,
00070                           const key      &index,
00071                           search_handler *handler);
00072         
00073         virtual void store(client *d,
00074                            const key      &index,
00075                            const value    &content,
00076                            notify_handler *notify = NULL);
00077         
00078         inline const char *id() const { return _id; }
00079     };
00080 } // ns kadc
00081 } // ns dht
00082 
00083 #endif // _DHT_KADC_STATE_H_

Generated on Thu Mar 1 16:18:47 2007 for libdht by  doxygen 1.5.1