00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 namespace cpsp {
00022 namespace gecode {
00023
00024 template<class VS>
00025 inline
00026 Gecode::ViewSelStatus
00027 GC_RankViewSel<VS>::init(const SuperSpace* home, const IdxIntView&x)
00028 {
00029 rank = 0;
00030 const GC_ThreadingSpace* ts = dynamic_cast<const GC_ThreadingSpace*>(home);
00031 if (ts != NULL)
00032 rank = ts->getRank(x.getIndex());
00033 Gecode::ViewSelStatus ret = vs.init(home,x);
00034 return (rank == 0 && ret == Gecode::VSS_COMMIT) ? Gecode::VSS_COMMIT : Gecode::VSS_NONE;
00035 }
00036
00037
00038 template<class VS>
00039 inline
00040 Gecode::ViewSelStatus
00041 GC_RankViewSel<VS>::select(const SuperSpace* home, IdxIntView x) {
00042 if (rank > 0) {
00043 const GC_ThreadingSpace* ts = dynamic_cast<const GC_ThreadingSpace*>(home);
00044 unsigned int act = INT_MAX;
00045 if (ts != NULL) {
00046
00047 act = ts->getRank(x.getIndex());
00048 }
00049 if ( act < rank ) {
00050 rank = act;
00051 if (rank == 0) {
00052 Gecode::ViewSelStatus ret = vs.select(home,x);
00053 return (ret == Gecode::VSS_COMMIT) ? ret : Gecode::VSS_SELECT;
00054 } else {
00055 return Gecode::VSS_SELECT;
00056 }
00057 } else if ( act == rank ) {
00058 Gecode::ViewSelStatus ret = vs.select(home,x);
00059 return (ret != Gecode::VSS_NONE) ? Gecode::VSS_SELECT : Gecode::VSS_NONE;
00060 }
00061 } else {
00062 return vs.select(home,x);
00063 }
00064 return Gecode::VSS_NONE;
00065 }
00066
00067 }
00068 }
00069