[gecode-users] Gist question

Guido Tack tack at ps.uni-sb.de
Thu May 7 05:23:35 CEST 2009


Malcolm Ryan wrote:

> Is there any way to get Gist to provide a space as a return value to
> my code?

You can use an Inspector to do that.  Here's an example (it's for  
Gecode 3.x, I noticed you were still using 2.x but something similar  
will work there, too):

class ReturnSpaceInspector : public Gist::Inspector {
public:
   Space* s;
   ReturnSpaceInspector(void) : s(NULL) {}
   virtual void inspect(const Space& n) {
     delete s;
     s = n.clone();
   }
   virtual std::string name(void) { return "ReturnSpaceInspector"; }
   ~ReturnSpaceInspector(void) { delete s; }
};

This inspector remembers the space of the last double-clicked node.   
Note that you have to clone it!  After Gist returns, you can then do  
whatever you want with the space.
With the next release, you'll be able to easily add several inspectors  
and turn them on and off individually.  Until then, the  
ReturnSpaceInspector could just inherit from Gist::Print so that you  
get both the output and the space.

Cheers,
	Guido





More information about the gecode-users mailing list