LAMA
/home/brandes/workspace/LAMA/src/lama/solver/criteria/Criterion.hpp
Go to the documentation of this file.
00001 
00034 #ifndef LAMA_BOOLEANCONDITION_HPP_
00035 #define LAMA_BOOLEANCONDITION_HPP_
00036 
00037 // for dll_import
00038 #include <lama/config.hpp>
00039 
00040 // base classes
00041 #include <lama/Printable.hpp>
00042 
00043 // others
00044 #include <lama/LAMATypes.hpp>
00045 
00046 // logging
00047 #include <logging/logging.hpp>
00048 
00049 // boost
00050 #include <boost/shared_ptr.hpp>
00051 
00052 #include <ostream>
00053 
00054 namespace lama
00055 {
00056 
00057 class IterativeSolver;
00058 
00059 class Criterion;
00060 
00061 typedef boost::shared_ptr<Criterion> CriterionPtr;
00062 
00069 class LAMA_DLL_IMPORTEXPORT Criterion : public Printable
00070 {
00071 public:
00072 
00076     enum BooleanOperator
00077     {
00078          AND,       
00079          OR         
00080     };
00081 
00085     Criterion();
00086 
00092     Criterion( const bool boolean );
00093 
00099     Criterion( const Criterion& other );
00100 
00115     Criterion( const CriterionPtr other, const bool modifier );
00116 
00126     Criterion(
00127         const CriterionPtr leftChild,
00128         const CriterionPtr rightChild,
00129         BooleanOperator operation );
00130 
00134     virtual ~Criterion();
00135 
00143     virtual bool isSatisfied( const IterativeSolver& solver );
00144 
00145     const CriterionPtr getLeftChild() const;
00146 
00147     const CriterionPtr getRightChild() const;
00148 
00149     BooleanOperator getOperation() const;
00150 
00151     void setLeftChild( const CriterionPtr leftChild);
00152 
00153     void setRightChild( const CriterionPtr rightChild);
00154 
00155     void setOperation( const BooleanOperator operation );
00156 
00163     bool hasLeftChild() const;
00164 
00171     bool hasRightChild() const;
00172 
00173     Criterion& operator =( const Criterion& other );
00174 
00175     virtual void writeAt(std::ostream& stream) const;
00176 
00177 protected:
00178 
00179     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00180 
00181 private:
00182     CriterionPtr mLeftChild;
00183     CriterionPtr mRightChild;
00184     BooleanOperator     mOperation;
00185     const bool          mModifier; // true: negate, false: do nothing
00186 };
00187 
00188 inline CriterionPtr operator||( CriterionPtr a, CriterionPtr b )
00189 {
00190      return CriterionPtr( new Criterion( a, b, Criterion::OR ) );
00191 }
00192 
00193 inline CriterionPtr operator&&( CriterionPtr a, CriterionPtr b )
00194 {
00195      return CriterionPtr( new Criterion( a, b, Criterion::AND ) );
00196 }
00197 
00198 } // namespace lama
00199 
00200 #endif // LAMA_BOOLEANCONDITION_HPP_