xorp

process_watch.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2009 XORP, Inc.
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 // $XORP: xorp/bgp/process_watch.hh,v 1.16 2008/10/02 21:56:18 bms Exp $
00021 
00022 #ifndef __BGP_PROCESS_WATCH_HH__
00023 #define __BGP_PROCESS_WATCH_HH__
00024 
00025 #include "libxorp/debug.h"
00026 #include "libxorp/xlog.h"
00027 #include "libxorp/eventloop.hh"
00028 #include "libxorp/timer.hh"
00029 #include "libxipc/xrl_std_router.hh"
00030 
00031 class ProcessWatch {
00032 public:
00033     typedef XorpCallback0<void>::RefPtr TerminateCallback;
00034 
00035     ProcessWatch(XrlStdRouter *xrl_router, EventLoop& eventloop,
00036          const char *bgp_mib_name,
00037          TerminateCallback cb);
00038 
00042     void birth(const string& target_class, const string& target_instance);
00043 
00047     void death(const string& target_class, const string& target_instance);
00048 
00052     void finder_death(const char *file, const int lineno);
00053 
00058     void start_kill_timer();
00059 
00064     bool ready() const;
00065 
00069     bool target_exists(const string& target) const;
00070 
00071 protected:
00072     void interest_callback(const XrlError& error);
00073     void add_target(const string& target_class,
00074              const string& target_instance);
00075     void remove_target(const string& target_class,
00076             const string& target_instance);
00077 
00078 private:
00079     EventLoop& _eventloop;
00080     TerminateCallback _shutdown;
00081 
00082     bool _fea;
00083     bool _rib;
00084 
00085     string _fea_instance;
00086     string _rib_instance;
00087 
00088     XorpTimer _shutdown_timer;
00089 
00090     class Process {
00091     public:
00092     Process(string c, string i) : _target_class(c), _target_instance(i)
00093     {}
00094     string _target_class;
00095     string _target_instance;
00096     };
00097 
00098     list<Process> _processes;
00099 };
00100 
00101 #endif // __BGP_PROCESS_WATCH_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations