xorp

fea_io.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2007-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 
00021 
00022 #ifndef __FEA_FEA_IO_HH__
00023 #define __FEA_FEA_IO_HH__
00024 
00025 
00026 //
00027 // FEA (Forwarding Engine Abstraction) I/O interface.
00028 //
00029 
00030 
00031 
00032 class EventLoop;
00033 class FeaNode;
00034 class InstanceWatcher;
00035 
00039 class FeaIo {
00040 public:
00046     FeaIo(EventLoop& eventloop);
00047 
00051     virtual ~FeaIo();
00052 
00058     int     startup();
00059 
00065     int     shutdown();
00066 
00072     bool    is_running() const;
00073 
00079     EventLoop& eventloop() { return (_eventloop); }
00080 
00090     virtual int add_instance_watch(const string& instance_name,
00091                    InstanceWatcher* instance_watcher,
00092                    string& error_msg);
00093 
00103     virtual int delete_instance_watch(const string& instance_name,
00104                       InstanceWatcher* instance_watcher,
00105                       string& error_msg);
00106 
00112     virtual void instance_birth(const string& instance_name);
00113 
00119     virtual void instance_death(const string& instance_name);
00120 
00121 protected:
00130     virtual int register_instance_event_interest(const string& instance_name,
00131                          string& error_msg) = 0;
00132 
00141     virtual int deregister_instance_event_interest(const string& instance_name,
00142                            string& error_msg) = 0;
00143 
00144 private:
00145     EventLoop&  _eventloop; // The event loop to use
00146     bool    _is_running;    // True if the service is running
00147 
00148     list<pair<string, InstanceWatcher *> > _instance_watchers;
00149 };
00150 
00151 //
00152 
00160 class InstanceWatcher {
00161 public:
00162     virtual ~InstanceWatcher() {}
00163 
00169     virtual void instance_birth(const string& instance_name) = 0;
00170 
00176     virtual void instance_death(const string& instance_name) = 0;
00177 };
00178 
00179 #endif // __FEA_FEA_IO_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations