xorp

xrldb.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2012 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 // $XORP: xorp/rtrmgr/xrldb.hh,v 1.14 2008/10/02 21:58:27 bms Exp $
00021 
00022 #ifndef __RTRMGR_XRLDB_HH__
00023 #define __RTRMGR_XRLDB_HH__
00024 
00025 
00026 
00027 
00028 #include "libxipc/xrl_router.hh"
00029 
00030 #include "rtrmgr_error.hh"
00031 
00032 
00033 enum XRLMatchType {
00034     MATCH_FAIL  = 0x0,
00035     MATCH_XRL   = 0x1,
00036     MATCH_RSPEC = 0x2,
00037     MATCH_ALL   = MATCH_XRL | MATCH_RSPEC
00038 };
00039 
00040 class XrlSpec {
00041 public:
00042     XrlSpec(const Xrl& xrl, const XrlArgs& rspec, bool verbose);
00043     XRLMatchType matches(const Xrl& xrl, const XrlArgs& rspec) const;
00044     string str() const;
00045 
00046 private:
00047     Xrl     _xrl;       // The XRL itself
00048     XrlArgs _rspec;     // The return spec
00049     bool    _verbose;   // Set to true if output is verbose
00050 };
00051 
00052 class XRLtarget {
00053 public:
00054     XRLtarget(const string& xrlfilename, bool verbose);
00055 
00056     XRLMatchType xrl_matches(const Xrl& test_xrl, const XrlArgs& rspec) const;
00057     string str() const;
00058 
00059 private:
00060     string  _targetname;
00061     list<XrlSpec> _xrlspecs;
00062     bool    _verbose;   // Set to true if output is verbose
00063 };
00064 
00065 class XRLdb {
00066 public:
00067     XRLdb(const string& xrldir, bool verbose) throw (InitError);
00068 #ifdef DEBUG_XRLDB
00069     bool check_xrl_syntax(const string& xrl) const;
00070     XRLMatchType check_xrl_exists(const string& xrl) const;
00071 #endif
00072     string str() const;
00073 
00074 private:
00075     list<XRLtarget> _targets;
00076     bool    _verbose;   // Set to true if output is verbose
00077 };
00078 
00079 #endif // __RTRMGR_XRLDB_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations