Пример #1
0
  void 
  CSRingDSMC::runEvent() const
  {
    double locdt = dt;
  
#ifdef DYNAMO_DEBUG 
    if (boost::math::isnan(locdt))
      M_throw() << "A NAN system event time has been found";
#endif
    
    Sim->dSysTime += locdt;
    
    Sim->ptrScheduler->stream(locdt);
  
    //dynamics must be updated first
    Sim->dynamics.stream(locdt);

    dt = tstep;

    locdt += Sim->freestreamAcc;
    Sim->freestreamAcc = 0;

    BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins)
      Ptr->eventUpdate(*this, NEventData(), locdt);

    //////////////////// T(1,2) operator
    double intPart;
    double fracpart = std::modf(maxprob12 * range1->size(), &intPart);
 
    size_t nmax = static_cast<size_t>(intPart) + (Sim->uniform_sampler() < fracpart);
  
    {
      boost::variate_generator
	<dynamo::baseRNG&, boost::uniform_int<size_t> >
	id1sampler(Sim->ranGenerator, 
		   boost::uniform_int<size_t>(0, (range1->size()/2) - 1));
    
      for (size_t n = 0; n < nmax; ++n)
	{
	  size_t pairID(id1sampler());
	  const Particle& p1(Sim->particleList[*(range1->begin() + 2 * pairID)]);
	  const Particle& p2(Sim->particleList[*(range1->begin() + 2 * pairID + 1)]);
	
	  Sim->dynamics.getLiouvillean().updateParticlePair(p1, p2);
	
	  CPDData PDat;
	
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    PDat.rij[iDim] = Sim->normal_sampler();
	
	  PDat.rij *= diameter / PDat.rij.nrm();
	
	  if (Sim->dynamics.getLiouvillean().DSMCSpheresTest
	      (p1, p2, maxprob12, factor12, PDat))
	    {
	      ++Sim->eventCount;
	      ++n12;

	      const PairEventData
		SDat(Sim->dynamics.getLiouvillean().DSMCSpheresRun(p1, p2, e, PDat));
	    
	      Sim->signalParticleUpdate(SDat);
	    
	      Sim->ptrScheduler->fullUpdate(p1, p2);
	    
	      BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins)
		Ptr->eventUpdate(*this, SDat, 0.0);
	    }
	}
    }

    //////////////////// T(1,3) operator
    {
      fracpart = std::modf(maxprob13 * range1->size(), &intPart);
    
      nmax = static_cast<size_t>(intPart) + (Sim->uniform_sampler() < fracpart);
    
      boost::variate_generator
	<dynamo::baseRNG&, boost::uniform_int<size_t> >
	id1sampler(Sim->ranGenerator, 
		   boost::uniform_int<size_t>(0, range1->size() - 1));
    
      for (size_t n = 0; n < nmax; ++n)
	{
	  const Particle& p1(Sim->particleList[*(range1->begin() + id1sampler())]);
	
	  size_t secondID(id1sampler());
	
	  while ((secondID == p1.getID())
		 || ((secondID % 2) 
		     ? ((secondID-1) == p1.getID())
		     : ((secondID+1) == p1.getID())))
	    secondID = id1sampler();
	
	  const Particle& p2(Sim->particleList[*(range1->begin() + secondID)]);
	
	  Sim->dynamics.getLiouvillean().updateParticlePair(p1, p2);
	
	  CPDData PDat;
	
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    PDat.rij[iDim] = Sim->normal_sampler();
	
	  PDat.rij *= diameter / PDat.rij.nrm();
	
	  if (Sim->dynamics.getLiouvillean().DSMCSpheresTest
	      (p1, p2, maxprob13, factor13, PDat))
	    {
	      ++Sim->eventCount;
	      ++n13;

	      const PairEventData
		SDat(Sim->dynamics.getLiouvillean().DSMCSpheresRun(p1, p2, e, PDat));

	      Sim->signalParticleUpdate(SDat);
	    
	      Sim->ptrScheduler->fullUpdate(p1, p2);
	    
	      BOOST_FOREACH(std::tr1::shared_ptr<OutputPlugin>& Ptr, Sim->outputPlugins)
		Ptr->eventUpdate(*this, SDat, 0.0);
	    }
	}
    }
  }
TOOL_DISPATCHER::~TOOL_DISPATCHER()
{
    BOOST_FOREACH( BUTTON_STATE* st, m_buttons )
        delete st;
}
Пример #3
0
    inline void rescaleTimes(const double& scale) throw()
    { 
      BOOST_FOREACH(Event& dat, c)
	dat.dt *= scale;
    }
Пример #4
0
void MainWindow::RemoveAllContentPanels(ServicePresenter* parent) {
  BOOST_FOREACH (ContentPanel* panel , contents_.values(parent))
    delete panel;
  contents_.remove(parent);
}
Пример #5
0
bool CGoldminenodeSync::IsBlockchainSynced(bool fBlockAccepted)
{
    static bool fBlockchainSynced = false;
    static int64_t nTimeLastProcess = GetTime();
    static int nSkipped = 0;
    static bool fFirstBlockAccepted = false;

    // if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process
    if(GetTime() - nTimeLastProcess > 60*60) {
        Reset();
        fBlockchainSynced = false;
    }

    if(!pCurrentBlockIndex || !pindexBestHeader || fImporting || fReindex) return false;

    if(fBlockAccepted) {
        // this should be only triggered while we are still syncing
        if(!IsSynced()) {
            // we are trying to download smth, reset blockchain sync status
            if(fDebug) LogPrintf("CGoldminenodeSync::IsBlockchainSynced -- reset\n");
            fFirstBlockAccepted = true;
            fBlockchainSynced = false;
            nTimeLastProcess = GetTime();
            return false;
        }
    } else {
        // skip if we already checked less than 1 tick ago
        if(GetTime() - nTimeLastProcess < GOLDMINENODE_SYNC_TICK_SECONDS) {
            nSkipped++;
            return fBlockchainSynced;
        }
    }

    if(fDebug) LogPrintf("CGoldminenodeSync::IsBlockchainSynced -- state before check: %ssynced, skipped %d times\n", fBlockchainSynced ? "" : "not ", nSkipped);

    nTimeLastProcess = GetTime();
    nSkipped = 0;

    if(fBlockchainSynced) return true;

    if(fCheckpointsEnabled && pCurrentBlockIndex->nHeight < Checkpoints::GetTotalBlocksEstimate(Params().Checkpoints()))
        return false;

    std::vector<CNode*> vNodesCopy;
    {
        LOCK(cs_vNodes);
        vNodesCopy = vNodes;
        BOOST_FOREACH(CNode* pnode, vNodesCopy)
            pnode->AddRef();
    }

    // We have enough peers and assume most of them are synced
    if(vNodes.size() >= GOLDMINENODE_SYNC_ENOUGH_PEERS) {
        // Check to see how many of our peers are (almost) at the same height as we are
        int nNodesAtSameHeight = 0;
        BOOST_FOREACH(CNode* pnode, vNodesCopy)
        {
            // Make sure this peer is presumably at the same height
            if(!CheckNodeHeight(pnode)) continue;
            nNodesAtSameHeight++;
            // if we have decent number of such peers, most likely we are synced now
            if(nNodesAtSameHeight >= GOLDMINENODE_SYNC_ENOUGH_PEERS) {
                LogPrintf("CGoldminenodeSync::IsBlockchainSynced -- found enough peers on the same height as we are, done\n");
                fBlockchainSynced = true;
                ReleaseNodes(vNodesCopy);
                return true;
            }
        }
    }
Пример #6
0
    inline void stream(const double& ndt) throw()
    {
      BOOST_FOREACH(Event& dat, c)
	dat.dt -= ndt;
    }
Пример #7
0
size_t Updater::computeBufSize(const DataFragmentPtrArray& data) {
	size_t size = (data.size() + 1)*sizeof(size_t);
	BOOST_FOREACH(DataFragment* df, data) 
		size += ((Data*)df)->size()*3*sizeof(double);
	return size;
}
Пример #8
0
void BonusList::getAllBonuses(BonusList &out) const
{
	BOOST_FOREACH(Bonus *b, bonuses)
		out.push_back(b);
}
Пример #9
0
bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
    if(status != ACTIVE_MASTERNODE_STARTED) {
        errorMessage = "Masternode is not in a running status";
        return false;
    }

    CPubKey pubKeyMasternode;
    CKey keyMasternode;

    if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
    {
        errorMessage = strprintf("Error upon calling SetKey: %s\n", errorMessage);
        return false;
    }

    LogPrintf("CActiveMasternode::SendMasternodePing() - Relay Masternode Ping vin = %s\n", vin.ToString());
    
    CMasternodePing mnp(vin);
    if(!mnp.Sign(keyMasternode, pubKeyMasternode))
    {
        errorMessage = "Couldn't sign Masternode Ping";
        return false;
    }

    // Update lastPing for our masternode in Masternode list
    CMasternode* pmn = mnodeman.Find(vin);
    if(pmn != NULL)
    {
        if(pmn->IsPingedWithin(MASTERNODE_PING_SECONDS, mnp.sigTime)){
            errorMessage = "Too early to send Masternode Ping";
            return false;
        }

        pmn->lastPing = mnp;
        mnodeman.mapSeenMasternodePing.insert(make_pair(mnp.GetHash(), mnp));

        //mnodeman.mapSeenMasternodeBroadcast.lastPing is probably outdated, so we'll update it
        CMasternodeBroadcast mnb(*pmn);
        uint256 hash = mnb.GetHash();
        if(mnodeman.mapSeenMasternodeBroadcast.count(hash)) mnodeman.mapSeenMasternodeBroadcast[hash].lastPing = mnp;

        mnp.Relay();

        /*
         * IT'S SAFE TO REMOVE THIS IN FURTHER VERSIONS
         * AFTER MIGRATION TO V12 IS DONE
         */

        if(IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES)) return true;
        // for migration purposes ping our node on old masternodes network too
        std::string retErrorMessage;
        std::vector<unsigned char> vchMasterNodeSignature;
        int64_t masterNodeSignatureTime = GetAdjustedTime();

        std::string strMessage = service.ToString() + boost::lexical_cast<std::string>(masterNodeSignatureTime) + boost::lexical_cast<std::string>(false);

        if(!darkSendSigner.SignMessage(strMessage, retErrorMessage, vchMasterNodeSignature, keyMasternode)) {
            errorMessage = "dseep sign message failed: " + retErrorMessage;
            return false;
        }

        if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchMasterNodeSignature, strMessage, retErrorMessage)) {
            errorMessage = "dseep verify message failed: " + retErrorMessage;
            return false;
        }

        LogPrint("masternode", "dseep - relaying from active mn, %s \n", vin.ToString().c_str());
        LOCK(cs_vNodes);
        BOOST_FOREACH(CNode* pnode, vNodes)
            pnode->PushMessage("dseep", vin, vchMasterNodeSignature, masterNodeSignatureTime, false);

        /*
         * END OF "REMOVE"
         */

        return true;
    }
    else
    {
        // Seems like we are trying to send a ping while the Masternode is not registered in the network
        errorMessage = "Darksend Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin.ToString();
        status = ACTIVE_MASTERNODE_NOT_CAPABLE;
        notCapableReason = errorMessage;
        return false;
    }

}
Пример #10
0
bool CActiveMasternode::Register(CTxIn vin, CService service, CKey keyCollateralAddress, CPubKey pubKeyCollateralAddress, CKey keyMasternode, CPubKey pubKeyMasternode, std::string &errorMessage) {
    CMasternodeBroadcast mnb;
    CMasternodePing mnp(vin);
    if(!mnp.Sign(keyMasternode, pubKeyMasternode)){
        errorMessage = strprintf("Failed to sign ping, vin: %s", vin.ToString());
        LogPrintf("CActiveMasternode::Register() -  %s\n", errorMessage);
        return false;
    }
    mnodeman.mapSeenMasternodePing.insert(make_pair(mnp.GetHash(), mnp));

    LogPrintf("CActiveMasternode::Register() - Adding to Masternode list\n    service: %s\n    vin: %s\n", service.ToString(), vin.ToString());
    mnb = CMasternodeBroadcast(service, vin, pubKeyCollateralAddress, pubKeyMasternode, PROTOCOL_VERSION);
    mnb.lastPing = mnp;
    if(!mnb.Sign(keyCollateralAddress)){
        errorMessage = strprintf("Failed to sign broadcast, vin: %s", vin.ToString());
        LogPrintf("CActiveMasternode::Register() - %s\n", errorMessage);
        return false;
    }
    mnodeman.mapSeenMasternodeBroadcast.insert(make_pair(mnb.GetHash(), mnb));
    masternodeSync.AddedMasternodeList(mnb.GetHash());

    CMasternode* pmn = mnodeman.Find(vin);
    if(pmn == NULL)
    {
        CMasternode mn(mnb);
        mnodeman.Add(mn);
    } else {
        pmn->UpdateFromNewBroadcast(mnb);
    }

    //send to all peers
    LogPrintf("CActiveMasternode::Register() - RelayElectionEntry vin = %s\n", vin.ToString());
    mnb.Relay();

    /*
     * IT'S SAFE TO REMOVE THIS IN FURTHER VERSIONS
     * AFTER MIGRATION TO V12 IS DONE
     */

    if(IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES)) return true;
    // for migration purposes inject our node in old masternodes' list too
    std::string retErrorMessage;
    std::vector<unsigned char> vchMasterNodeSignature;
    int64_t masterNodeSignatureTime = GetAdjustedTime();
    std::string donationAddress = "";
    int donationPercantage = 0;

    std::string vchPubKey(pubKeyCollateralAddress.begin(), pubKeyCollateralAddress.end());
    std::string vchPubKey2(pubKeyMasternode.begin(), pubKeyMasternode.end());

    std::string strMessage = service.ToString() + boost::lexical_cast<std::string>(masterNodeSignatureTime) + vchPubKey + vchPubKey2 + boost::lexical_cast<std::string>(PROTOCOL_VERSION) + donationAddress + boost::lexical_cast<std::string>(donationPercantage);

    if(!darkSendSigner.SignMessage(strMessage, retErrorMessage, vchMasterNodeSignature, keyCollateralAddress)) {
        errorMessage = "dsee sign message failed: " + retErrorMessage;
        LogPrintf("CActiveMasternode::Register() - Error: %s\n", errorMessage.c_str());
        return false;
    }

    if(!darkSendSigner.VerifyMessage(pubKeyCollateralAddress, vchMasterNodeSignature, strMessage, retErrorMessage)) {
        errorMessage = "dsee verify message failed: " + retErrorMessage;
        LogPrintf("CActiveMasternode::Register() - Error: %s\n", errorMessage.c_str());
        return false;
    }

    LOCK(cs_vNodes);
    BOOST_FOREACH(CNode* pnode, vNodes)
        pnode->PushMessage("dsee", vin, service, vchMasterNodeSignature, masterNodeSignatureTime, pubKeyCollateralAddress, pubKeyMasternode, -1, -1, masterNodeSignatureTime, PROTOCOL_VERSION, donationAddress, donationPercantage);

    /*
     * END OF "REMOVE"
     */

    return true;
}
Пример #11
0
std::string field::value_str() const
{
    std::ostringstream os;

    switch(type())
    {
        case FT_DCHP:
            os << (value<bool>() ? "true" : "false");
            break;

        case FT_HW_TYPE:
        case FT_HW_REV:
        case FT_SERIAL_COUNT:
            os << std::dec << int(value<uint8_t>());
            break;

        case FT_VERSION:
            os << std::dec << value<uint16_t>();

        case FT_PORT:
        case FT_SSL_PORT:
            os << std::dec << value<uint32_t>();
            break;

        case FT_NAME:
        case FT_DOMAIN:
        case FT_FIRMWARE:
        case FT_RESULT_MSG:
        case FT_DEVICE:
            os << value<std::string>();
            break;

        case FT_IP_ADDR:
        case FT_NETMASK:
        case FT_GATEWAY:
        case FT_DNS:
            os << value<ip_address>();
            break;

        case FT_MAC_ADDR:
            os << value<mac_address>();
            break;

        case FT_VENDOR:
            os << value<guid>();
            break;

        case FT_CONF_ERR_CODE:
            os << std::dec << value<config_error>();
            break;

        case FT_ERR_CODE:
            os << std::dec << value<error_code>();
            break;

        case FT_RESULT_FLAG:
            os << std::dec << value<result_flag>();
            break;

        default:
        {
            BOOST_FOREACH(uint8_t b, payload())
                os << " " << std::hex << std::setfill('0') << std::setw(2) << int(b);
            break;
        }
    }
    return os.str();
}
COMPONENT_TREE_SEARCH_CONTAINER::~COMPONENT_TREE_SEARCH_CONTAINER()
{
    BOOST_FOREACH( TREE_NODE* node, nodes )
        delete node;
    nodes.clear();
}
Пример #13
0
void TOOL_DISPATCHER::ResetState()
{
    BOOST_FOREACH( BUTTON_STATE* st, m_buttons )
        st->Reset();
}
Пример #14
0
  void read(boost::optional<mil_msgs::VelocityMeasurements> &res, boost::optional<mil_msgs::RangeStamped> &height_res)
  {
    res = boost::none;
    height_res = boost::none;

    if (!p.is_open())  // Open serial port if closed
    {
      open();
      return;
    }

    ByteVec ensemble;
    ensemble.resize(4);

    // Header ID
    if (!read_byte(ensemble[0]))
      return;
    if (ensemble[0] != 0x7F)
      return;

    ros::Time stamp = ros::Time::now();

    // Data Source ID
    if (!read_byte(ensemble[1]))
      return;
    if (ensemble[1] != 0x7F)
      return;

    // Size low
    if (!read_byte(ensemble[2]))
      return;
    // Size high
    if (!read_byte(ensemble[3]))
      return;

    uint16_t ensemble_size = getu16le(ensemble.data() + 2);
    ensemble.resize(ensemble_size);
    for (int i = 4; i < ensemble_size; i++)
    {
      if (!read_byte(ensemble[i]))
        return;
    }

    uint16_t checksum = 0;
    BOOST_FOREACH (uint16_t b, ensemble)
      checksum += b;
    uint16_t received_checksum;
    if (!read_short(received_checksum))
      return;
    if (received_checksum != checksum)
    {
      ROS_ERROR_THROTTLE(0.5, "DVL: invalid ensemble checksum. received: %i calculated: %i size: %i", received_checksum,
                         checksum, ensemble_size);
      return;
    }

    if (ensemble.size() < 6)
      return;
    for (int dt = 0; dt < ensemble[5]; dt++)
    {
      int offset = getu16le(ensemble.data() + 6 + 2 * dt);
      if (ensemble.size() - offset < 2)
        continue;
      // Three modes, encoded by the section_id: Bottom Track High Resolution Velocity
      // Bottom Track, Bottom Track Range
      uint16_t section_id = getu16le(ensemble.data() + offset);

      std::vector<double> correlations(4, nan(""));
      if (section_id == 0x5803)  // Bottom Track High Resolution Velocity
      {
        if (ensemble.size() - offset < 2 + 4 * 4)
          continue;
        res = boost::make_optional(mil_msgs::VelocityMeasurements());
        res->header.stamp = stamp;

        std::vector<geometry_msgs::Vector3> dirs;
        {
          double tilt = 30 * boost::math::constants::pi<double>() / 180;
          double x = sin(tilt);
          double z = cos(tilt);
          dirs.push_back(mil_tools::make_xyz<geometry_msgs::Vector3>(-x, 0, -z));
          dirs.push_back(mil_tools::make_xyz<geometry_msgs::Vector3>(+x, 0, -z));
          dirs.push_back(mil_tools::make_xyz<geometry_msgs::Vector3>(0, +x, -z));
          dirs.push_back(mil_tools::make_xyz<geometry_msgs::Vector3>(0, -x, -z));
        }

        // Keep track of which beams didn't return for logging
        std::vector<size_t> invalid_beams;
        invalid_beams.reserve(4);
        for (int i = 0; i < 4; i++)
        {
          mil_msgs::VelocityMeasurement m;
          m.direction = dirs[i];
          int32_t vel = gets32le(ensemble.data() + offset + 2 + 4 * i);
          m.velocity = -vel * .01e-3;
          if (vel == -3276801)  // -3276801 indicates no data
          {
            invalid_beams.push_back(i + 1);
            m.velocity = nan("");
          }
          res->velocity_measurements.push_back(m);
        }

        // Report  a list of invalid beams
        if (invalid_beams.size() > 0)
        {
          std::string to_log{ "DVL: didn't return bottom velocity for beam(s): " };
          for (auto beam : invalid_beams)
            to_log += std::to_string(beam) + " ";
          ROS_ERROR_THROTTLE(0.5, "%s", to_log.c_str());
        }
      }
      else if (section_id == 0x0600)  // Bottom Track
      {
        for (int i = 0; i < 4; i++)
          correlations[i] = *(ensemble.data() + offset + 32 + i);
      }
      else if (section_id == 0x5804)  // Bottom Track Range
      {
        if (ensemble.size() - offset < 2 + 4 * 3)
          continue;
        if (gets32le(ensemble.data() + offset + 10) <= 0)
        {
          ROS_ERROR_THROTTLE(0.5, "%s", "DVL: didn't return height over bottom");
          continue;
        }
        height_res = boost::make_optional(mil_msgs::RangeStamped());
        height_res->header.stamp = stamp;
        height_res->range = gets32le(ensemble.data() + offset + 10) * 0.1e-3;
      }
      if (res)
      {
        for (int i = 0; i < 4; i++)
        {
          res->velocity_measurements[i].correlation = correlations[i];
        }
      }
    }
  }
Пример #15
0
void FeatureFunction::SetupAll(TranslationTask const& ttask)
{
  BOOST_FOREACH(FeatureFunction* ff, s_staticColl)
  ff->Setup(ttask);
}
Пример #16
0
void
GWaker::runEvent(const Particle& part, const double dt) const
{
    GlobalEvent iEvent(getEvent(part));
    iEvent.setdt(dt); //We only trust the schedulers time, as we don't
    //track the motion of the system in Globals

#ifdef DYNAMO_DEBUG
    if (boost::math::isnan(iEvent.getdt()))
        M_throw() << "A NAN Interaction collision time has been found"
                  << iEvent.stringData(Sim);

    if (iEvent.getdt() == HUGE_VAL)
        M_throw() << "An infinite Interaction (not marked as NONE) collision time has been found\n"
                  << iEvent.stringData(Sim);
#endif

    Sim->dSysTime += iEvent.getdt();

    Sim->ptrScheduler->stream(iEvent.getdt());

    Sim->dynamics.stream(iEvent.getdt());

    Sim->dynamics.getLiouvillean().updateParticle(part);

    //Here is where the particle goes to sleep or wakes
    ++Sim->eventCount;

    _neighbors = 0;
    //Grab a reference to the neighbour list
    const CGNeighbourList& nblist(*static_cast<const CGNeighbourList*>(Sim->dynamics.getGlobals()[_NBListID]
                                  .get_ptr()));
    //Add the interaction events
    nblist.getParticleNeighbourhood(part, magnet::function::MakeDelegate(this, &GWaker::nblistCallback));

//  if (_neighbors < 10)
//    {
    iEvent.addTime(Sim->freestreamAcc);
    Sim->freestreamAcc = 0;

    ParticleEventData EDat(part, Sim->dynamics.getSpecies(part), iEvent.getType());

    Vector newVel(Sim->normal_sampler(),Sim->normal_sampler(),Sim->normal_sampler());
    newVel *= _wakeVelocity / newVel.nrm();

    const_cast<Particle&>(part).getVelocity() = newVel;
    const_cast<Particle&>(part).setState(Particle::DYNAMIC);

    EDat.setDeltaKE(0.5 * EDat.getSpecies().getMass(part.getID())
                    * (part.getVelocity().nrm2()
                       - EDat.getOldVel().nrm2()));

    Sim->signalParticleUpdate(EDat);

    BOOST_FOREACH(magnet::ClonePtr<OutputPlugin> & Ptr, Sim->outputPlugins)
    Ptr->eventUpdate(iEvent, EDat);
//    }
//  else
//    Sim->freestreamAcc += iEvent.getdt();

    //Now we're past the event, update the scheduler and plugins
    Sim->ptrScheduler->fullUpdate(part);
}
//----------------------------------------------------------------------------------------------
TPhysicEngine_Bullet::~TPhysicEngine_Bullet()
{
  BOOST_FOREACH(TMapIntWorldVT& ID_World, mMapIDWorld)
    ID_World.second.Done();
  mMapIDWorld.clear();
}
Пример #18
0
void ReleaseNodes(const std::vector<CNode*> &vNodesCopy)
{
    LOCK(cs_vNodes);
    BOOST_FOREACH(CNode* pnode, vNodesCopy)
        pnode->Release();
}
//----------------------------------------------------------------------------------------------
void TPhysicEngine_Bullet::Work(btScalar timeStep, int maxSubSteps, btScalar fixedTimeStep)
{
  BOOST_FOREACH(TMapIntWorldVT& ID_World, mMapIDWorld)
    ID_World.second.pWorld->stepSimulation(timeStep, maxSubSteps, fixedTimeStep);
}
Пример #20
0
 void printdata() 
     { 
         BOOST_FOREACH(anyhash::value_type i, data)
            std::cout<<"key: " << i.first<<" \t -> value: "<<i.second<<"\n";
     }
Пример #21
0
//---------------------------------------------------------------------------------
void TManagerThreadModules::SetCallbackStop(TCallBackRegistrator1<std::string>* pCB)
{
  BOOST_FOREACH(TThreadModules*& pThread, mVecThread)
    pThread->SetCallbackStop(pCB);
}
Пример #22
0
    inline void addTime(const double& ndt) throw()
    {
      BOOST_FOREACH(Event& dat, c)
	dat.dt += ndt;
    }
Пример #23
0
//---------------------------------------------------------------------------------
void TManagerThreadModules::Stop()
{
  BOOST_FOREACH(TThreadModules*& pThread, mVecThread)
    pThread->Stop();
}
Пример #24
0
void MainWindow::RemoveAllContacts(ServicePresenter* parent) {
  grouped_by_account_->RemoveGroup(parent);
  BOOST_FOREACH (ContactWidget* widget , contacts_.values(parent))
    delete widget;
  contacts_.remove(parent);
}
Пример #25
0
//---------------------------------------------------------------------------------
void TManagerThreadModules::Done()
{
  BOOST_FOREACH(TThreadModules*& pThread, mVecThread)
    delete pThread;
}
Пример #26
0
Res::ResourceSet::ResourceSet(const JsonNode & node)
{
	reserve(GameConstants::RESOURCE_QUANTITY);
	BOOST_FOREACH(std::string name, GameConstants::RESOURCE_NAMES)
		push_back(node[name].Float());
}
 inline void
 unlock(std::vector<boost::reference_wrapper<Mutex> > mutexes)
 {
     BOOST_FOREACH(Mutex& mutex, mutexes)
         mutex.unlock();
 }
Пример #28
0
/// Called after code is generated, this function loops over all the ops
/// and figures out the lifetimes of all variables, based on whether the
/// args in each op are read or written.
void
OSLCompilerImpl::track_variable_lifetimes (const OpcodeVec &code,
                                           const SymbolPtrVec &opargs,
                                           const SymbolPtrVec &allsyms)
{
    // Clear the lifetimes for all symbols
    BOOST_FOREACH (Symbol *s, allsyms)
        s->clear_rw ();

    static ustring op_for("for");
    static ustring op_while("while");
    static ustring op_dowhile("dowhile");

    // For each op, mark its arguments as being used at that op
    int opnum = 0;
    BOOST_FOREACH (const Opcode &op, code) {
        // Some work to do for each argument to the op...
        for (int a = 0;  a < op.nargs();  ++a) {
            SymbolPtr s = opargs[op.firstarg()+a];
            ASSERT (s->dealias() == s);
            // s = s->dealias();   // Make sure it's de-aliased

            // Mark that it's read and/or written for this op
            s->mark_rw (opnum, op.argread(a), op.argwrite(a));
        }

        // If this is a loop op, we need to mark its control variable
        // (the only arg) as used for the duration of the loop!
        if (op.opname() == op_for ||
            op.opname() == op_while ||
            op.opname() == op_dowhile) {
            ASSERT (op.nargs() == 1);  // loops should have just one arg
            SymbolPtr s = opargs[op.firstarg()];
            s->mark_rw (opnum+1, true, true);
            s->mark_rw (op.farthest_jump()-1, true, true);
        }

        ++opnum;
    }


    // Special cases: handle variables whose lifetimes cross the boundaries
    // of a loop.
    opnum = 0;
    BOOST_FOREACH (const Opcode &op, code) {
        if (op.opname() == op_for ||
            op.opname() == op_while ||
            op.opname() == op_dowhile) {
            int loopcond = op.jump (0);  // after initialization, before test
            int loopend = op.farthest_jump() - 1;
            BOOST_FOREACH (Symbol *s, allsyms) {
                // Temporaries referenced both inside AND outside a loop
                // need their lifetimes extended to cover the entire
                // loop so they aren't coalesced incorrectly.  The
                // specific danger is for a function that contains a
                // loop, and the function is passed an argument that is
                // a temporary calculation.
                if (s->symtype() == SymTypeTemp &&
                    ((s->firstuse() < loopcond && s->lastuse() >= loopcond) ||
                     (s->firstuse() < loopend && s->lastuse() >= loopend))) {
                    s->mark_rw (opnum, true, true);
                    s->mark_rw (loopend, true, true);
                }

                // Locals that are written within the loop should have
                // their usage conservatively expanded to the whole
                // loop.  This is not a worry for temps, because they
                // CAN'T be read in the next iteration unless they were
                // set before the loop, handled above.  Ideally, we
                // could be less conservative if we knew that the
                // variable in question was declared/scoped internal to
                // the loop, in which case it can't carry values to the
                // next iteration (FIXME).
                if (s->symtype() == SymTypeLocal &&
                      s->firstuse() < loopend && s->lastwrite() >= loopcond) {
                    bool read = (s->lastread() >= loopcond);
                    s->mark_rw (opnum, read, true);
                    s->mark_rw (loopend, read, true);
                }
            }
        }
        ++opnum;
    }
Пример #29
0
	~WXMEncodingDetector()
	{
		BOOST_FOREACH(EncodingChecker* checker, m_checkers)
			delete checker;
	}