brancher-val-commit.hpp /usr/include/gecode/kernel.hh Gecode::ValCommit Gecode::ValCommitFunction Gecode /*-*-mode:C++;c-basic-offset:2;indent-tabs-mode:nil-*-*/ /* *Mainauthor: *ChristianSchulte<schulte@gecode.org> * *Copyright: *ChristianSchulte,2012 * *Lastmodified: *$Date:2013-07-0417:03:13+0200(Thu,04Jul2013)$by$Author:schulte$ *$Revision:13801$ * *ThisfileispartofGecode,thegenericconstraint *developmentenvironment: *http://www.gecode.org * *Permissionisherebygranted,freeofcharge,toanypersonobtaining *acopyofthissoftwareandassociateddocumentationfiles(the *"Software"),todealintheSoftwarewithoutrestriction,including *withoutlimitationtherightstouse,copy,modify,merge,publish, *distribute,sublicense,and/orsellcopiesoftheSoftware,andto *permitpersonstowhomtheSoftwareisfurnishedtodoso,subjectto *thefollowingconditions: * *Theabovecopyrightnoticeandthispermissionnoticeshallbe *includedinallcopiesorsubstantialportionsoftheSoftware. * *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND, *EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOF *MERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEAND *NONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBE *LIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTION *OFCONTRACT,TORTOROTHERWISE,ARISINGFROM,OUTOFORINCONNECTION *WITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE. * */ namespaceGecode{ template<class_View,class_Val> classValCommit{ public: typedef_ViewView; typedef_ValVal; public: ValCommit(Space&home,constValBranch&vb); ValCommit(Space&home,boolshared,ValCommit<View,Val>&vs); boolnotice(void)const; voiddispose(Space&home); }; template<classView> classValCommitFunction:public ValCommit<View, typenameBranchTraits<typenameView::VarType>::ValType>{ typedeftypenameValCommit<View, typenameBranchTraits<typename View::VarType> ::ValType>::ValVal; public: typedeftypenameView::VarTypeVar; typedeftypenameBranchTraits<Var>::CommitCommitFunction; protected: CommitFunctionc; public: ValCommitFunction(Space&home,constValBranch&vb); ValCommitFunction(Space&home,boolshared,ValCommitFunction&vc); ModEventcommit(Space&home,unsignedinta,Viewx,inti,Valn); NGL*ngl(Space&home,unsignedinta,Viewx,Valn)const; voidprint(constSpace&home,unsignedinta,Viewx,inti, constVal&n,std::ostream&o)const; }; //Baseclassforvaluecommit template<classView,classVal> forceinline ValCommit<View,Val>::ValCommit(Space&,constValBranch&){} template<classView,classVal> forceinline ValCommit<View,Val>::ValCommit(Space&,bool,ValCommit<View,Val>&){} template<classView,classVal> forceinlinebool ValCommit<View,Val>::notice(void)const{ returnfalse; } template<classView,classVal> forceinlinevoid ValCommit<View,Val>::dispose(Space&){} //User-definedvalueselection template<classView> forceinline ValCommitFunction<View>::ValCommitFunction(Space&home, constValBranch&vb) :ValCommit<View,Val>(home,vb), c(function_cast<CommitFunction>(vb.commit())){} template<classView> forceinline ValCommitFunction<View>::ValCommitFunction(Space&home,boolshared, ValCommitFunction<View>&vc) :ValCommit<View,Val>(home,shared,vc),c(vc.c){} template<classView> forceinlineModEvent ValCommitFunction<View>::commit(Space&home,unsignedinta,Viewx,inti, Valn){ typenameView::VarTypey(x.varimp()); c(home,a,y,i,n); returnhome.failed()?ES_FAILED:ES_OK; } template<classView> forceinlineNGL* ValCommitFunction<View>::ngl(Space&,unsignedint,View,Val)const{ returnNULL; } template<classView> forceinlinevoid ValCommitFunction<View>::print(constSpace&,unsignedint, View,inti,constVal&, std::ostream&o)const{ o<<"var["<<i<<"]isuser-defined."; } } //STATISTICS:kernel-branch