00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 namespace Gecode {
00035
00037 class TracerBase : public HeapAllocated {
00038 protected:
00040 GECODE_KERNEL_EXPORT
00041 static Support::Mutex m;
00042 };
00043
00044 template<class View> class ViewTraceRecorder;
00045
00050 template<class View>
00051 class ViewTracer : public TracerBase {
00052 template<class ViewForTraceRecorder> friend class ViewTraceRecorder;
00053 private:
00060 void _init(const Space& home, const ViewTraceRecorder<View>& t);
00067 void _prune(const Space& home, const ViewTraceRecorder<View>& t,
00068 const ViewTraceInfo& vti,
00069 int i, typename TraceTraits<View>::TraceDelta& d);
00076 void _fail(const Space& home, const ViewTraceRecorder<View>& t);
00082 void _fix(const Space& home, const ViewTraceRecorder<View>& t);
00088 void _done(const Space& home, const ViewTraceRecorder<View>& t);
00089 public:
00091 ViewTracer(void);
00098 virtual void init(const Space& home,
00099 const ViewTraceRecorder<View>& t) = 0;
00109 virtual void prune(const Space& home,
00110 const ViewTraceRecorder<View>& t,
00111 const ViewTraceInfo& vti,
00112 int i, typename TraceTraits<View>::TraceDelta& d) = 0;
00119 virtual void fail(const Space& home,
00120 const ViewTraceRecorder<View>& t) = 0;
00128 virtual void fix(const Space& home,
00129 const ViewTraceRecorder<View>& t) = 0;
00136 virtual void done(const Space& home,
00137 const ViewTraceRecorder<View>& t) = 0;
00139 virtual ~ViewTracer(void);
00140 };
00141
00142
00143
00144
00149 class Tracer : public TracerBase {
00150 friend class Space;
00151 friend class PostInfo;
00152 private:
00159 void _propagate(const Space& home, const PropagateTraceInfo& pti);
00166 void _commit(const Space& home, const CommitTraceInfo& cti);
00173 void _post(const Space& home, const PostTraceInfo& pti);
00174 public:
00176 Tracer(void);
00183 virtual void propagate(const Space& home,
00184 const PropagateTraceInfo& pti) = 0;
00191 virtual void commit(const Space& home,
00192 const CommitTraceInfo& cti) = 0;
00199 virtual void post(const Space& home,
00200 const PostTraceInfo& pti) = 0;
00202 virtual ~Tracer(void);
00203 };
00204
00205
00210 class GECODE_KERNEL_EXPORT StdTracer : public Tracer {
00211 protected:
00213 std::ostream& os;
00214 public:
00216 StdTracer(std::ostream& os = std::cerr);
00223 virtual void propagate(const Space& home,
00224 const PropagateTraceInfo& pti);
00231 virtual void commit(const Space& home,
00232 const CommitTraceInfo& cti);
00239 virtual void post(const Space& home,
00240 const PostTraceInfo& pti);
00242 static StdTracer def;
00243 };
00244
00245
00246
00247
00248
00249
00250 template<class View>
00251 forceinline
00252 ViewTracer<View>::ViewTracer(void) {
00253 }
00254
00255 template<class View>
00256 forceinline void
00257 ViewTracer<View>::_init(const Space& home,
00258 const ViewTraceRecorder<View>& t) {
00259 Support::Lock l(m);
00260 init(home,t);
00261 }
00262 template<class View>
00263 forceinline void
00264 ViewTracer<View>::_prune(const Space& home,
00265 const ViewTraceRecorder<View>& t,
00266 const ViewTraceInfo& vti,
00267 int i, typename TraceTraits<View>::TraceDelta& d) {
00268 Support::Lock l(m);
00269 prune(home,t,vti,i,d);
00270 }
00271 template<class View>
00272 forceinline void
00273 ViewTracer<View>::_fail(const Space& home,
00274 const ViewTraceRecorder<View>& t) {
00275 Support::Lock l(m);
00276 fail(home,t);
00277 }
00278 template<class View>
00279 forceinline void
00280 ViewTracer<View>::_fix(const Space& home,
00281 const ViewTraceRecorder<View>& t) {
00282 Support::Lock l(m);
00283 fix(home,t);
00284 }
00285 template<class View>
00286 forceinline void
00287 ViewTracer<View>::_done(const Space& home,
00288 const ViewTraceRecorder<View>& t) {
00289 Support::Lock l(m);
00290 done(home,t);
00291 }
00292
00293 template<class View>
00294 forceinline
00295 ViewTracer<View>::~ViewTracer(void) {
00296 }
00297
00298
00299
00300
00301
00302
00303 forceinline
00304 Tracer::Tracer(void) {
00305 }
00306
00307 forceinline void
00308 Tracer::_propagate(const Space& home,
00309 const PropagateTraceInfo& pti) {
00310 Support::Lock l(m);
00311 propagate(home,pti);
00312 }
00313 forceinline void
00314 Tracer::_commit(const Space& home,
00315 const CommitTraceInfo& cti) {
00316 Support::Lock l(m);
00317 commit(home,cti);
00318 }
00319 forceinline void
00320 Tracer::_post(const Space& home,
00321 const PostTraceInfo& pti) {
00322 Support::Lock l(m);
00323 post(home,pti);
00324 }
00325
00326 forceinline
00327 Tracer::~Tracer(void) {
00328 }
00329
00330 }
00331
00332