当前位置: 首页>>代码示例>>C++>>正文


C++ xp函数代码示例

本文整理汇总了C++中xp函数的典型用法代码示例。如果您正苦于以下问题:C++ xp函数的具体用法?C++ xp怎么用?C++ xp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getVertexArray

osgToy::OctoStrip::OctoStrip()
{
    osg::Vec3Array* vAry = dynamic_cast<osg::Vec3Array*>( getVertexArray() );

    osg::Vec3Array* nAry = dynamic_cast<osg::Vec3Array*>( getNormalArray() );
    setNormalBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec4Array* cAry = dynamic_cast<osg::Vec4Array*>( getColorArray() );
    setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    osg::Vec3 xp( 1, 0, 0);   osg::Vec4 red(1,0,0,1);
    osg::Vec3 xn(-1, 0, 0);   osg::Vec4 cyan(0,1,1,1);
    osg::Vec3 yp( 0, 1, 0);   osg::Vec4 green(0,1,0,1);
    osg::Vec3 yn( 0,-1, 0);   osg::Vec4 magenta(1,0,1,1);
    osg::Vec3 zp( 0, 0, 1);   osg::Vec4 blue(0,0,1,1);
    osg::Vec3 zn( 0, 0,-1);   osg::Vec4 yellow(1,1,0,1);

    vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue);
    vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green);
    vAry->push_back(xn); nAry->push_back(xn); cAry->push_back(cyan);
    vAry->push_back(zn); nAry->push_back(zn); cAry->push_back(yellow);
    vAry->push_back(yn); nAry->push_back(yn); cAry->push_back(magenta);
    vAry->push_back(xp); nAry->push_back(xp); cAry->push_back(red);
    vAry->push_back(zp); nAry->push_back(zp); cAry->push_back(blue);
    vAry->push_back(yp); nAry->push_back(yp); cAry->push_back(green);

    addPrimitiveSet( new osg::DrawArrays( GL_TRIANGLE_STRIP, 0, vAry->size() ) );
}
开发者ID:mew-cx,项目名称:osgtoy,代码行数:28,代码来源:Polyhedra.cpp

示例2: fopen

void DAILY_XFER_HISTORY::init() {
    FILE* f = fopen(DAILY_XFER_HISTORY_FILENAME, "r");
    if (!f) return;

    MIOFILE mf;
    XML_PARSER xp(&mf);
    mf.init_file(f);
    bool is_tag;
    char tag[256];

    int d = current_day();

    if (!xp.parse_start("daily_xfers")) {
        fclose(f);
        return;
    }
    while (!xp.get(tag, sizeof(tag), is_tag)) {
        if (!is_tag) continue;
        if (!strcmp(tag, "dx")) {
            DAILY_XFER dx;
            int retval = dx.parse(xp);
            if (!retval && d - dx.when < 365) {
                // discard records after a year
                daily_xfers.push_back(dx);
            }
        }
    }
    fclose(f);
}
开发者ID:BME-IK,项目名称:gridbee-nacl-framework,代码行数:29,代码来源:net_stats.cpp

示例3: xp

int APP_CONFIGS::parse_file(FILE* f, PROJECT* p) {
    MIOFILE mf;
    XML_PARSER xp(&mf);
    mf.init_file(f);
    int retval = parse(xp, p);
    return retval;
}
开发者ID:justinlynn,项目名称:boinc-v2,代码行数:7,代码来源:app_config.cpp

示例4: xp

inline void KillRewarder::_RewardXP(Player* player, float rate)
{
    uint32 xp(_xp);
    if (_group)
    {
        // 4.2.1. If player is in group, adjust XP:
        //        * set to 0 if player's level is more than maximum level of not gray member;
        //        * cut XP in half if _isFullXP is false.
        if (_maxNotGrayMember && player->IsAlive() &&
            _maxNotGrayMember->getLevel() >= player->getLevel())
            xp = _isFullXP ?
            uint32(xp * rate) :             // Reward FULL XP if all group members are not gray.
            uint32(xp * rate / 2) + 1;      // Reward only HALF of XP if some of group members are gray.
        else
            xp = 0;
    }
    if (xp)
    {
        // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT).
        for (auto const& aura : player->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT))
            AddPct(xp, aura->GetAmount());

        // 4.2.3. Give XP to player.
        player->GiveXP(xp, _victim, _groupRate);
        if (Pet* pet = player->GetPet())
            // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
            pet->GivePetXP(_group ? xp / 2 : xp);
    }
}
开发者ID:boom8866,项目名称:MaddieCore,代码行数:29,代码来源:KillRewarder.cpp

示例5: xp

bool ApService::InitApService(std::string ApListenIp, int ApListenPort, int threadPoolNum) {
    bool status = true;

    _ApListenIp = ApListenIp;
    _ApListenPort = ApListenPort;
    _threadPoolNum = threadPoolNum;

    SharedPointer<IProcessor> xp(
        new apapiProcessor(
            SharedPointer<apapi>(
                new ApService)));

    ServiceManager sm;
    sm.add_service(xp);

    ThreadPool tp;
    tp.init(_threadPoolNum);
    Server* server = new Server(&sm, &tp, _ApListenPort);

    if (0 != server->serve()) {
        status =  false;
    }

    return status;
}
开发者ID:AaronZhangL,项目名称:CC,代码行数:25,代码来源:ApService.cpp

示例6: wxGetApp

void CDlgDiagnosticLogFlags::OnOK(wxCommandEvent& event) {
    SET_LOCALE sl;
    char buf[64000];
    MIOFILE mf;
    bool val;
    unsigned int i;
    CMainDocument* pDoc = wxGetApp().GetDocument();

    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));

    mf.init_buf_write(buf, sizeof(buf));
    for (i=0; i<m_checkbox_list.size(); ++i) {
        wxCheckBox* ckbox = m_checkbox_list[i];
        val = ckbox->GetValue();
        mf.printf("        <%s>%d</%s>\n", (const char*)ckbox->GetLabel().ToAscii(), (int)val, (const char*)ckbox->GetLabel().ToAscii());
    }
    mf.printf("    </log_flags>\n");

    XML_PARSER xp(&mf);
    mf.init_buf_read(buf);
    log_flags.parse(xp);
    
    int retval = pDoc->rpc.set_cc_config(m_cc_config, log_flags);
    if (!retval) {
        pDoc->rpc.read_cc_config();
    }
    event.Skip();
}
开发者ID:Ashod,项目名称:Boinc,代码行数:29,代码来源:DlgDiagnosticLogFlags.cpp

示例7: xp

inline void KillRewarder::_RewardXP(Player* player, float rate)
{
    uint32 xp(_xp);
    if (_group)
    {
        // 4.2.1. If player is in group, adjust XP:
        //        * set to 0 if player's level is more than maximum level of not gray member;
        //        * cut XP in half if _isFullXP is false.
        if (_maxNotGrayMember && player->IsAlive() &&
                _maxNotGrayMember->getLevel() >= player->getLevel())
            xp = _isFullXP ?
                 uint32(xp * rate) :             // Reward FULL XP if all group members are not gray.
                 uint32(xp * rate / 2) + 1;      // Reward only HALF of XP if some of group members are gray.
        else
            xp = 0;
    }
    if (xp)
    {
        // 4.2.2. Apply auras modifying rewarded XP (SPELL_AURA_MOD_XP_PCT and SPELL_AURA_MOD_XP_FROM_CREATURE_TYPE).
        xp *= player->GetTotalAuraMultiplier(SPELL_AURA_MOD_XP_PCT);
        xp *= player->GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_XP_FROM_CREATURE_TYPE, int32(_victim->GetCreatureType()));

        // 4.2.3. Give XP to player.
        player->GiveXP(xp, _victim, _groupRate);
        if (Pet* pet = player->GetPet())
            // 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
            pet->GivePetXP(_group ? xp / 2 : xp);
    }
}
开发者ID:m7nu3l,项目名称:TrinityCore,代码行数:29,代码来源:KillRewarder.cpp

示例8: handle_trickle

int handle_trickle(MSG_FROM_HOST& msg) {
    double runtime = 0;
    MIOFILE mf;

    mf.init_buf_read(msg.xml);
    XML_PARSER xp(&mf);

    while (!xp.get_tag()) {
        if (xp.parse_double("runtime", runtime)) break;
        log_messages.printf(MSG_NORMAL, "unexpected tag: %s\n", xp.parsed_tag);
    }
    if (runtime <= 0) {
        log_messages.printf(MSG_NORMAL,
            "unexpected nonpositive runtime: %f\n", runtime
        );
        return ERR_XML_PARSE;
    }

    DB_HOST host;
    int retval = host.lookup_id(msg.hostid);
    if (retval) return retval;
    HOST old_host = host;

    double flops_sec = host.p_fpops;

    // sanity checks - customize as needed
    //
    if (runtime > max_runtime) {
        log_messages.printf(MSG_NORMAL,
            "Reported runtime exceeds bound: %f>%f\n", runtime, max_runtime
        );
        runtime = max_runtime;
    }
    if (flops_sec < 0) {
        log_messages.printf(MSG_NORMAL,
            "host CPU speed %f < 0.  Using %f instead\n",
            flops_sec, flops_50_percentile
        );
        flops_sec = flops_50_percentile;
    }
    if (flops_sec > flops_95_percentile) {
        log_messages.printf(MSG_NORMAL,
            "host CPU speed %f exceeds %f.  Using %f instead\n",
            flops_sec, flops_95_percentile, flops_95_percentile
        );
        flops_sec = flops_95_percentile;
    }
    double credit = cpu_time_to_credit(runtime, flops_sec);
    grant_credit(host, dtime()-86400, credit);
    log_messages.printf(MSG_DEBUG,
        "granting %f credit to host %lu\n", credit, host.id
    );

    // update the host's credit fields
    //
    retval = host.update_diff_validator(old_host);

    return 0;
}
开发者ID:FoxKyong,项目名称:boinc,代码行数:59,代码来源:trickle_credit.cpp

示例9: clear

int ACCT_MGR_INFO::init() {
    MIOFILE mf;
    FILE*   p;
    int retval;

    clear();
    p = fopen(ACCT_MGR_URL_FILENAME, "r");
    if (!p) {
        // if not using acct mgr, make sure projects not flagged,
        // otherwise won't be able to detach them.
        //
        for (unsigned int i=0; i<gstate.projects.size(); i++) {
            gstate.projects[i]->attached_via_acct_mgr = false;
        }
        return 0;
    }
    mf.init_file(p);
    XML_PARSER xp(&mf);
    if (!xp.parse_start("acct_mgr_login")) {
        //
    }
    while (!xp.get_tag()) {
        if (!xp.is_tag) {
            printf("unexpected text: %s\n", xp.parsed_tag);
            continue;
        }
        if (xp.match_tag("/acct_mgr")) break;
        else if (xp.parse_str("name", project_name, 256)) continue;
        else if (xp.parse_str("url", master_url, 256)) continue;
        else if (xp.parse_bool("send_gui_rpc_info", send_gui_rpc_info)) continue;
        else if (xp.match_tag("signing_key")) {
            retval = xp.element_contents("</signing_key>", signing_key, sizeof(signing_key));
            if (retval) {
                msg_printf(NULL, MSG_INFO,
                    "error parsing <signing_key> in acct_mgr_url.xml"
                );
            }
            continue;
        }
        else if (xp.parse_bool("cookie_required", cookie_required)) continue;
        else if (xp.parse_str("cookie_failure_url", cookie_failure_url, 256)) continue;
        if (log_flags.unparsed_xml) {
            msg_printf(NULL, MSG_INFO,
                "[unparsed_xml] ACCT_MGR_INFO::init: unrecognized %s",
                xp.parsed_tag
            );
        }
        xp.skip_unexpected(log_flags.unparsed_xml, "ACCT_MGR_INFO::init");
    }
    fclose(p);

    p = fopen(ACCT_MGR_LOGIN_FILENAME, "r");
    if (p) {
        parse_login_file(p);
        fclose(p);
    }
    return 0;
}
开发者ID:TsvikDmitry,项目名称:boinc,代码行数:58,代码来源:acct_mgr.cpp

示例10: convexhull

vector<P> convexhull(vector<P> v) { // v.SZ >= 2
    sort(v.begin(), v.end());
    vector<Vect> u;
    for (int i = 1; i < (int)v.SZ; i++)
        u.PB(Vect(v[i], v[0]));
    sort(u.begin(), u.end());
    vector<P> w(v.SZ, v[0]);
    int j = 1;  w[1] = u[0].p;
    for (int i = 1; i < (int)u.SZ; i++) {
        T t = xp(w[j-1], w[j], u[i].p);
        for (j--; t < 0 && j > 0; j--)
            t = xp(w[j-1], w[j], u[i].p);
        j += t > 0 ? 2 : 1;
        w[j] = u[i].p;
    }
    w.resize(j+1);
    return w;
}
开发者ID:rhaps0dy,项目名称:UPF-SWERC,代码行数:18,代码来源:Convex+Hull.cpp

示例11: xp

int CERT_SIGS::parse_buffer(char* buf) {
    MIOFILE mf;
    int retval;

    mf.init_buf_read(buf);
    XML_PARSER xp(&mf);
    retval = this->parse(xp);
    return retval;
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:9,代码来源:cert_sig.cpp

示例12: posfun

dvar_vector posfun(const dvar_vector& x, const double& eps, dvariable& pen)
  {
    int i;
    dvar_vector xp(x.indexmin(),x.indexmax());
    for(i=x.indexmin();i<=x.indexmax();i++)
    {
        if(x(i)>=eps)
        {
            xp(i) = x(i);
        }
        else
        {
            pen += 0.01*square(x(i)-eps);
            xp(i) = eps/(2.-x(i)/eps);
        }
    }
    return(xp);
  }
开发者ID:hhamazaki,项目名称:cstar,代码行数:18,代码来源:generic.cpp

示例13: xp

static void xp(XmlNode *x, int level, int max)
{
	int i;
	char text[] = "text";
	char *name = text;
	if(level > max)return;
	if(!x)return;
	if(x->name)name = x->name;
	for(i=0; i<level; i++)printf("    ");
	printf("%s:", name);
	if(x->name)
	for(i=0; i<x->nattrib; i++)
		printf("%s=\"%s\",", x->attrib[i*2], x->attrib[i*2+1]);
	else printf("%s", x->attrib[0]);
	printf("\n");
	if(x->child)xp(x->child, level+1, max);
	if(x->next)xp(x->next, level, max);
}
开发者ID:csesteban,项目名称:ccan,代码行数:18,代码来源:run.c

示例14: xp

int ACCT_MGR_INFO::parse_login_file(FILE* p) {
    MIOFILE mf;
    int retval;

    mf.init_file(p);
    XML_PARSER xp(&mf);
    if (!xp.parse_start("acct_mgr_login")) {
        msg_printf(NULL, MSG_INTERNAL_ERROR,
            "missing start tag in account manager login file"
        );
    }
    while (!xp.get_tag()) {
        if (!xp.is_tag) {
            printf("unexpected text: %s\n", xp.parsed_tag);
            continue;
        }
        if (xp.match_tag("/acct_mgr_login")) break;
        else if (xp.parse_str("login", login_name, 256)) continue;
        else if (xp.parse_str("password_hash", password_hash, 256)) continue;
        else if (xp.parse_str("previous_host_cpid", previous_host_cpid, sizeof(previous_host_cpid))) continue;
        else if (xp.parse_double("next_rpc_time", next_rpc_time)) continue;
        else if (xp.match_tag("opaque")) {
            retval = xp.element_contents("</opaque>", opaque, sizeof(opaque));
            if (retval) {
                msg_printf(NULL, MSG_INFO,
                    "error parsing <opaque> in acct_mgr_login.xml"
                );
            }
            continue;
        }
        else if (xp.match_tag("sched_req_opaque")) {
            char buf[65536];
            retval = xp.element_contents(
                "</sched_req_opaque>", buf, sizeof(buf)
            );
            if (retval) {
                msg_printf(NULL, MSG_INFO,
                    "error parsing <sched_req_opaque> in acct_mgr_login.xml"
                );
            }
            sched_req_opaque = string(buf);
            continue;
        }
        else if (xp.parse_bool("no_project_notices", no_project_notices)) continue;
        if (log_flags.unparsed_xml) {
            msg_printf(NULL, MSG_INFO,
                "[unparsed_xml] unrecognized %s in acct_mgr_login.xml",
                xp.parsed_tag
            );
        }
        xp.skip_unexpected(
            log_flags.unparsed_xml, "ACCT_MGR_INFO::parse_login_file"
        );
    }
    return 0;
}
开发者ID:FoxKyong,项目名称:boinc,代码行数:56,代码来源:acct_mgr.cpp

示例15: distance2

// calculate distance line-point
double distance2(double x,double y,double z, const double *p) {
   // distance line point is D= | (xp-x0) cross  ux |
   // where ux is direction of line and x0 is a point in the line (like t = 0)
   ROOT::Math::XYZVector xp(x,y,z);
   ROOT::Math::XYZVector x0(p[0], p[2], 0. );
   ROOT::Math::XYZVector x1(p[0] + p[1], p[2] + p[3], 1. );
   ROOT::Math::XYZVector u = (x1-x0).Unit();
   double d2 = ((xp-x0).Cross(u)) .Mag2();
   return d2;
}
开发者ID:thefengman,项目名称:lbl_gem_tpc,代码行数:11,代码来源:helper_functions.cpp


注:本文中的xp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。