metaSMT 2
metaSMT/tags/SAT.hpp
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <boost/variant.hpp>
00004 #include <boost/mpl/vector.hpp>
00005 
00006 namespace metaSMT {
00007 
00008   namespace SAT {
00009     namespace tag {
00010 
00011     // sat literal tag
00012     // 0 is invalid
00013     // n is variable n
00014     // -m is variable n negated
00015     struct lit_tag { 
00016       int id; 
00017       template<typename STREAM>
00018       friend STREAM & operator<< (STREAM & out, lit_tag const & self)
00019       {  out << "sat_lit[" << self.id  << "]"; return out; }
00020       bool operator< (lit_tag const & other) const { return id < other.id; }
00021       lit_tag operator- () const { lit_tag l = { -id }; return l; }
00022       int var() const {return id >= 0 ? id: -id; }
00023     };
00024 
00025     struct c_tag { 
00026       template<typename STREAM>
00027       friend STREAM & operator<< (STREAM & out, c_tag const & self)
00028       {  out << "or"; return out; }
00029       bool operator< (c_tag const & other) const { return false; }
00030     };
00031 
00032     struct not_tag { 
00033       template<typename STREAM>
00034       friend STREAM & operator<< (STREAM & out, not_tag const & self)
00035       {  out << "not"; return out; }
00036       bool operator< (not_tag const & other) const { return false; }
00037     };
00038 
00039       // tag variant SAT
00040       typedef boost::mpl::vector<
00041           lit_tag
00042         , c_tag
00043       >::type SAT_Tags;
00044 
00045       typedef boost::make_variant_over< SAT_Tags >::type SAT_Tag;
00046 
00047     } // namespace tag
00048   } // namespace SAT
00049 } // namespace metaSMT
00050 
00051 //  vim: ft=cpp:ts=2:sw=2:expandtab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines