コード例 #1
0
   static void swap_nodes(const node_ptr &this_node, const node_ptr &other_node)
   {
      if (other_node == this_node)
         return;
      bool this_inited  = inited(this_node);
      bool other_inited = inited(other_node);
      if(this_inited){
         init_header(this_node);
      }
      if(other_inited){
         init_header(other_node);
      }

      node_ptr next_this(NodeTraits::get_next(this_node));
      node_ptr prev_this(NodeTraits::get_previous(this_node));
      node_ptr next_other(NodeTraits::get_next(other_node));
      node_ptr prev_other(NodeTraits::get_previous(other_node));
      //these first two swaps must happen before the other two
      swap_prev(next_this, next_other);
      swap_next(prev_this, prev_other);
      swap_next(this_node, other_node);
      swap_prev(this_node, other_node);

      if(this_inited){
         init(other_node);
      }
      if(other_inited){
         init(this_node);
      }
   }
コード例 #2
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_unlock(krb5_context context)
{
    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;
    return ctx_unlock(context, context->dal_handle->db_context);
}
コード例 #3
0
ファイル: CamaraLucida.cpp プロジェクト: Giladx/Camara-Lucida
	void CamaraLucida::update()
	{
		if (!inited())
			return;
				
		if (mesh->is_render_enabled())
			mesh->update();
	}
コード例 #4
0
ファイル: kdb_db2.c プロジェクト: irush-cs/krb5-anonsvn
krb5_error_code
krb5_db2_get_principal(krb5_context context, krb5_const_principal searchfor,
                       unsigned int flags, krb5_db_entry **entry)
{
    krb5_db2_context *dbc;
    krb5_error_code retval;
    DB     *db;
    DBT     key, contents;
    krb5_data keydata, contdata;
    int     trynum, dbret;

    *entry = NULL;
    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;

    dbc = context->dal_handle->db_context;

    for (trynum = 0; trynum < KRB5_DB2_MAX_RETRY; trynum++) {
        if ((retval = ctx_lock(context, dbc, KRB5_LOCKMODE_SHARED))) {
            if (dbc->db_nb_locks)
                return (retval);
            sleep(1);
            continue;
        }
        break;
    }
    if (trynum == KRB5_DB2_MAX_RETRY)
        return KRB5_KDB_DB_INUSE;

    /* XXX deal with wildcard lookups */
    retval = krb5_encode_princ_dbkey(context, &keydata, searchfor);
    if (retval)
        goto cleanup;
    key.data = keydata.data;
    key.size = keydata.length;

    db = dbc->db;
    dbret = (*db->get)(db, &key, &contents, 0);
    retval = errno;
    krb5_free_data_contents(context, &keydata);
    switch (dbret) {
    case 1:
        retval = KRB5_KDB_NOENTRY;
        /* Fall through. */
    case -1:
    default:
        goto cleanup;
    case 0:
        contdata.data = contents.data;
        contdata.length = contents.size;
        retval = krb5_decode_princ_entry(context, &contdata, entry);
        break;
    }

cleanup:
    (void) krb5_db2_unlock(context); /* unlock read lock */
    return retval;
}
コード例 #5
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_iterate(krb5_context context, char *match_expr, ctx_iterate_cb func,
                 krb5_pointer func_arg, krb5_flags iterflags)
{
    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;
    return ctx_iterate(context, context->dal_handle->db_context, func,
                       func_arg, iterflags);
}
コード例 #6
0
ファイル: kdb_db2.c プロジェクト: irush-cs/krb5-anonsvn
krb5_error_code
krb5_db2_iterate(krb5_context context, char *match_expr,
                 krb5_error_code(*func) (krb5_pointer, krb5_db_entry *),
                 krb5_pointer func_arg)
{
    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;
    return ctx_iterate(context, context->dal_handle->db_context, func,
                       func_arg);
}
コード例 #7
0
void MainWindow::onStart()
{
    if (!task_)
    {
        task_ = new DownloadTask(this);
        connect(task_, SIGNAL(inited()), this, SLOT(onInit()));
        connect(task_, SIGNAL(downloadProgress(qint64, qint64, qint64)), this, SLOT(onDownloadProgress(qint64, qint64, qint64)));
        connect(task_, SIGNAL(finished()), this, SLOT(onFinished()));
        task_->init("", "http://ermaopcassist.qiniudn.com/ErmaoPcAssist2.0.0.2.exe", &mgr_);
    }
    task_->start();
}
コード例 #8
0
void
impl::app::process_options(void)
{
    assert(inited());

    std::string optstr;
#if defined(HAVE_GNU_GETOPT)
    optstr += '+'; // Turn on POSIX behavior.
#endif
    optstr += ':';
    {
        options_set opts = options();
        for (options_set::const_iterator iter = opts.begin();
             iter != opts.end(); iter++) {
            const option& opt = (*iter);

            optstr += opt.m_character;
            if (!opt.m_argument.empty())
                optstr += ':';
        }
    }

    int ch;
    const int old_opterr = ::opterr;
    ::opterr = 0;
    while ((ch = ::getopt(m_argc, m_argv, optstr.c_str())) != -1) {
        switch (ch) {
            case 'h':
                m_hflag = true;
                break;

            case ':':
                throw usage_error("Option -%c requires an argument.",
                                  ::optopt);

            case '?':
                throw usage_error("Unknown option -%c.", ::optopt);

            default:
                process_option(ch, ::optarg);
        }
    }
    m_argc -= ::optind;
    m_argv += ::optind;

    // Clear getopt state just in case the test wants to use it.
    opterr = old_opterr;
    optind = 1;
#if defined(HAVE_OPTRESET)
    optreset = 1;
#endif
}
コード例 #9
0
ファイル: kdb_db2.c プロジェクト: irush-cs/krb5-anonsvn
krb5_error_code
krb5_db2_put_principal(krb5_context context, krb5_db_entry *entry,
                       char **db_args)
{
    int     dbret;
    DB     *db;
    DBT     key, contents;
    krb5_data contdata, keydata;
    krb5_error_code retval;
    krb5_db2_context *dbc;

    krb5_clear_error_message (context);
    if (db_args) {
        /* DB2 does not support db_args DB arguments for principal */
        krb5_set_error_message(context, EINVAL,
                               _("Unsupported argument \"%s\" for db2"),
                               db_args[0]);
        return EINVAL;
    }

    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;

    dbc = context->dal_handle->db_context;
    if ((retval = ctx_lock(context, dbc, KRB5_LOCKMODE_EXCLUSIVE)))
        return retval;

    db = dbc->db;

    retval = krb5_encode_princ_entry(context, &contdata, entry);
    if (retval)
        goto cleanup;
    contents.data = contdata.data;
    contents.size = contdata.length;
    retval = krb5_encode_princ_dbkey(context, &keydata, entry->princ);
    if (retval) {
        krb5_free_data_contents(context, &contdata);
        goto cleanup;
    }

    key.data = keydata.data;
    key.size = keydata.length;
    dbret = (*db->put)(db, &key, &contents, 0);
    retval = dbret ? errno : 0;
    krb5_free_data_contents(context, &keydata);
    krb5_free_data_contents(context, &contdata);

cleanup:
    ctx_update_age(dbc);
    (void) krb5_db2_unlock(context); /* unlock database */
    return (retval);
}
コード例 #10
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_get_age(krb5_context context, char *db_name, time_t *age)
{
    krb5_db2_context *dbc;
    struct stat st;

    if (!inited(context))
        return (KRB5_KDB_DBNOTINITED);
    dbc = context->dal_handle->db_context;

    if (fstat(dbc->db_lf_file, &st) < 0)
        *age = -1;
    else
        *age = st.st_mtime;
    return 0;
}
コード例 #11
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_destroy(krb5_context context, char *conf_section, char **db_args)
{
    krb5_error_code status;
    krb5_db2_context *dbc;
    char *dbname = NULL, *lockname = NULL, *polname = NULL, *plockname = NULL;

    if (inited(context)) {
        status = krb5_db2_fini(context);
        if (status != 0)
            return status;
    }

    krb5_clear_error_message(context);
    status = configure_context(context, conf_section, db_args);
    if (status != 0)
        return status;

    status = check_openable(context);
    if (status != 0)
        return status;

    dbc = context->dal_handle->db_context;

    status = ctx_allfiles(dbc, &dbname, &lockname, &polname, &plockname);
    if (status)
        goto cleanup;
    status = destroy_file(dbname);
    if (status)
        goto cleanup;
    status = unlink(lockname);
    if (status)
        goto cleanup;
    status = osa_adb_destroy_db(polname, plockname, OSA_ADB_POLICY_DB_MAGIC);
    if (status)
        return status;

    status = krb5_db2_fini(context);

cleanup:
    free(dbname);
    free(lockname);
    free(polname);
    free(plockname);
    return status;
}
コード例 #12
0
ファイル: data_peer.cpp プロジェクト: zhangsoledad/tdesktop
bool PtsWaiter::check(ChannelData *channel, int32 pts, int32 count) { // return false if need to save that update and apply later
	if (!inited()) {
		init(pts);
		return true;
	}

	_last = qMax(_last, pts);
	_count += count;
	if (_last == _count) {
		_good = _last;
		return true;
	} else if (_last < _count) {
		setWaitingForSkipped(channel, 1);
	} else {
		setWaitingForSkipped(channel, WaitForSkippedTimeout);
	}
	return !count;
}
コード例 #13
0
ファイル: application.cpp プロジェクト: w796933/bind99damp
void
impl::app::usage(std::ostream& os)
{
    PRE(inited());

    std::string args = specific_args();
    if (!args.empty())
        args = " " + args;
    os << ui::format_text_with_tag(std::string(m_prog_name) + " [options]" +
                                   args, "Usage: ", false) << "\n\n"
       << ui::format_text(m_description) << "\n\n";

    options_set opts = options();
    INV(!opts.empty());
    os << "Available options:\n";
    size_t coldesc = 0;
    for (options_set::const_iterator iter = opts.begin();
         iter != opts.end(); iter++) {
        const option& opt = (*iter);

        if (opt.m_argument.length() + 1 > coldesc)
            coldesc = opt.m_argument.length() + 1;
    }
    for (options_set::const_iterator iter = opts.begin();
         iter != opts.end(); iter++) {
        const option& opt = (*iter);

        std::string tag = std::string("    -") + opt.m_character;
        if (opt.m_argument.empty())
            tag += "    ";
        else
            tag += " " + opt.m_argument + "    ";
        os << ui::format_text_with_tag(opt.m_description, tag, false,
                                       coldesc + 10) << "\n";
    }
    os << "\n";

    std::string gmp;
    if (!m_global_manpage.empty())
        gmp = " and " + m_global_manpage;
    os << ui::format_text("For more details please see " + m_manpage +
                          gmp + ".")
       << "\n";
}
コード例 #14
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_open(krb5_context context, char *conf_section, char **db_args,
              int mode)
{
    krb5_error_code status = 0;

    krb5_clear_error_message(context);
    if (inited(context))
        return 0;

    status = configure_context(context, conf_section, db_args);
    if (status != 0)
        return status;

    status = check_openable(context);
    if (status != 0)
        return status;

    return ctx_init(context->dal_handle->db_context);
}
コード例 #15
0
void DownloadTask::load(const QString &path, const QString &infFile, QNetworkAccessManager *netMgr)
{
	Q_ASSERT(state_ == Unvalid);
	path_ = path;
	name_ = infFile.left(infFile.lastIndexOf('.'));
	networkMgr_ = netMgr;
	infoFile_.setFileName(infFile);
	if (!infoFile_.open(QFile::ReadWrite))
	{
		qDebug() << QString(__FUNCTION__) << " " << __LINE__ << " error : " << infoFile_.error();
		return;
	}
	if (infoFile_.size() != 0)
	{
		infoFile_.read((char*)&size_, sizeof(size_));
		infoFile_.read((char*)&progress_, sizeof(progress_));
		url_ = QString::fromUtf8(infoFile_.readAll());
	}
	state_ = Init;
	emit inited();
}
コード例 #16
0
void DownloadTask::init(const QString &savePath, const QString &url, QNetworkAccessManager *netMgr)
{
	Q_ASSERT(state_ == Unvalid);
	path_ = savePath;
	url_ = url;
	networkMgr_ = netMgr;
	splitName();
	infoFile_.setFileName(infoFileFullName());
	if (!infoFile_.open(QFile::ReadWrite))
	{
		qDebug() << QString(__FUNCTION__) << " " << __LINE__ << " error : " << infoFile_.error();
		return;
	}
	if (infoFile_.size() != 0)
	{
		infoFile_.read((char*)&size_, sizeof(size_));
		infoFile_.read((char*)&progress_, sizeof(progress_));
	}
	state_ = Init;
	emit inited();
}
コード例 #17
0
ファイル: CamaraLucida.cpp プロジェクト: Giladx/Camara-Lucida
	void CamaraLucida::dispose()
	{
		ofLog(OF_LOG_VERBOSE, "CamaraLucida::dispose");
		
		if (!inited())
			return;
		
		dispose_events();
		
		mesh->dispose_pts();
		mesh = NULL;
		
		cvReleaseMat(&rgb_int);	
		cvReleaseMat(&depth_int);
		
		cvReleaseMat(&rgb_R);
		cvReleaseMat(&rgb_T);
		
		cvReleaseMat(&proj_int);	
		cvReleaseMat(&proj_R);
		cvReleaseMat(&proj_T);
	}
コード例 #18
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_create(krb5_context context, char *conf_section, char **db_args)
{
    krb5_error_code status = 0;
    krb5_db2_context *dbc;

    krb5_clear_error_message(context);
    if (inited(context))
        return 0;

    status = configure_context(context, conf_section, db_args);
    if (status != 0)
        return status;

    dbc = context->dal_handle->db_context;
    status = ctx_create_db(context, dbc);
    if (status != 0)
        return status;

    if (!dbc->tempdb)
        krb5_db2_unlock(context);

    return 0;
}
コード例 #19
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_delete_principal(krb5_context context, krb5_const_principal searchfor)
{
    krb5_error_code retval;
    krb5_db_entry *entry;
    krb5_db2_context *dbc;
    DB     *db;
    DBT     key, contents;
    krb5_data keydata, contdata;
    int     i, dbret;

    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;

    dbc = context->dal_handle->db_context;
    if ((retval = ctx_lock(context, dbc, KRB5_LOCKMODE_EXCLUSIVE)))
        return (retval);

    if ((retval = krb5_encode_princ_dbkey(context, &keydata, searchfor)))
        goto cleanup;
    key.data = keydata.data;
    key.size = keydata.length;

    db = dbc->db;
    dbret = (*db->get) (db, &key, &contents, 0);
    retval = errno;
    switch (dbret) {
    case 1:
        retval = KRB5_KDB_NOENTRY;
        /* Fall through. */
    case -1:
    default:
        goto cleankey;
    case 0:
        ;
    }
    contdata.data = contents.data;
    contdata.length = contents.size;
    retval = krb5_decode_princ_entry(context, &contdata, &entry);
    if (retval)
        goto cleankey;

    /* Clear encrypted key contents */
    for (i = 0; i < entry->n_key_data; i++) {
        if (entry->key_data[i].key_data_length[0]) {
            memset(entry->key_data[i].key_data_contents[0], 0,
                   (unsigned) entry->key_data[i].key_data_length[0]);
        }
    }

    retval = krb5_encode_princ_entry(context, &contdata, entry);
    krb5_dbe_free(context, entry);
    if (retval)
        goto cleankey;

    contents.data = contdata.data;
    contents.size = contdata.length;
    dbret = (*db->put) (db, &key, &contents, 0);
    retval = dbret ? errno : 0;
    krb5_free_data_contents(context, &contdata);
    if (retval)
        goto cleankey;
    dbret = (*db->del) (db, &key, 0);
    retval = dbret ? errno : 0;
cleankey:
    krb5_free_data_contents(context, &keydata);

cleanup:
    ctx_update_age(dbc);
    (void) krb5_db2_unlock(context); /* unlock write lock */
    return retval;
}
コード例 #20
0
ファイル: kdb_db2.c プロジェクト: DirectXMan12/krb5
krb5_error_code
krb5_db2_promote_db(krb5_context context, char *conf_section, char **db_args)
{
    krb5_error_code retval;
    krb5_boolean merge_nra = FALSE, real_locked = FALSE;
    krb5_db2_context *dbc_temp, *dbc_real = NULL;
    char **db_argp;

    /* context must be initialized with an exclusively locked temp DB. */
    if (!inited(context))
        return KRB5_KDB_DBNOTINITED;
    dbc_temp = context->dal_handle->db_context;
    if (dbc_temp->db_lock_mode != KRB5_LOCKMODE_EXCLUSIVE)
        return KRB5_KDB_NOTLOCKED;
    if (!dbc_temp->tempdb)
        return EINVAL;

    /* Check db_args for whether we should merge non-replicated attributes. */
    for (db_argp = db_args; *db_argp; db_argp++) {
        if (!strcmp(*db_argp, "merge_nra")) {
            merge_nra = TRUE;
            break;
        }
    }

    /* Make a db2 context for the real DB. */
    dbc_real = k5alloc(sizeof(*dbc_real), &retval);
    if (dbc_real == NULL)
        return retval;
    ctx_clear(dbc_real);

    /* Try creating the real DB. */
    dbc_real->db_name = strdup(dbc_temp->db_name);
    if (dbc_real->db_name == NULL)
        goto cleanup;
    dbc_real->tempdb = FALSE;
    retval = ctx_create_db(context, dbc_real);
    if (retval == EEXIST) {
        /* The real database already exists, so open and lock it. */
        dbc_real->db_name = strdup(dbc_temp->db_name);
        if (dbc_real->db_name == NULL)
            goto cleanup;
        dbc_real->tempdb = FALSE;
        retval = ctx_init(dbc_real);
        if (retval)
            goto cleanup;
        retval = ctx_lock(context, dbc_real, KRB5_DB_LOCKMODE_EXCLUSIVE);
        if (retval)
            goto cleanup;
    } else if (retval)
        goto cleanup;
    real_locked = TRUE;

    if (merge_nra) {
        retval = ctx_merge_nra(context, dbc_temp, dbc_real);
        if (retval)
            goto cleanup;
    }

    /* Perform filesystem manipulations for the promotion. */
    retval = ctx_promote(context, dbc_temp, dbc_real);
    if (retval)
        goto cleanup;

    /* Unlock and finalize context since the temp DB is gone. */
    (void) krb5_db2_unlock(context);
    krb5_db2_fini(context);

cleanup:
    if (real_locked)
        (void) ctx_unlock(context, dbc_real);
    if (dbc_real)
        ctx_fini(dbc_real);
    return retval;
}
コード例 #21
0
ファイル: CamaraLucida.cpp プロジェクト: Giladx/Camara-Lucida
	void CamaraLucida::render()
	{
		if (!inited())
			return;
		
		if (mesh->is_render_enabled())
		{
			fbo.bind();
			//ofEnableAlphaBlending();  
			//glEnable(GL_BLEND);  
			//glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA); 
		
			ofNotifyEvent( render_texture, void_event_args );
		
			fbo.unbind();
			//ofDisableAlphaBlending(); 
			//glDisable(GL_BLEND);  
		}
		
		glClearColor(0, 0, 0, 1);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glEnable(GL_DEPTH_TEST);
	
		glPolygonMode(GL_FRONT, GL_FILL);
		// TODO wireframe it's not working with fbo textures.. why?
		// @see cmlMesh.enable_render();
		// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
		
		glColor3f(1, 1, 1);
		glViewport(0, 0, ofGetWidth(), ofGetHeight());
		
		gl_ortho();
		
		ofNotifyEvent( render_hud, void_event_args );
		
		render_screenlog();
		
		gl_projection();	
		gl_viewpoint();
		
		gl_scene_control();
		
		if (_debug)
		{
			render_world_CS();
			render_proj_CS();
			render_rgb_CS();
			render_proj_ppal_point();
		}
		
		//	if (using_opencl)
		//		opencl.finish();
		
		// TODO alpha blending!
		
		//glEnable(GL_BLEND);  
		//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		//glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 
		//glBlendFuncSeparate(GL_ONE, GL_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
		//glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 
		//ofEnableAlphaBlending();
		
		if (mesh->is_render_enabled())
		{
			fbo.getTextureReference(0).bind();
		
			mesh->render();
		
			fbo.getTextureReference(0).unbind();
		}
		
		//glDisable(GL_BLEND);
		//ofDisableAlphaBlending(); 
	}
コード例 #22
0
ファイル: bfvm.cpp プロジェクト: ORBAT/QtBrain
    void BfVM::initializeStateMachine() {
        // see the state chart for a clearer picture of what's going on with the states
        /////////////////////////////////////////////////////////////////////////////////////
        //// STATE NAME INITIALIZATIONS
        ///////////////////////////////
        //: Please don't translate the state names in case I forget to remove the tr()s
        m_stateGroup->setProperty("statename", QVariant::fromValue(tr("main state group")));
        m_runGroup->setProperty("statename", QVariant::fromValue(tr("run state group")));
        m_emptySt->setProperty("statename", QVariant::fromValue(tr("empty VM")));
        m_steppingSt->setProperty("statename", QVariant::fromValue(tr("stepping")));
        m_runningSt->setProperty("statename", QVariant::fromValue(tr("running")));
        m_clearSt->setProperty("statename", QVariant::fromValue(tr("clearing")));
        m_initializedSt->setProperty("statename", QVariant::fromValue(tr("initialized")));
        m_finishedSt->setProperty("statename", QVariant::fromValue(tr("finished")));
        m_waitingForInpSt->setProperty("statename", QVariant::fromValue(
                tr("waiting for input")));
        m_breakpointSt->setProperty("statename", QVariant::fromValue(tr("breakpoint")));
        m_runHistorySt->setProperty("statename", QVariant::fromValue(
                tr("run history state")));


        /////////////////////////////////////////////////////////////////////////////////////
        //// EMPTY STATE
        ////////////////
        /*
         Only transition away from the empty state when the VM is initialized, ie. a
         Brainfuck program is loaded succesfully
          */
        InitedEventTransition *iet = new InitedEventTransition();
        iet->setTargetState(m_initializedSt);
        m_emptySt->addTransition(iet);


        /////////////////////////////////////////////////////////////////////////////////////
        //// INITIALIZED STATE
        //////////////////////
        // reset the VM when the initialized state is entered
        connect(m_initializedSt, SIGNAL(entered()), this, SLOT(reset()));

        // emit inited() when entering the initialized state so the GUI knows we're ready
        connect(m_initializedSt, SIGNAL(entered()), this, SIGNAL(inited()));

        m_initializedSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);
        m_initializedSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// STEPPING STATE
        ///////////////////
        // run step() whenever this state is entered
        connect(m_steppingSt, SIGNAL(entered()), this, SLOT(step()));
        // just loops back to itself when receiving additional stepSig()s
        m_steppingSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        // Transition to running if toggleRunSig() received
        m_steppingSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// RUNNING STATE
        //////////////////
        /* Entering or exiting this state controls whether the run timer is running. */
        connect(m_runningSt, SIGNAL(entered()), this, SLOT(go()));
        connect(m_runningSt, SIGNAL(exited()), this, SLOT(stop()));
        m_runningSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        m_runningSt->addTransition(this, SIGNAL(toggleRunSig()), m_steppingSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// FINISHED STATE
        ///////////////////
        /* the only way to get out of the finished state is to reset or clear the VM.
           finish() is emitted when this state is entered so that the GUI can disable
           actions and whatnot */

        connect(m_finishedSt, SIGNAL(entered()), this, SIGNAL(finish()));
        m_finishedSt->addTransition(this, SIGNAL(resetSig()), m_initializedSt);

        /////////////////////////////////////////////////////////////////////////////////////
        //// WAITING FOR INPUT STATE
        ////////////////////////////

        // signal the GUI that the VM needs input
        connect(m_waitingForInpSt, SIGNAL(entered()), this, SIGNAL(needInput()));

        /* send the same signal when exiting the state, so the GUI can toggle its
           input notification */
        connect(m_waitingForInpSt, SIGNAL(exited()), this, SIGNAL(needInput()));

        /* To get out of the wait state we need either input or a reset/clear.
           Clears are handled by the top state group, but we need to catch the reset
           signal ourselves.
           Transitions back to the correct state of the running state group by using
           m_runGroup's history state */
        InpBufFilledTransition *ibft = new InpBufFilledTransition();
        ibft->setTargetState(m_runHistorySt);
        m_waitingForInpSt->addTransition(ibft);
        m_waitingForInpSt->addTransition(this, SIGNAL(resetted()), m_initializedSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// BREAKPOINT STATE
        /////////////////////
        connect(m_breakpointSt, SIGNAL(entered()), this, SLOT(breakPtTest()));
        m_breakpointSt->addTransition(this, SIGNAL(stepSig()), m_steppingSt);
        m_breakpointSt->addTransition(this, SIGNAL(toggleRunSig()), m_runningSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// CLEARING STATE
        ///////////////////
        connect(m_clearSt, SIGNAL(entered()), this, SLOT(clear()));
        m_clearSt->addTransition(m_emptySt);

        /////////////////////////////////////////////////////////////////////////////////////
        //// TOP STATE GROUP
        ////////////////////
        m_stateGroup->setInitialState(m_emptySt);  // start in the empty state
        // if the clearSig() signal is sent when in any state, go to the clear state
        m_stateGroup->addTransition(this, SIGNAL(clearSig()), m_clearSt);


        /////////////////////////////////////////////////////////////////////////////////////
        //// RUN STATE GROUP
        ////////////////////
        m_runGroup->setInitialState(m_steppingSt); /* the run group always starts in the
                                                      stepping state*/

        /* If the VM is reset while running, go back to the initialized state */
        m_runGroup->addTransition(this, SIGNAL(resetSig()), m_initializedSt);

        // Stop the VM when exiting the run group
        connect(m_runGroup, SIGNAL(exited()), this, SLOT(stop()));

        /* handle an EndEvent in any run state by transitioning to the finished state */
        EndEventTransition *eet = new EndEventTransition();
        eet->setTargetState(m_finishedSt);
        m_runGroup->addTransition(eet);

        /* if the input buffer is empty and the VM needs input, go into the waiting
           for input state */
        InpBufEmptyTransition *ibet = new InpBufEmptyTransition();
        ibet->setTargetState(m_waitingForInpSt);
        m_runGroup->addTransition(ibet);

        // go to the breakpoint state if a breakpoint was reached
        BreakpointTransition *bpt = new BreakpointTransition();
        bpt->setTargetState(m_breakpointSt);
        m_runGroup->addTransition(bpt);



        /////////////////////////////////////////////////////////////////////////////////////
        //// STATE MACHINE INITIALIZATION
        /////////////////////////////////

        m_stateMachine->addState(m_stateGroup);
        m_stateMachine->setInitialState(m_stateGroup);
    }