GraphCommon.hpp

Go to the documentation of this file.
00001 #ifndef wali_graph_GRAPH_COMMON_H_
00002 #define wali_graph_GRAPH_COMMON_H_
00003 
00004 #include "wali/Common.hpp"
00005 #include "wali/wfa/ITrans.hpp"
00006 
00007 namespace wali {
00008 
00009     namespace graph {
00010 
00011 
00012         struct Transition {
00013             Key src, tgt, stack;
00014             Transition() : src(0), tgt(0), stack(0) {}
00015             Transition(Key s, Key st, Key t) : src(s), tgt(t), stack(st) {}
00016             Transition(const Transition &t) : src(t.src), tgt(t.tgt), stack(t.stack) {}
00017             Transition(const wali::wfa::ITrans& t ) : src(t.from()), tgt(t.to()), stack(t.stack()) {}
00018             bool operator == (const Transition &t) {
00019                 return (src == t.src && tgt == t.tgt && stack == t.stack);
00020             }    
00021         };
00022 
00023         struct TransitionCmp {
00024             bool operator() (const Transition &t1, const Transition &t2) const { // some total order on Transitions
00025                 return ((t1.stack < t2.stack) ? true :
00026                         (t1.stack > t2.stack) ? false :
00027                         (t1.tgt < t2.tgt) ? true :
00028                         (t1.tgt > t2.tgt) ? false :
00029                         (t1.src < t2.src) ? true :
00030                         false);
00031             }
00032         };
00033 
00034         struct TransitionEq {
00035             bool operator() (const Transition &t1, const Transition &t2) const { // equality
00036                 return (t1.stack == t2.stack && t1.src == t2.src && t1.tgt == t2.tgt);
00037             }
00038         };
00039 
00040         struct TransitionHash {
00041             size_t operator() (const Transition &t) const {
00042                 return (997*t.stack + 131*t.tgt + t.src);
00043             }
00044         };
00045 
00046         typedef std::pair<Transition, wali::sem_elem_t> WTransition;
00047 
00048 
00049     } // namespace graph
00050 
00051 } // namespace wali
00052 
00053 #ifdef _WIN32
00054 #define WIN(stmt) do { if(1) { stmt; } }while(0)
00055 #else
00056 #define WIN(stmt) 
00057 #endif
00058 
00059 #ifdef DEBUG
00060 #define FWPDSDBGS(stmt) do { if(1) { stmt; } }while(0)
00061 #else
00062 #define FWPDSDBGS(stmt)
00063 #endif
00064 
00065 #ifdef FWPDS_INCREMENTAL
00066 #define INCREMENTAL(stmt) do { if(1) { stmt; } }while(0)
00067 #else
00068 #define INCREMENTAL(stmt)
00069 #endif
00070 
00071 #ifdef FWPDS_STATS 
00072 #define STAT(stmt) do { if(1) { stmt; } }while(0)
00073 #else
00074 #define STAT(stmt)
00075 #endif
00076 
00077 #endif // wali_graph_GRAPH_COMMON_H_