// The timebomb BOOL CXEvilApp::timeStampcheck() { // Disabled for final release. #if 0 CTime current = CTime::GetCurrentTime(); // Beta 7 CTime earliest(1998,12,1,0,0,0); // Dec 1, 1998 CTime latest(1999,4,1,0,0,0); // Apr 1, 1999 // Beta 6 // CTime earliest(1998,1,1,0,0,0); // Jan 1, 1998 // CTime latest(1999,1,1,0,0,0); // Jan 1, 1999 // Beta 5 // CTime earliest(1997,7,1,0,0,0); // July 1, 1997 // CTime latest(1998,7,1,0,0,0); // July 1, 1998 if (current <= earliest) { return FALSE; } if (current >= latest) { return FALSE; } #endif return TRUE; }
/////////////////////////////////////////////////////////////////////////////// /// \brief If there are lots of history entries, removes all old entries, /// leaving only the most recently created ones. /// /// \details If history entires are removed, the remaining entries are /// compressed so that their indices start at 0 for the oldest entry. /// /// \param id The AssetId of the WindowSettings stack to truncate. /// \param max_history_entries The number of entries to leave in the database. /// /// \ingroup loading void truncateWindowSettingsHistory(const AssetId& id, int max_history_entries) { try { std::shared_ptr<bed::Bed> bed = bed::openWritable(id.bed); if (!bed) throw std::runtime_error("Could not open bed for writing!"); bed::Db& db = bed->getDb(); if (db.getInt(BE_WND_WINDOW_SETTINGS_SQL_TABLE_EXISTS, 0) == 0) throw std::runtime_error("WindowSettings table does not exist!"); bed::Transaction transaction(db, bed::Transaction::Immediate); int history_index = 0; bed::Stmt latest(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_LATEST_INDEX), BE_WND_WINDOW_SETTINGS_SQL_LATEST_INDEX); latest.bind(1, id.asset.value()); if (latest.step()) history_index = latest.getInt(0); history_index -= max_history_entries - 1; // remove old history entries bed::Stmt remove(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_TRUNCATE), BE_WND_WINDOW_SETTINGS_SQL_TRUNCATE); remove.bind(1, id.asset.value()); remove.bind(2, history_index); remove.step(); // compress remaining history indices closer to 0 if (history_index > 1) { bed::Stmt compress(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_COMPRESS), BE_WND_WINDOW_SETTINGS_SQL_COMPRESS); compress.bind(2, id.asset.value()); compress.bind(1, history_index - 1); compress.step(); } transaction.commit(); } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while truncating window settings history!" << BE_LOG_NL << " Bed: " << id.bed << BE_LOG_NL << "WindowSettings ID: " << id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while truncating window settings history!" << BE_LOG_NL << " Bed: " << id.bed << BE_LOG_NL << "WindowSettings ID: " << id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } }
/////////////////////////////////////////////////////////////////////////////// /// \brief Updates the position and size properties of an existing saved /// WindowSettings object. /// /// \details The WindowSettings object will be found by looking at the AssetId /// found in window_settings.id. The history index updated will be /// the most recent one. Only the size and position properties will /// be updated, and only if window_settings.save_position_on_close /// is true. /// /// \param window_settings Determines where the WindowSettings are saved and /// the new position/size values to update. /// \return \c true if the size and position were updated successfully. /// /// \ingroup loading bool updateSavedPosition(const WindowSettings& window_settings) { if (!window_settings.save_position_on_close) return false; try { std::shared_ptr<bed::Bed> bed = bed::openWritable(window_settings.id.bed); if (!bed) throw std::runtime_error("Could not open bed for writing!"); bed::Db& db = bed->getDb(); if (db.getInt(BE_WND_WINDOW_SETTINGS_SQL_TABLE_EXISTS, 0) == 0) throw std::runtime_error("WindowSettings table does not exist!"); bed::Transaction transaction(db, bed::Transaction::Immediate); int history_index = 0; bed::Stmt latest(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_LATEST_INDEX), BE_WND_WINDOW_SETTINGS_SQL_LATEST_INDEX); latest.bind(1, window_settings.id.asset.value()); if (latest.step()) history_index = latest.getInt(0); bed::Stmt save(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_SAVE_POS), BE_WND_WINDOW_SETTINGS_SQL_SAVE_POS); save.bind(1, window_settings.position.x); save.bind(2, window_settings.position.y); save.bind(3, window_settings.size.x); save.bind(4, window_settings.size.y); save.bind(5, window_settings.id.asset.value()); save.bind(6, history_index); save.step(); transaction.commit(); return true; } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while saving window position!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while saving window position!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } return false; }
OpTime TopologyCoordinatorImpl::_latestKnownOpTime() const { OpTime latest(0,0); for( Member *m = _otherMembers.head(); m; m=m->next() ) { if (!m->hbinfo().up()) { continue; } if (m->hbinfo().opTime > latest) { latest = m->hbinfo().opTime; } } return latest; }
/////////////////////////////////////////////////////////////////////////////// /// \brief Deletes the most recent history index of the specified /// WindowSettings object. /// /// \param id The AssetId defining the WindowSettings stack to revert. /// \return The next most recent history index for the WindowSettings object. /// If there is a problem deleting the most recent window settings or /// if there is no next most recent history index, a /// default-constructed WindowSettings object will be returned. /// /// \ingroup loading WindowSettings revertWindowSettings(const AssetId& id) { try { std::shared_ptr<bed::Bed> bed = bed::openWritable(id.bed); if (!bed) throw std::runtime_error("Could not open bed for writing!"); bed::Db& db = bed->getDb(); if (db.getInt(BE_WND_WINDOW_SETTINGS_SQL_TABLE_EXISTS, 0) == 0) throw std::runtime_error("WindowSettings table does not exist!"); bed::Transaction transaction(db, bed::Transaction::Immediate); int history_index = 0; bed::Stmt latest(db, BE_WND_WINDOW_SETTINGS_SQLID_LATEST_INDEX); latest.bind(1, id.asset.value()); if (latest.step()) history_index = latest.getInt(0); bed::Stmt remove(db, BE_WND_WINDOW_SETTINGS_SQLID_REVERT); remove.bind(1, id.asset.value()); remove.bind(2, history_index); remove.step(); transaction.commit(); return loadWindowSettings(*bed, id.asset); } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while reverting window settings!" << BE_LOG_NL << " Bed: " << id.bed << BE_LOG_NL << "WindowSettings ID: " << id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while reverting window settings!" << BE_LOG_NL << " Bed: " << id.bed << BE_LOG_NL << "WindowSettings ID: " << id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } return WindowSettings(); }
/////////////////////////////////////////////////////////////////////////////// /// \brief Saves a set of WindowSettings to a bed. /// /// \details The bed and Id that are saved to are determined by the id field /// of the WindowSettings object passed in. If the WindowSettings /// already exist in the bed, a new history index will be created. /// /// If there is a problem saving the WindowSettings, a warning will /// be emitted, and false will be returned. /// /// \param window_settings The WindowSettings to save. /// \return \c true if the WindowSettings were saved successfully. /// /// \ingroup loading bool saveWindowSettings(const WindowSettings& window_settings) { try { std::shared_ptr<bed::Bed> bed = bed::openWritable(window_settings.id.bed); if (!bed) throw std::runtime_error("Could not open bed for writing!"); bed::Db& db = bed->getDb(); bed::Transaction transaction(db, bed::Transaction::Immediate); int history_index = 0; if (db.getInt(BE_WND_WINDOW_SETTINGS_SQL_TABLE_EXISTS, 0) == 0) { db.exec(BE_WND_WINDOW_SETTINGS_SQL_CREATE_TABLE); } else { bed::Stmt latest(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_LATEST_INDEX), BE_WND_WINDOW_SETTINGS_SQL_LATEST_INDEX); latest.bind(1, window_settings.id.asset.value()); if (latest.step()) history_index = latest.getInt(0); } bed::Stmt save(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_SAVE), BE_WND_WINDOW_SETTINGS_SQL_SAVE); save.bind(1, window_settings.id.asset.value()); save.bind(2, history_index + 1); save.bind(3, static_cast<int>(window_settings.mode)); save.bind(4, window_settings.system_positioned); save.bind(5, window_settings.save_position_on_close); save.bind(6, window_settings.position.x); save.bind(7, window_settings.position.y); save.bind(8, window_settings.size.x); save.bind(9, window_settings.size.y); save.bind(10, window_settings.monitor_index); save.bind(11, window_settings.refresh_rate); save.bind(12, static_cast<int>(window_settings.v_sync)); save.bind(13, window_settings.msaa_level); save.bind(14, window_settings.red_bits); save.bind(15, window_settings.green_bits); save.bind(16, window_settings.blue_bits); save.bind(17, window_settings.alpha_bits); save.bind(18, window_settings.depth_bits); save.bind(19, window_settings.stencil_bits); save.bind(20, window_settings.srgb_capable); save.bind(21, window_settings.use_custom_gamma); save.bind(22, window_settings.custom_gamma); save.bind(23, window_settings.context_version_major); save.bind(24, window_settings.context_version_minor); save.bind(25, window_settings.forward_compatible_context ? 1 : 0); save.bind(26, window_settings.debug_context ? 1 : 0); save.bind(27, static_cast<int>(window_settings.context_profile_type)); save.step(); transaction.commit(); return true; } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while saving window settings!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while saving window settings!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } return false; }
void Key_file::generate () { uint32_t version(is_empty() ? 0 : latest() + 1); entries[version].generate(version); }
const Key_file::Entry* Key_file::get_latest () const { return is_filled() ? get(latest()) : 0; }
JNIEXPORT void JNICALL Java_org_apache_subversion_javahl_util_DiffLib_nativeFileMerge( JNIEnv* env, jobject jthis, jstring joriginal_file, jstring jmodified_file, jstring jlatest_file, jint jignore_space_ordinal, jboolean jignore_eol_style, jboolean jshow_c_function, jstring jconflict_original, jstring jconflict_modified, jstring jconflict_latest, jstring jconflict_separator, jint jconflict_style_ordinal, jobject jresult_stream) { JNIEntry(DiffLib, nativeFileMerge); // Using a "global" request pool since we don't keep a context with // its own pool around for these functions. SVN::Pool pool; Path original(joriginal_file, pool); if (JNIUtil::isJavaExceptionThrown()) return; SVN_JNI_ERR(original.error_occurred(),); Path modified(jmodified_file, pool); if (JNIUtil::isJavaExceptionThrown()) return; SVN_JNI_ERR(modified.error_occurred(),); Path latest(jlatest_file, pool); if (JNIUtil::isJavaExceptionThrown()) return; SVN_JNI_ERR(latest.error_occurred(),); svn_diff_t* diff; svn_diff_file_options_t* diff_options = svn_diff_file_options_create(pool.getPool()); diff_options->ignore_space = svn_diff_file_ignore_space_t(jignore_space_ordinal); diff_options->ignore_eol_style = svn_boolean_t(jignore_eol_style); diff_options->show_c_function = svn_boolean_t(jshow_c_function); SVN_JNI_ERR(svn_diff_file_diff3_2(&diff, original.c_str(), modified.c_str(), latest.c_str(), diff_options, pool.getPool()),); JNIStringHolder conflict_original(jconflict_original); if (JNIUtil::isJavaExceptionThrown()) return; JNIStringHolder conflict_modified(jconflict_modified); if (JNIUtil::isJavaExceptionThrown()) return; JNIStringHolder conflict_latest(jconflict_latest); if (JNIUtil::isJavaExceptionThrown()) return; JNIStringHolder conflict_separator(jconflict_separator); if (JNIUtil::isJavaExceptionThrown()) return; OutputStream result_stream(jresult_stream); SVN_JNI_ERR(svn_diff_file_output_merge2( result_stream.getStream(pool), diff, original.c_str(), modified.c_str(), latest.c_str(), conflict_original.c_str(), conflict_modified.c_str(), conflict_latest.c_str(), conflict_separator.c_str(), svn_diff_conflict_display_style_t(jconflict_style_ordinal), pool.getPool()),); }
void AppUpdater::finishedRead( int id, bool errors ) { (void)errors; // we'll get called here alternately by the setHost( ) request and the actual GET request // we don't care about setHost, so just return and wait for the GET response if( id != httpGetID ) return; QDomDocument doc; QString err; int line, col; if (!doc.setContent(http.readAll(), true, &err, &line, &col)) { headline.setText( "<font size=4>Couldn't contact the update server...</font>" ); details.setText( QString( "Make sure you're connected to the internet." ) ); acceptButton.setText( tr("OK") ); acceptButton.disconnect( ); // make sure it wasn't connected by anything else previously connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); removeBrowserAndIgnoreButton( ); if(!checkingOnStartup) this->show( ); return; } QDomElement channel = doc.documentElement().firstChild().toElement(); QDomNodeList items = channel.elementsByTagName("item"); QPair<QString, QString> latest(MCBUILDER_VERSION, ""); bool updateAvailable = false; for (int i=0, j=items.size(); i<j; i++) { QDomElement item = items.item(i).toElement(); if( item.isNull() ) continue; QDomNodeList enclosures = item.elementsByTagName("enclosure"); for (int k=0, l=enclosures.size(); k<l; k++) { QDomElement enclosure = enclosures.item(k).toElement(); if (enclosure.isNull()) continue; QString version = enclosure.attributeNS( "http://www.andymatuschak.org/xml-namespaces/sparkle", "version", "not-found" ); // each item can have multiple enclosures, of which at least one // should have a version field if (version == "not-found") continue; if( versionCompare(version, latest.first) > 0 ) { latest.first = version; QDomNodeList descs = item.elementsByTagName("description"); //I(descs.size() == 1); QDomElement desc = descs.item(0).toElement(); //I(!desc.isNull()); latest.second = desc.text(); updateAvailable = true; } } } // add the appropriate elements/info depending on whether an update is available if( updateAvailable ) { headline.setText( "<font size=4>A new version of mcbuilder is available!</font>" ); QString d = QString( "mcbuilder %1 is now available (you have %2). Would you like to download it?" ) .arg(latest.first).arg( MCBUILDER_VERSION ); details.setText( d ); browser.setHtml( latest.second ); acceptButton.setText( tr("Visit Download Page") ); acceptButton.disconnect( ); ignoreButton.disconnect( ); connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( visitDownloadsPage() ) ); connect( &ignoreButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); if( textLayout.indexOf( &browser ) < 0 ) // if the browser's not in the layout, then insert it after the details line textLayout.insertWidget( textLayout.indexOf( &details ) + 1, &browser ); if( buttonLayout.indexOf( &ignoreButton ) < 0 ) // put the ignore button on the left buttonLayout.insertWidget( 0, &ignoreButton ); this->show( ); } else { headline.setText( "<font size=4>You're up to date!</font>" ); details.setText( QString( "You're running the latest version of mcbuilder, version %1." ).arg( MCBUILDER_VERSION ) ); acceptButton.setText( tr("OK") ); acceptButton.disconnect( ); connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); removeBrowserAndIgnoreButton( ); if(!checkingOnStartup) this->show( ); } }
// this is just a workbench. most of the stuff here will go into the Frontend class. int main(int argc, char **argv) { ros::init(argc, argv, "okvis_node_synchronous"); google::InitGoogleLogging(argv[0]); FLAGS_stderrthreshold = 0; // INFO: 0, WARNING: 1, ERROR: 2, FATAL: 3 FLAGS_colorlogtostderr = 1; if (argc != 3 && argc != 4) { LOG(ERROR) << "Usage: ./" << argv[0] << " configuration-yaml-file bag-to-read-from [skip-first-seconds]"; return -1; } okvis::Duration deltaT(0.0); if (argc == 4) { deltaT = okvis::Duration(atof(argv[3])); } // set up the node ros::NodeHandle nh("okvis_node"); // publisher okvis::Publisher publisher(nh); // read configuration file std::string configFilename(argv[1]); okvis::RosParametersReader vio_parameters_reader(configFilename); okvis::VioParameters parameters; vio_parameters_reader.getParameters(parameters); okvis::ThreadedKFVio okvis_estimator(parameters); okvis_estimator.setFullStateCallback(std::bind(&okvis::Publisher::publishFullStateAsCallback,&publisher,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4)); okvis_estimator.setLandmarksCallback(std::bind(&okvis::Publisher::publishLandmarksAsCallback,&publisher,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3)); okvis_estimator.setStateCallback(std::bind(&okvis::Publisher::publishStateAsCallback,&publisher,std::placeholders::_1,std::placeholders::_2)); okvis_estimator.setBlocking(true); publisher.setParameters(parameters); // pass the specified publishing stuff // extract the folder path std::string bagname(argv[2]); size_t pos = bagname.find_last_of("/"); std::string path; if (pos == std::string::npos) path = "."; else path = bagname.substr(0, pos); const unsigned int numCameras = parameters.nCameraSystem.numCameras(); // setup files to be written publisher.setCsvFile(path + "/okvis_estimator_output.csv"); publisher.setLandmarksCsvFile(path + "/okvis_estimator_landmarks.csv"); okvis_estimator.setImuCsvFile(path + "/imu0_data.csv"); for (size_t i = 0; i < numCameras; ++i) { std::stringstream num; num << i; okvis_estimator.setTracksCsvFile(i, path + "/cam" + num.str() + "_tracks.csv"); } // open the bag rosbag::Bag bag(argv[2], rosbag::bagmode::Read); // views on topics. the slash is needs to be correct, it's ridiculous... std::string imu_topic("/imu0"); rosbag::View view_imu( bag, rosbag::TopicQuery(imu_topic)); if (view_imu.size() == 0) { LOG(ERROR) << "no imu topic"; return -1; } rosbag::View::iterator view_imu_iterator = view_imu.begin(); LOG(INFO) << "No. IMU messages: " << view_imu.size(); std::vector<std::shared_ptr<rosbag::View> > view_cams_ptr; std::vector<rosbag::View::iterator> view_cam_iterators; std::vector<okvis::Time> times; okvis::Time latest(0); for(size_t i=0; i<numCameras;++i) { std::string camera_topic("/cam"+std::to_string(i)+"/image_raw"); std::shared_ptr<rosbag::View> view_ptr( new rosbag::View( bag, rosbag::TopicQuery(camera_topic))); if (view_ptr->size() == 0) { LOG(ERROR) << "no camera topic"; return 1; } view_cams_ptr.push_back(view_ptr); view_cam_iterators.push_back(view_ptr->begin()); sensor_msgs::ImageConstPtr msg1 = view_cam_iterators[i] ->instantiate<sensor_msgs::Image>(); times.push_back( okvis::Time(msg1->header.stamp.sec, msg1->header.stamp.nsec)); if (times.back() > latest) latest = times.back(); LOG(INFO) << "No. cam " << i << " messages: " << view_cams_ptr.back()->size(); } for(size_t i=0; i<numCameras;++i) { if ((latest - times[i]).toSec() > 0.01) view_cam_iterators[i]++; } int counter = 0; okvis::Time start(0.0); while (ros::ok()) { ros::spinOnce(); okvis_estimator.display(); // check if at the end if (view_imu_iterator == view_imu.end()){ std::cout << std::endl << "Finished. Press any key to exit." << std::endl << std::flush; char k = 0; while(k==0 && ros::ok()){ k = cv::waitKey(1); ros::spinOnce(); } return 0; } for (size_t i = 0; i < numCameras; ++i) { if (view_cam_iterators[i] == view_cams_ptr[i]->end()) { std::cout << std::endl << "Finished. Press any key to exit." << std::endl << std::flush; char k = 0; while(k==0 && ros::ok()){ k = cv::waitKey(1); ros::spinOnce(); } return 0; } } // add images okvis::Time t; for(size_t i=0; i<numCameras;++i) { sensor_msgs::ImageConstPtr msg1 = view_cam_iterators[i] ->instantiate<sensor_msgs::Image>(); cv::Mat filtered(msg1->height, msg1->width, CV_8UC1); memcpy(filtered.data, &msg1->data[0], msg1->height * msg1->width); t = okvis::Time(msg1->header.stamp.sec, msg1->header.stamp.nsec); if (start == okvis::Time(0.0)) { start = t; } // get all IMU measurements till then okvis::Time t_imu=start; do { sensor_msgs::ImuConstPtr msg = view_imu_iterator ->instantiate<sensor_msgs::Imu>(); Eigen::Vector3d gyr(msg->angular_velocity.x, msg->angular_velocity.y, msg->angular_velocity.z); Eigen::Vector3d acc(msg->linear_acceleration.x, msg->linear_acceleration.y, msg->linear_acceleration.z); t_imu = okvis::Time(msg->header.stamp.sec, msg->header.stamp.nsec); // add the IMU measurement for (blocking) processing if (t_imu - start > deltaT) okvis_estimator.addImuMeasurement(t_imu, acc, gyr); view_imu_iterator++; } while (view_imu_iterator != view_imu.end() && t_imu <= t); // add the image to the frontend for (blocking) processing if (t - start > deltaT) okvis_estimator.addImage(t, i, filtered); view_cam_iterators[i]++; } ++counter; // display progress if (counter % 20 == 0) { std::cout << "\rProgress: " << int(double(counter) / double(view_cams_ptr.back()->size()) * 100) << "% " ; } } std::cout << std::endl; return 0; }