projectors-compiler.hh
Go to the documentation of this file.00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Guido Tack <tack@gecode.org> 00005 * 00006 * Copyright: 00007 * Guido Tack, 2006 00008 * 00009 * Last modified: 00010 * $Date: 2007-08-09 15:30:21 +0200 (Thu, 09 Aug 2007) $ by $Author: tack $ 00011 * $Revision: 4790 $ 00012 * 00013 * This file is part of Gecode, the generic constraint 00014 * development environment: 00015 * http://www.gecode.org 00016 * 00017 * Permission is hereby granted, free of charge, to any person obtaining 00018 * a copy of this software and associated documentation files (the 00019 * "Software"), to deal in the Software without restriction, including 00020 * without limitation the rights to use, copy, modify, merge, publish, 00021 * distribute, sublicense, and/or sell copies of the Software, and to 00022 * permit persons to whom the Software is furnished to do so, subject to 00023 * the following conditions: 00024 * 00025 * The above copyright notice and this permission notice shall be 00026 * included in all copies or substantial portions of the Software. 00027 * 00028 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00029 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00030 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00031 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00032 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00033 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00034 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00035 * 00036 */ 00037 00038 #ifndef __GECODE_GENERATOR_PROJECOTRS_COMPILER_HH 00039 #define __GECODE_GENERATOR_PROJECTORS_COMPILER_HH 00040 00041 #include "gecode/set/projectors.hh" 00042 00043 namespace Gecode { 00044 00049 class ProjectorPropagatorSpec { 00050 public: 00052 std::string _name; 00054 std::string _namespace; 00055 00057 int _arity; 00059 bool _reified; 00061 bool _negated; 00062 00063 ProjectorSet _ps; 00064 }; 00065 00070 class ProjectorCompiler { 00071 public: 00073 class Indent { 00074 public: 00076 int i; 00078 Indent(void); 00080 void operator++(void); 00082 void operator--(void); 00083 }; 00084 private: 00086 Indent indent; 00088 std::ostream& hhos; 00090 std::ostream& iccos; 00091 00093 const ProjectorPropagatorSpec& spec; 00094 00096 00097 00098 bool nary(void); 00100 std::string propcost(void); 00102 void allAssigned(std::ostream&); 00104 void viewsarglist(std::ostream&); 00106 void initarglist(std::ostream&); 00108 std::string propcond(PropCond); 00110 void templateparams(void); 00112 void templatehead(std::ostream&); 00114 void header(std::ostream&); 00116 void footer(std::ostream&); 00118 void classdef(void); 00120 void standardMemberFunctions(void); 00122 int iterator(const SetExprCode& instrs, 00123 bool countSize=false, 00124 bool invert=false); 00126 void propagation(void); 00128 00129 public: 00131 enum FixpointType { 00132 NO_FIX, 00133 ITER_FIX, 00134 }; 00136 enum ViewsType { 00137 SINGLE_VIEW, 00138 MULTI_VIEW 00139 }; 00140 00142 00143 00144 bool compiletest; 00146 FixpointType fixpoint; 00148 ViewsType views; 00150 00152 GECODE_SET_EXPORT ProjectorCompiler(std::ostream& hhos, 00153 std::ostream& iccos, 00154 const ProjectorPropagatorSpec& spec); 00156 GECODE_SET_EXPORT void compile(void); 00157 }; 00158 00159 00160 } 00161 00162 #endif 00163 00164 // STATISTICS: set-prop