OKlibrary  0.2.1.6
Literals.hpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 25.11.2006 (Swansea)
00002 /* Copyright 2006 - 2007, 2009 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00013 #ifndef LITERALS_JJhala7t4
00014 #define LITERALS_JJhala7t4
00015 
00016 #include <OKlib/Concepts/LibraryBasics.hpp>
00017 
00018 #include <OKlib/Concepts/Variables.hpp>
00019 #include <OKlib/Concepts/AtomicConditions.hpp>
00020 
00021 #include <OKlib/Satisfiability/ProblemInstances/Literals/traits/var_type.hpp>
00022 #include <OKlib/Satisfiability/ProblemInstances/Literals/traits/cond_type.hpp>
00023 #include <OKlib/Satisfiability/ProblemInstances/Literals/var.hpp>
00024 #include <OKlib/Satisfiability/ProblemInstances/Literals/cond.hpp>
00025 #include <OKlib/Satisfiability/ProblemInstances/Literals/set_cond.hpp>
00026 
00027 namespace OKlib {
00028   namespace Concepts {
00029 
00030     struct Literals_tag : virtual BasicRequirements_tag, virtual FullyConstructible_tag,  virtual EqualitySubstitutable_tag, virtual LinearOrder_tag {};
00031 
00060     template <typename Lit>
00061     struct Literals {
00062 
00063       typedef typename OKlib::Literals::traits::var_type<Lit>::type var_type;
00064       typedef typename OKlib::Literals::traits::cond_type<Lit>::type cond_type;
00065 
00066       void constraints() {
00067         OKLIB_MODELS_CONCEPT_TAG(Lit, Literals);
00068 
00069         OKLIB_MODELS_CONCEPT_REQUIRES(Lit, BasicRequirements);
00070         OKLIB_MODELS_CONCEPT_TAG(Lit, BasicRequirements);
00071         OKLIB_MODELS_CONCEPT_REQUIRES(Lit, FullyConstructible);
00072         OKLIB_MODELS_CONCEPT_TAG(Lit, FullyConstructible);
00073         OKLIB_MODELS_CONCEPT_REQUIRES(Lit, EqualitySubstitutable);
00074         OKLIB_MODELS_CONCEPT_TAG(Lit, EqualitySubstitutable);
00075         OKLIB_MODELS_CONCEPT_REQUIRES(Lit, LinearOrder);
00076         OKLIB_MODELS_CONCEPT_TAG(Lit, LinearOrder);
00077 
00078         OKLIB_MODELS_CONCEPT_REQUIRES(var_type, Concepts::Variables);
00079         OKLIB_MODELS_CONCEPT_TAG(var_type, Concepts::Variables);
00080         OKLIB_MODELS_CONCEPT_REQUIRES(cond_type, Concepts::AtomicCondition);
00081         OKLIB_MODELS_CONCEPT_TAG(cond_type, Concepts::AtomicCondition);
00082         
00083         static_cast<var_type>(OKlib::Literals::var(lc));
00084         static_cast<var_type>(OKlib::Literals::var(l));
00085 
00086         static_cast<cond_type>(OKlib::Literals::cond(lc));
00087 
00088         OKlib::Literals::set_cond(l, c);
00089 
00090         dummy_use(Lit(v));
00091       }
00092 
00093       Lit l;
00094       const Lit lc;
00095       const var_type v;
00096       const cond_type c;
00097       void dummy_use(const Lit& l) {}
00098     };
00099 
00100     class Literals_Archetype {
00101       typedef OKlib::Concepts::convertible_to_bool convertible_to_bool;
00102     public :
00103       typedef Literals_tag concept_tag;
00104       typedef OKlib::Concepts::Variables_Archetype var_type;
00105       typedef OKlib::Concepts::AtomicCondition_Archetype cond_type;
00106       Literals_Archetype() {}
00107       Literals_Archetype(var_type) {}
00108       convertible_to_bool operator ==(const Literals_Archetype&) const { return convertible_to_bool(); }
00109       convertible_to_bool operator !=(const Literals_Archetype&) const { return convertible_to_bool(); }
00110       convertible_to_bool operator <(const Literals_Archetype&) const { return convertible_to_bool(); }
00111       convertible_to_bool operator >(const Literals_Archetype&) const { return convertible_to_bool(); }
00112       convertible_to_bool operator <=(const Literals_Archetype&) const { return convertible_to_bool(); }
00113       convertible_to_bool operator >=(const Literals_Archetype&) const { return convertible_to_bool(); }
00114 
00115     };
00116   }
00117   namespace Literals {
00118     template <>
00119     inline OKlib::Concepts::Literals_Archetype::var_type var(const OKlib::Concepts::Literals_Archetype&) { return OKlib::Concepts::Literals_Archetype::var_type(); }
00120     template <>
00121     inline OKlib::Concepts::Literals_Archetype::cond_type cond(const OKlib::Concepts::Literals_Archetype&) { return OKlib::Concepts::Literals_Archetype::cond_type(); }
00122     template <>
00123     inline void set_cond(OKlib::Concepts::Literals_Archetype&, const OKlib::Concepts::Literals_Archetype::cond_type&) {}
00124   }
00125   
00126 }
00127 
00128 
00129 #endif