OKlibrary  0.2.1.6
AtomicConditions.hpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 5.12.2006 (Swansea)
00002 /* Copyright 2006 - 2007 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 ATOMICCONDITIONS_303045439jhg
00014 #define ATOMICCONDITIONS_303045439jhg
00015 
00016 #include <OKlib/Concepts/LibraryBasics.hpp>
00017 
00018 #include <OKlib/Satisfiability/ProblemInstances/Conditions/AtomicConditions/traits/value_type.hpp>
00019 #include <OKlib/Satisfiability/ProblemInstances/Conditions/AtomicConditions/eval.hpp>
00020 #include <OKlib/Satisfiability/ProblemInstances/Conditions/AtomicConditions/complement.hpp>
00021 
00022 namespace OKlib {
00023   namespace Concepts {
00024 
00025         struct AtomicCondition_tag : virtual BasicRequirements_tag, virtual FullyConstructible_tag,  virtual EqualitySubstitutable_tag, virtual LinearOrder_tag {};
00026 
00043     template <typename AC>
00044     struct AtomicCondition {
00045 
00046       typedef typename OKlib::AtomicConditions::traits::value_type<AC>::type value_type;
00047 
00048       void constraints() {
00049         OKLIB_MODELS_CONCEPT_TAG(AC, AtomicCondition);
00050 
00051         OKLIB_MODELS_CONCEPT_REQUIRES(AC, BasicRequirements);
00052         OKLIB_MODELS_CONCEPT_TAG(AC, BasicRequirements);
00053         OKLIB_MODELS_CONCEPT_REQUIRES(AC, FullyConstructible);
00054         OKLIB_MODELS_CONCEPT_TAG(AC, FullyConstructible);
00055         OKLIB_MODELS_CONCEPT_REQUIRES(AC, EqualitySubstitutable);
00056         OKLIB_MODELS_CONCEPT_TAG(AC, EqualitySubstitutable);
00057         OKLIB_MODELS_CONCEPT_REQUIRES(AC, LinearOrder);
00058         OKLIB_MODELS_CONCEPT_TAG(AC, LinearOrder);
00059 
00060         OKLIB_MODELS_CONCEPT_REQUIRES(value_type, FullyConstructible);
00061         OKLIB_MODELS_CONCEPT_REQUIRES(value_type, EqualitySubstitutable);
00062         OKLIB_MODELS_CONCEPT_REQUIRES(value_type, LinearOrder);
00063 
00064         static_cast<bool>(OKlib::AtomicConditions::eval(cc, v));
00065         static_cast<bool>(OKlib::AtomicConditions::eval(c, v));
00066 
00067         OKlib::AtomicConditions::complement(c);
00068 
00069         dummy_use(AC(v));
00070       }
00071 
00072       AC c;
00073       const AC cc;
00074       const value_type v;
00075       void dummy_use(const AC& ac) {}
00076     };
00077 
00078     class AtomicCondition_Archetype {
00079       typedef OKlib::Concepts::convertible_to_bool convertible_to_bool;
00080     public :
00081       typedef AtomicCondition_tag concept_tag;
00082       convertible_to_bool operator ==(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00083       convertible_to_bool operator !=(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00084       convertible_to_bool operator <(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00085       convertible_to_bool operator >(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00086       convertible_to_bool operator <=(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00087       convertible_to_bool operator >=(const AtomicCondition_Archetype&) const { return convertible_to_bool(); }
00088 
00089       struct value_type {};
00090       friend convertible_to_bool operator ==(const value_type&, const value_type&) { return convertible_to_bool(); }
00091       friend convertible_to_bool operator !=(const value_type&, const value_type&) { return convertible_to_bool(); }
00092       friend convertible_to_bool operator <(const value_type&, const value_type&) { return convertible_to_bool(); }
00093       friend convertible_to_bool operator >(const value_type&, const value_type&) { return convertible_to_bool(); }
00094       friend convertible_to_bool operator <=(const value_type&, const value_type&) { return convertible_to_bool(); }
00095       friend convertible_to_bool operator >=(const value_type&, const value_type&) { return convertible_to_bool(); }
00096 
00097       AtomicCondition_Archetype() {}
00098       explicit AtomicCondition_Archetype(const value_type) {}
00099     };
00100   }
00101   namespace AtomicConditions {
00102     template <>
00103     inline bool eval(const OKlib::Concepts::AtomicCondition_Archetype&, const OKlib::AtomicConditions::traits::value_type<OKlib::Concepts::AtomicCondition_Archetype>::type&) {
00104       return ::OKlib::Concepts::convertible_to_bool();
00105     }
00106     template <>
00107     inline void complement(OKlib::Concepts::AtomicCondition_Archetype&) {}
00108     
00109   }
00110 
00111 }
00112 
00113 #endif
00114