xorp

process_watch.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8:
00003 
00004 // Copyright (c) 2001-2011 XORP, Inc and Others
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License, Version 2, June
00008 // 1991 as published by the Free Software Foundation. Redistribution
00009 // and/or modification of this program under the terms of any other
00010 // version of the GNU General Public License is not permitted.
00011 // 
00012 // This program is distributed in the hope that it will be useful, but
00013 // WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00015 // see the GNU General Public License, Version 2, a copy of which can be
00016 // found in the XORP LICENSE.gpl file.
00017 // 
00018 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00019 // http://xorp.net
00020 
00021 // $XORP: xorp/policy/process_watch.hh,v 1.9 2008/10/02 21:58:00 bms Exp $
00022 
00023 #ifndef __POLICY_PROCESS_WATCH_HH__
00024 #define __POLICY_PROCESS_WATCH_HH__
00025 
00026 #include "policy/common/policy_exception.hh"
00027 #include "libxipc/xrl_std_router.hh"
00028 #include "xrl/interfaces/finder_event_notifier_xif.hh"
00029 #include "process_watch_base.hh"
00030 #include "pw_notifier.hh"
00031 #include "protocol_map.hh"
00032 
00033 
00034 
00044 class ProcessWatch : public ProcessWatchBase {
00045 public:
00049     class PWException : public PolicyException {
00050     public:
00051         PWException(const char* file, size_t line, const string& init_why = "")   
00052             : PolicyException("PWException", file, line, init_why) {} 
00053     };
00054 
00059     ProcessWatch(XrlStdRouter& rtr, ProtocolMap& pmap);
00060 
00066     void register_cb(const XrlError& err);
00067 
00073     void add_interest(const string& proc);
00074 
00080     void birth(const string& proto);
00081     
00087     void death(const string& proto);
00088    
00096     bool alive(const string& proto);
00097 
00106     void set_notifier(PWNotifier& notifier);
00107 
00108 private:
00109     ProtocolMap&    _pmap;
00110     set<string>     _watching;
00111     set<string>     _alive;
00112     XrlFinderEventNotifierV0p1Client _finder;
00113     string      _instance_name;
00114 
00115     // do not delete, we do not own
00116     PWNotifier*     _notifier;
00117 
00118     string      _finder_name;
00119 };
00120 
00121 #endif // __POLICY_PROCESS_WATCH_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations