本文整理汇总了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() ) );
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}