projectors-compiler.hh
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Guido Tack <tack@gecode.org> 00004 * 00005 * Copyright: 00006 * Guido Tack, 2006 00007 * 00008 * Last modified: 00009 * $Date: 2006-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $ 00010 * $Revision: 3188 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 #ifndef __GECODE_GENERATOR_PROJECOTRS_COMPILER_HH 00023 #define __GECODE_GENERATOR_PROJECTORS_COMPILER_HH 00024 00025 #include "gecode/set/projectors.hh" 00026 00027 namespace Gecode { 00028 00033 class ProjectorPropagatorSpec { 00034 public: 00036 std::string _name; 00038 std::string _namespace; 00039 00041 int _arity; 00043 bool _reified; 00045 bool _negated; 00046 00047 ProjectorSet _ps; 00048 }; 00049 00054 class ProjectorCompiler { 00055 public: 00057 class Indent { 00058 public: 00060 int i; 00062 Indent(void); 00064 void operator++(void); 00066 void operator--(void); 00067 }; 00068 private: 00070 Indent indent; 00072 std::ostream& hhos; 00074 std::ostream& iccos; 00075 00077 const ProjectorPropagatorSpec& spec; 00078 00080 00081 00082 bool nary(void); 00084 std::string propcost(void); 00086 void allAssigned(std::ostream&); 00088 void viewsarglist(std::ostream&); 00090 void initarglist(std::ostream&); 00092 std::string propcond(PropCond); 00094 void templateparams(void); 00096 void templatehead(std::ostream&); 00098 void header(std::ostream&); 00100 void footer(std::ostream&); 00102 void classdef(void); 00104 void standardMemberFunctions(void); 00106 int iterator(const SetExprCode& instrs, 00107 bool countSize=false, 00108 bool invert=false); 00110 void propagation(void); 00112 00113 public: 00115 enum FixpointType { 00116 NO_FIX, 00117 ITER_FIX, 00118 }; 00120 enum ViewsType { 00121 SINGLE_VIEW, 00122 MULTI_VIEW 00123 }; 00124 00126 00127 00128 bool compiletest; 00130 FixpointType fixpoint; 00132 ViewsType views; 00134 00136 GECODE_SET_EXPORT ProjectorCompiler(std::ostream& hhos, 00137 std::ostream& iccos, 00138 const ProjectorPropagatorSpec& spec); 00140 GECODE_SET_EXPORT void compile(void); 00141 }; 00142 00143 00144 } 00145 00146 #endif 00147 00148 // STATISTICS: set-prop