void TransferWorker::parse_dives(Driver::Ptr driver, const dive_data_t & dives) { IMixFinder::Ptr mf = boost::dynamic_pointer_cast<IMixFinder>(m_session->finder<Mix>()); Mix::Ptr air = mf->findByName("Air"); parser_data data; data.mixfinder = mf; // Parse the Dives dive_data_t::const_iterator it; for (it = dives.begin(); it != dives.end(); it++) { // Setup Parser Data data.dive.reset(new Dive); data.mixes.clear(); data.profile.clear(); data.vendor.clear(); data.haswp = false; data.curmix = air; // Parse the Header and Profile driver->parse(it->first, & parse_header, & parse_profile, & data); // Append the final Waypoint if (data.haswp) data.profile.push_back(data.curwp); // Update Dive Data data.dive->setComputer(m_dc); // Set the Dive Mix as the first Mix in the profile if (data.haswp) data.dive->setMix(data.profile.begin()->mix); // Create Profile Profile::Ptr profile = Profile::Ptr(new Profile); profile->setComputer(m_dc); profile->setDive(data.dive); profile->setImported(time(NULL)); profile->setProfile(data.profile); profile->setRawProfile(it->first); profile->setVendor(json_encode(data.vendor)); // Emit Parsed Dive emit parsedDive(profile); } }
//! @brief Unlink this Object to the Owning Object virtual void unlink(Persistent::Ptr d, Persistent::Ptr obj) { Dive::Ptr dive = boost::dynamic_pointer_cast<Dive>(obj); Profile::Ptr profile = boost::dynamic_pointer_cast<Profile>(d); profile->setDive(boost::none); }