xorp

instruction.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/backend/instruction.hh,v 1.14 2008/10/02 21:58:03 bms Exp $
00022 
00023 #ifndef __POLICY_BACKEND_INSTRUCTION_HH__
00024 #define __POLICY_BACKEND_INSTRUCTION_HH__
00025 
00026 #include "libxorp/xorp.h"
00027 
00028 #ifdef HAVE_REGEX_H
00029 #  include <regex.h>
00030 #else // ! HAVE_REGEX_H
00031 #  ifdef HAVE_PCRE_H
00032 #    include <pcre.h>
00033 #  endif
00034 #  ifdef HAVE_PCREPOSIX_H
00035 #    include <pcreposix.h>
00036 #  endif
00037 #endif // ! HAVE_REGEX_H
00038 
00039 #include "policy/common/element_base.hh"
00040 #include "policy/common/operator_base.hh"
00041 #include "policy/common/policy_exception.hh"
00042 #include "policy/common/varrw.hh"
00043 
00044 #include "instr_visitor.hh"
00045 #include "instruction_base.hh"
00046 
00047 
00053 class Push :
00054     public NONCOPYABLE,
00055     public Instruction
00056 {
00057 public:
00064     Push(Element* e) : _elem(e) {}
00065     ~Push() { delete _elem; }
00066 
00067     // semicolon for kdoc
00068     INSTR_VISITABLE();
00069 
00073     const Element& elem() const { return *_elem; }
00074 
00075 private:
00076     Element* _elem;
00077 };
00078 
00089 class PushSet : public Instruction {
00090 public:
00094     PushSet(const string& setid) : _setid(setid) {}
00095 
00096     INSTR_VISITABLE();
00097 
00101     const string& setid() const { return _setid; }
00102 
00103 private:
00104     string _setid;
00105 };
00106 
00114 class OnFalseExit : public Instruction {
00115 public:
00116     
00117     INSTR_VISITABLE();
00118 };
00119 
00123 class Load : public Instruction {
00124 public:
00125 
00129     Load(const VarRW::Id& var) : _var(var) {}
00130 
00131     INSTR_VISITABLE();
00132     
00136     const VarRW::Id& var() const { return _var; }
00137 
00138 private:
00139     VarRW::Id _var;
00140 };
00141 
00148 class Store : public Instruction {
00149 public:
00153     Store(const VarRW::Id& var) : _var(var) {}
00154 
00155     INSTR_VISITABLE();
00156 
00160     const VarRW::Id& var() const { return _var; }
00161 
00162 private:
00163     VarRW::Id _var;
00164 };
00165 
00169 class Accept : public Instruction  {
00170 public:
00171     INSTR_VISITABLE();
00172 };
00173 
00177 class Reject : public Instruction  {
00178 public:
00179     INSTR_VISITABLE();
00180 };
00181 
00182 class Next : public Instruction {
00183 public:
00184     enum Flow {
00185     TERM,
00186     POLICY
00187     };
00188 
00189     Next(Flow f) : _flow(f) {}
00190 
00191     Flow flow() { return _flow; }
00192 
00193     INSTR_VISITABLE();
00194 
00195 private:
00196     Flow    _flow;
00197 };
00198 
00199 class Subr : public Instruction {
00200 public:
00201     Subr(string target) : _target(target) {}
00202 
00203     string target() { return _target; }
00204 
00205     INSTR_VISITABLE();
00206 
00207 private:
00208     string  _target;
00209 };
00210 
00220 class NaryInstr :
00221     public NONCOPYABLE,
00222     public Instruction
00223 {
00224 public:
00230     NaryInstr(Oper* op) : _op(op) {}
00231     ~NaryInstr() { delete _op; }
00232 
00233     INSTR_VISITABLE();
00234 
00235 
00239     const Oper& op() const { return *_op; }
00240 
00241 private:
00242     Oper* _op;
00243 };
00244 
00245 #endif // __POLICY_BACKEND_INSTRUCTION_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations