xorp

operator.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-2009 XORP, Inc.
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/common/operator.hh,v 1.11 2008/10/02 21:58:07 bms Exp $
00022 
00023 #ifndef __POLICY_COMMON_OPERATOR_HH__
00024 #define __POLICY_COMMON_OPERATOR_HH__
00025 
00026 #include "operator_base.hh"
00027 
00028 #define DEFINE_OPER(name,human,parent) \
00029 class name : public parent { \
00030 public: \
00031     static Hash _hash; \
00032     name() : parent(_hash) {} \
00033     ~name() {} \
00034     string str() const { return #human; } \
00035     Hash hash() const { return _hash; } \
00036     void set_hash(const Hash& x) const { _hash = x; } \
00037 }; 
00038 
00039 #define DEFINE_UNOPER(name,human) \
00040 DEFINE_OPER(name,human,UnOper)
00041 
00042 #define DEFINE_BINOPER(name,human) \
00043 DEFINE_OPER(name,human,BinOper)
00044 
00045 // Logical operators
00046 DEFINE_BINOPER(OpAnd,AND)
00047 DEFINE_BINOPER(OpOr,OR)
00048 DEFINE_BINOPER(OpXor,XOR)
00049 
00050 // Relational operators
00051 DEFINE_BINOPER(OpEq,==)
00052 DEFINE_BINOPER(OpNe,!=)
00053 DEFINE_BINOPER(OpLt,<)
00054 DEFINE_BINOPER(OpGt,>)
00055 DEFINE_BINOPER(OpLe,<=)
00056 DEFINE_BINOPER(OpGe,>=)
00057 
00058 // Math operators
00059 DEFINE_BINOPER(OpAdd,+)
00060 DEFINE_BINOPER(OpSub,-)
00061 DEFINE_BINOPER(OpMul,*)
00062 
00063 // Regular expression operator
00064 DEFINE_BINOPER(OpRegex,REGEX)
00065 
00066 DEFINE_BINOPER(OpCtr,CTR)
00067 
00068 DEFINE_BINOPER(OpNEInt,NON_EMPTY_INTERSECTION)
00069 
00070 // Unary operators
00071 DEFINE_UNOPER(OpNot,NOT)
00072 DEFINE_UNOPER(OpHead,HEAD)
00073 
00074 #endif // __POLICY_COMMON_OPERATOR_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations