this repo has no description
1/*****************************************************************[myspace.hh] 2 Copyright (c) 2007, Universite d'Orleans - Jeremie Vautard, Marco Benedetti, 3 Arnaud Lallouet. 4 5 Permission is hereby granted, free of charge, to any person obtaining a copy 6 of this software and associated documentation files (the "Software"), to deal 7 in the Software without restriction, including without limitation the rights 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 copies of the Software, and to permit persons to whom the Software is 10 furnished to do so, subject to the following conditions: 11 12 The above copyright notice and this permission notice shall be included in 13 all copies or substantial portions of the Software. 14 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 THE SOFTWARE. 22 *****************************************************************************/ 23#ifndef __QECODE_MYSPACE__ 24#define __QECODE_MYSPACE__ 25 26#include "qecode.hh" 27#include <vector> 28#include "gecode/minimodel.hh" 29#include "vartype.hh" 30 31using namespace Gecode; 32using namespace Gecode::Int; 33 34/** \brief A simple extension of Gecode::Space class 35 * 36 * A simple extension of the Space class from Gecode, in order to have access to the variables it contains. 37 */ 38 39class QECODE_VTABLE_EXPORT MySpace : public Space { 40 41 protected : 42 unsigned int n; 43 44public: 45 /** \brief This array contains all the variables this space contains. 46 */ 47 void** v; 48 49 /** \brief This array indicates the type of each variable 50 */ 51 VarType* type_of_v; 52 53 /** \brief Constructor of a space with a fixed number of variables 54 * 55 * Builds a space which will contain nv variables (the variables themselves are however not declared). 56 * @param nv the number of variable the space must contain. 57 */ 58 QECODE_EXPORT MySpace(unsigned int nv); 59 QECODE_EXPORT int nbVars() {return n;} 60 QECODE_EXPORT MySpace(bool share,MySpace& ms); 61 QECODE_EXPORT virtual MySpace* copy(bool share); 62 QECODE_EXPORT virtual ~MySpace(); 63 QECODE_EXPORT int getValue(unsigned int i); ///< returns the value of variable i. If boolean : 0 or 1 (false / true). 64 65 /** \brief Returns the integer variables before idMax 66 * 67 * Returns an IntVarArgs containing all the integer variables of index inferior than parameter idMax 68 */ 69 QECODE_EXPORT IntVarArgs getIntVars(unsigned int idMax); 70 71 /** \brief Returns the boolean variables before idMax 72 * 73 * Returns a BoolVarArgs containing all the boolean variables of index inferior than parameter idMax 74 */ 75 QECODE_EXPORT BoolVarArgs getBoolVars(unsigned int idMax); 76 77}; 78 79#endif