00001 #ifndef wali_WITNESS_EXTEND_GUARD 00002 #define wali_WITNESS_EXTEND_GUARD 1 00003 00004 /*! 00005 * @author Nicholas Kidd 00006 */ 00007 00008 #include "wali/Common.hpp" 00009 #include "wali/witness/Witness.hpp" 00010 00011 namespace wali 00012 { 00013 namespace witness 00014 { 00015 /*! 00016 * @class WitnessExtend 00017 * 00018 * Class WitnessExtend bears witness to the fact that a new weight 00019 * (sem_elem_t) was created by extending 0, 1, or 2 weights. In the normal 00020 * case it will be extend of two weights. It really does not make sense 00021 * for there to be an extend of 0 weights. 00022 * 00023 * @see Witness 00024 * @see sem_elem_t 00025 */ 00026 class WitnessExtend : public Witness 00027 { 00028 public: 00029 /*! 00030 * Constructor creates WitnessExtend with no children. 00031 * How does this happen? 00032 */ 00033 WitnessExtend( sem_elem_t weight ); 00034 00035 /*! 00036 * Constructor creates WitnessExtend with only a left child. 00037 * Parameter weight should equal left 00038 */ 00039 WitnessExtend( sem_elem_t weight, witness_t left ); 00040 00041 /*! 00042 * Constructor creates WitnessExtend with a left & right child. 00043 * Parameter weight should equal left.extend(right) 00044 */ 00045 WitnessExtend( sem_elem_t weight, witness_t left, witness_t right ); 00046 00047 //! Destructor does nothing. 00048 virtual ~WitnessExtend(); 00049 00050 //! Override Witness::accept 00051 virtual void accept( Visitor& v, bool visitOnce=false ); 00052 00053 //! Override Witness::reset_marks 00054 virtual void reset_marks() const; 00055 00056 //! Override Witness::pretty_print 00057 virtual std::ostream& prettyPrint( std::ostream& o, size_t depth ) const; 00058 00059 //! @return witness_t that is the left child 00060 witness_t left() { return lchild; } 00061 00062 //! @return true if the left child is valid 00063 bool hasLeft() const { return !lchild.is_empty(); } 00064 00065 //! @return witness_t that is the right child 00066 witness_t right() { return rchild; } 00067 00068 //! @return true if the right child is valid 00069 bool hasRight() const { return !rchild.is_empty(); } 00070 00071 protected: 00072 witness_t lchild; //! < left parameter of binary extend 00073 witness_t rchild; //! < right parameter of binary extend 00074 00075 }; // class WitnessExtend 00076 00077 } // namespace witness 00078 00079 } // namespace wali 00080 00081 #endif // wali_WITNESS_EXTEND_GUARD 00082