示例#1
1
文件: model.cpp 项目: 130s/srdfdom
bool srdf::Model::initXml(const urdf::ModelInterface &urdf_model, TiXmlElement *robot_xml)
{
  clear();
  if (!robot_xml || robot_xml->ValueStr() != "robot")
  {
    logError("Could not find the 'robot' element in the xml file");
    return false;
  }
  
  // get the robot name
  const char *name = robot_xml->Attribute("name");
  if (!name)
    logError("No name given for the robot.");
  else
  {
    name_ = std::string(name); boost::trim(name_);
    if (name_ != urdf_model.getName())
      logError("Semantic description is not specified for the same robot as the URDF");
  }
  
  loadVirtualJoints(urdf_model, robot_xml);
  loadGroups(urdf_model, robot_xml);
  loadGroupStates(urdf_model, robot_xml);
  loadEndEffectors(urdf_model, robot_xml); 
  loadLinkSphereApproximations(urdf_model, robot_xml);
  loadDisabledCollisions(urdf_model, robot_xml);
  loadPassiveJoints(urdf_model, robot_xml);
  
  return true;
}
示例#2
0
文件: QyncDB.cpp 项目: beeender/qync
void QyncDB::init(const QString &account, QyncCategoryListModel &groupList)
{
    if (!mBaseDir.isEmpty()) qFatal("QyncDB cannot be inited twice!");

    mBaseDir = QString("%1/%2/%3/").arg(QDir::home().absolutePath(), BASE_DIR,
            QString(QCryptographicHash::hash(account.toUtf8(), QCryptographicHash::Md5).toHex()));
    QDir dir(mBaseDir);
    if (!dir.exists()) dir.mkpath(".");
    mDbPath =  QString("%1%2").arg(mBaseDir, DB_NAME);
    mImageDir = QString("%1%2/").arg(mBaseDir, IMAGE_BASE_DIR);


    mDb = QSqlDatabase::addDatabase("QSQLITE");
    mDb.setDatabaseName(mDbPath);

    if(!mDb.open()) {
        qFatal("QyncDB: Cannot open database. %s", mDb.lastError().text().toStdString().c_str()) ;
    }

    QSqlQuery query;
    if(!query.exec(CREATE_GROUP_TABLE)) {
        qFatal("QyncDB: %s", SQL_ERROR_STR(query.lastError()));
    }
    if(!query.exec(CREATE_BUDDY_TABLE)) {
        qFatal("QyncDB: %s", SQL_ERROR_STR(query.lastError()));
    }

    loadGroups(groupList);
    loadBuddies(groupList);
}
示例#3
0
文件: eod.c 项目: 0x4e38/hyperscan
static really_inline
void initContext(const struct RoseEngine *t, u8 *state, u64a offset,
                 struct hs_scratch *scratch, RoseCallback callback,
                 RoseCallbackSom som_callback, void *ctx) {
    struct RoseRuntimeState *rstate = getRuntimeState(state);
    struct RoseContext *tctxt = &scratch->tctxt;
    tctxt->t = t;
    tctxt->depth = rstate->stored_depth;
    tctxt->groups = loadGroups(t, state); /* TODO: diff groups for eod */
    tctxt->lit_offset_adjust = scratch->core_info.buf_offset
                             - scratch->core_info.hlen
                             + 1; // index after last byte
    tctxt->delayLastEndOffset = offset;
    tctxt->lastEndOffset = offset;
    tctxt->filledDelayedSlots = 0;
    tctxt->state = state;
    tctxt->cb = callback;
    tctxt->cb_som = som_callback;
    tctxt->userCtx = ctx;
    tctxt->lastMatchOffset = 0;
    tctxt->minMatchOffset = 0;
    tctxt->minNonMpvMatchOffset = 0;
    tctxt->next_mpv_offset = 0;
    tctxt->curr_anchored_loc = MMB_INVALID;
    tctxt->curr_row_offset = 0;

    scratch->catchup_pq.qm_size = 0;
    scratch->al_log_sum = 0; /* clear the anchored logs */

    fatbit_clear(scratch->aqa);
}
示例#4
0
void CustomSmileyManager::init( )
{
	// doesn't support import/export to eip package
	tbtnImport->hide();
	tbtnExport->hide();

	// cancel does same job as ok, so hide it for now
	btnCancel->hide();

	lblPreview->setAlignment( TQt::AlignHCenter | TQt::AlignVCenter );

	d = new GroupActionPrivate;
	d->m_Action = GroupActionPrivate::GNone;
	d->m_Item = 0;
	d->m_OldName = "";

	if(m_Config) delete m_Config;
	TQString dir = EvaMain::user->getSetting()->getCustomSmileyDir() + "/";
	m_Config = new CustomFaceConfig(dir);
	m_Config->loadXML();
	// group list first
	loadGroups();

	// init table
	initFaces();

	lvGroups->setSelected( lvGroups->firstChild(), true);
}
示例#5
0
文件: stream.c 项目: 01org/hyperscan
static rose_inline
void roseStreamInitEod(const struct RoseEngine *t, u64a offset,
                       struct hs_scratch *scratch) {
    struct RoseContext *tctxt = &scratch->tctxt;
    /* TODO: diff groups for eod */
    tctxt->groups = loadGroups(t, scratch->core_info.state);
    tctxt->lit_offset_adjust = scratch->core_info.buf_offset
                             - scratch->core_info.hlen
                             + 1; // index after last byte
    tctxt->delayLastEndOffset = offset;
    tctxt->lastEndOffset = offset;
    tctxt->filledDelayedSlots = 0;
    tctxt->lastMatchOffset = 0;
    tctxt->minMatchOffset = offset;
    tctxt->minNonMpvMatchOffset = offset;
    tctxt->next_mpv_offset = offset;

    scratch->catchup_pq.qm_size = 0;
    scratch->al_log_sum = 0; /* clear the anchored logs */

    fatbit_clear(scratch->aqa);
}
示例#6
0
void lmcMessaging::init(XmlMessage *pInitParams) {
	lmcTrace::write("Messaging initialized");

	pNetwork->init(pInitParams);

    QString logonName = Helper::getLogonName();
    QString szAddress = pNetwork->physicalAddress();
    QString userId = createUserId(&szAddress, &logonName);

	pNetwork->setLocalId(&userId);
	
	pSettings = new lmcSettings();
	QString userStatus = pSettings->value(IDS_STATUS, IDS_STATUS_VAL).toString();
	int sIndex = Helper::statusIndexFromCode(userStatus);
	//	if status not recognized, default to available
	if(sIndex < 0)
		userStatus = statusCode[0];
	QString userName = getUserName();

	int nAvatar = pSettings->value(IDS_AVATAR, IDS_AVATAR_VAL).toInt();
	QString userNote = pSettings->value(IDS_NOTE, IDS_NOTE_VAL).toString();
    uint userCaps = UC_File | UC_GroupMessage | UC_Folder;
    localUser = new User(userId, IDA_VERSION, pNetwork->ipAddress, userName, userStatus,
                         QString::null, nAvatar, userNote, StdLocation::avatarFile(),
                         QString::number(userCaps));

	loadGroups();

	nTimeout = pSettings->value(IDS_TIMEOUT, IDS_TIMEOUT_VAL).toInt() * 1000;
	nMaxRetry = pSettings->value(IDS_MAXRETRIES, IDS_MAXRETRIES_VAL).toInt();

	pTimer = new QTimer(this);
	connect(pTimer, SIGNAL(timeout()), this, SLOT(timer_timeout()));
	pTimer->start(1000);

	msgId = 1;
}
示例#7
0
文件: stream.c 项目: 01org/hyperscan
void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch) {
    DEBUG_PRINTF("OH HAI [%llu, %llu)\n", scratch->core_info.buf_offset,
                 scratch->core_info.buf_offset + (u64a)scratch->core_info.len);
    assert(t);
    assert(scratch->core_info.hbuf);
    assert(scratch->core_info.buf);

    // We should not have been called if we've already been told to terminate
    // matching.
    assert(!told_to_stop_matching(scratch));

    assert(mmbit_sparse_iter_state_size(t->rolesWithStateCount)
           < MAX_SPARSE_ITER_STATES);

    size_t length = scratch->core_info.len;
    u64a offset = scratch->core_info.buf_offset;

    // We may have a maximum width (for engines constructed entirely
    // of bi-anchored patterns). If this write would result in us progressing
    // beyond this point, we cannot possibly match.
    if (t->maxBiAnchoredWidth != ROSE_BOUND_INF
        && offset + length > t->maxBiAnchoredWidth) {
        DEBUG_PRINTF("bailing, write would progress beyond maxBAWidth\n");
        return;
    }

    char *state = scratch->core_info.state;

    struct RoseContext *tctxt = &scratch->tctxt;
    tctxt->mpv_inactive = 0;
    tctxt->groups = loadGroups(t, state);
    tctxt->lit_offset_adjust = offset + 1; // index after last byte
    tctxt->delayLastEndOffset = offset;
    tctxt->lastEndOffset = offset;
    tctxt->filledDelayedSlots = 0;
    tctxt->lastMatchOffset = 0;
    tctxt->minMatchOffset = offset;
    tctxt->minNonMpvMatchOffset = offset;
    tctxt->next_mpv_offset = 0;
    DEBUG_PRINTF("BEGIN: history len=%zu, buffer len=%zu groups=%016llx\n",
                 scratch->core_info.hlen, scratch->core_info.len, tctxt->groups);

    fatbit_clear(scratch->aqa);
    scratch->al_log_sum = 0;
    scratch->catchup_pq.qm_size = 0;

    if (t->outfixBeginQueue != t->outfixEndQueue) {
        streamInitSufPQ(t, state, scratch);
    }

    runEagerPrefixesStream(t, scratch);

    u32 alen = t->anchoredDistance > offset ?
        MIN(length + offset, t->anchoredDistance) - offset : 0;

    const struct anchored_matcher_info *atable = getALiteralMatcher(t);
    if (atable && alen) {
        DEBUG_PRINTF("BEGIN ANCHORED %zu/%u\n", scratch->core_info.hlen, alen);
        runAnchoredTableStream(t, atable, alen, offset, scratch);

        if (can_stop_matching(scratch)) {
            goto exit;
        }
    }

    const struct HWLM *ftable = getFLiteralMatcher(t);
    if (ftable) {
        if (t->noFloatingRoots && !roseHasInFlightMatches(t, state, scratch)) {
            DEBUG_PRINTF("skip FLOATING: no inflight matches\n");
            goto flush_delay_and_exit;
        }

        size_t flen = length;
        if (t->floatingDistance != ROSE_BOUND_INF) {
            flen = t->floatingDistance > offset ?
                MIN(t->floatingDistance, length + offset) - offset : 0;
        }

        size_t hlength = scratch->core_info.hlen;

        char rebuild = hlength &&
                       (scratch->core_info.status & STATUS_DELAY_DIRTY) &&
                       (t->maxFloatingDelayedMatch == ROSE_BOUND_INF ||
                        offset < t->maxFloatingDelayedMatch);
        DEBUG_PRINTF("**rebuild %hhd status %hhu mfdm %u, offset %llu\n",
                     rebuild, scratch->core_info.status,
                     t->maxFloatingDelayedMatch, offset);

        if (!flen) {
            if (rebuild) { /* rebuild floating delayed match stuff */
                do_rebuild(t, ftable, scratch);
            }
            goto flush_delay_and_exit;
        }

        if (rebuild) { /* rebuild floating delayed match stuff */
            do_rebuild(t, ftable, scratch);
        }

        if (flen + offset <= t->floatingMinDistance) {
            DEBUG_PRINTF("skip FLOATING: before floating min\n");
            goto flush_delay_and_exit;
        }

        size_t start = 0;
        if (offset < t->floatingMinDistance) {
            // This scan crosses the floating min distance, so we can use that
            // to set HWLM's "start" offset.
            start = t->floatingMinDistance - offset;
        }
        DEBUG_PRINTF("start=%zu\n", start);

        u8 *stream_state;
        if (t->floatingStreamState) {
            stream_state = getFloatingMatcherState(t, state);
        } else {
            stream_state = NULL;
        }

        DEBUG_PRINTF("BEGIN FLOATING (over %zu/%zu)\n", flen, length);
        hwlmExecStreaming(ftable, scratch, flen, start, roseFloatingCallback,
                          scratch, tctxt->groups & t->floating_group_mask,
                          stream_state);
    }

flush_delay_and_exit:
    DEBUG_PRINTF("flushing floating\n");
    if (cleanUpDelayed(t, scratch, length, offset) == HWLM_TERMINATE_MATCHING) {
        return;
    }

exit:
    DEBUG_PRINTF("CLEAN UP TIME\n");
    if (!can_stop_matching(scratch)) {
        ensureStreamNeatAndTidy(t, state, scratch, length, offset);
    }
    DEBUG_PRINTF("DONE STREAMING SCAN, status = %u\n",
                 scratch->core_info.status);
    return;
}