← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3911: Use C++11 constructions for InteractionLoop.

 

------------------------------------------------------------
revno: 3911
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Fri 2016-07-01 22:21:05 +0200
message:
  Use C++11 constructions for InteractionLoop.
modified:
  pkg/common/InteractionLoop.cpp
  pkg/common/InteractionLoop.hpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/common/InteractionLoop.cpp'
--- pkg/common/InteractionLoop.cpp	2015-12-06 09:19:36 +0000
+++ pkg/common/InteractionLoop.cpp	2016-07-01 20:21:05 +0000
@@ -7,19 +7,18 @@
 	if(boost::python::len(t)==0) return; // nothing to do
 	if(boost::python::len(t)!=3) throw invalid_argument("Exactly 3 lists of functors must be given");
 	// parse custom arguments (3 lists) and do in-place modification of args
-	typedef std::vector<shared_ptr<IGeomFunctor> > vecGeom;
-	typedef std::vector<shared_ptr<IPhysFunctor> > vecPhys;
-	typedef std::vector<shared_ptr<LawFunctor> > vecLaw;
+	using vecGeom = std::vector<shared_ptr<IGeomFunctor> >;
+	using vecPhys = std::vector<shared_ptr<IPhysFunctor> >;
+	using vecLaw = std::vector<shared_ptr<LawFunctor> >;
 	vecGeom vg=boost::python::extract<vecGeom>(t[0])();
 	vecPhys vp=boost::python::extract<vecPhys>(t[1])();
 	vecLaw vl=boost::python::extract<vecLaw>(t[2])();
-	FOREACH(shared_ptr<IGeomFunctor> gf, vg) this->geomDispatcher->add(gf);
-	FOREACH(shared_ptr<IPhysFunctor> pf, vp) this->physDispatcher->add(pf);
-	FOREACH(shared_ptr<LawFunctor> cf, vl) this->lawDispatcher->add(cf);
+	for(const auto gf : vg) this->geomDispatcher->add(gf);
+	for(const auto pf : vp) this->physDispatcher->add(pf);
+	for(const auto cf : vl) this->lawDispatcher->add(cf);
 	t=boost::python::tuple(); // empty the args; not sure if this is OK, as there is some refcounting in raw_constructor code
 }
 
-
 void InteractionLoop::action(){
 	// update Scene* of the dispatchers
 	lawDispatcher->scene=scene;
@@ -37,7 +36,7 @@
 	*/
 	// pair of callback object and pointer to the function to be called
 	vector<IntrCallback::FuncPtr> callbackPtrs;
-	FOREACH(const shared_ptr<IntrCallback> cb, callbacks){
+	for (const auto cb : callbacks){
 		cb->scene=scene;
 		callbackPtrs.push_back(cb->stepInit());
 	}
@@ -60,7 +59,7 @@
 	for(long i=0; i<size; i++){
 		const shared_ptr<Interaction>& I=(*scene->interactions)[i];
 	#else
-	FOREACH(const shared_ptr<Interaction>& I, *scene->interactions){
+	for (const auto & I : *scene->interactions){
 	#endif
 		if(removeUnseenIntrs && !I->isReal() && I->iterLastSeen<scene->iter) {
 			eraseAfterLoop(I->getId1(),I->getId2());

=== modified file 'pkg/common/InteractionLoop.hpp'
--- pkg/common/InteractionLoop.hpp	2014-10-15 06:44:01 +0000
+++ pkg/common/InteractionLoop.hpp	2016-07-01 20:21:05 +0000
@@ -1,8 +1,8 @@
 // 2009 © Václav Šmilauer <eudoxos@xxxxxxxx>
 #pragma once
-#include<core/GlobalEngine.hpp>
-#include<pkg/common/Callbacks.hpp>
-#include<pkg/common/Dispatching.hpp>
+#include <core/GlobalEngine.hpp>
+#include <pkg/common/Callbacks.hpp>
+#include <pkg/common/Dispatching.hpp>
 
 #ifdef USE_TIMING_DELTAS
 	#define TIMING_DELTAS_CHECKPOINT(cpt) timingDeltas->checkpoint(cpt)
@@ -14,7 +14,7 @@
 
 class InteractionLoop: public GlobalEngine {
 	bool alreadyWarnedNoCollider;
-	typedef std::pair<Body::id_t, Body::id_t> idPair;
+	using idPair = std::pair<Body::id_t, Body::id_t>;
 	// store interactions that should be deleted after loop in action, not later
 	#ifdef YADE_OPENMP
 		std::vector<std::list<idPair> > eraseAfterLoopIds;