Commit 594dd1c0 authored by Anton Gladky's avatar Anton Gladky
Browse files

Use C++11 constructions for InteractionLoop.

parent 0bd81b6a
......@@ -7,19 +7,18 @@ void InteractionLoop::pyHandleCustomCtorArgs(boost::python::tuple& t, boost::pyt
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 @@ void InteractionLoop::action(){
*/
// 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 @@ void InteractionLoop::action(){
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());
......
// 2009 © Václav Šmilauer <eudoxos@arcig.cz>
#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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment