本文整理汇总了C++中Globals类的典型用法代码示例。如果您正苦于以下问题:C++ Globals类的具体用法?C++ Globals怎么用?C++ Globals使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Globals类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FuncScopeVariableEnvironment
FuncScopeVariableEnvironment::
FuncScopeVariableEnvironment(const FunctionStatement *func)
: m_func(func), m_staticEnv(NULL), m_argc(0),
m_argStart(RequestEvalState::argStack().pos()) {
const Block::VariableIndices &vi = func->varIndices();
const vector<string> &vars = func->variables();
m_byIdx.resize(vi.size());
Globals *g = NULL;
for (int i = vars.size() - 1; i >= 0; i--) {
const string &name = vars[i];
Block::VariableIndices::const_iterator it = vi.find(name);
ASSERT(it != vi.end());
if (it == vi.end()) continue;
const VariableIndex &v = it->second;
String sname(name.c_str(), name.size(), AttachLiteral);
if (v.superGlobal() != VariableIndex::Normal &&
v.superGlobal() != VariableIndex::Globals) {
if (!g) g = get_globals();
// This is safe because superglobals are real members of the globals
// and do not live in an array
m_byIdx[v.idx()] = &g->get(sname);
} else {
Variant &val = m_alist.prepend(sname);
m_byIdx[v.idx()] = &val;
if (v.superGlobal() == VariableIndex::Globals) {
val = get_global_array_wrapper();
}
}
}
}
示例2: info_
Shake::Shake(SimInfo* info) : info_(info), maxConsIteration_(10),
consTolerance_(1.0e-6), doShake_(false),
currConstraintTime_(0.0) {
if (info_->getNGlobalConstraints() > 0)
doShake_ = true;
if (!doShake_) return;
Globals* simParams = info_->getSimParams();
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
if (simParams->haveConstraintTime()){
constraintTime_ = simParams->getConstraintTime();
} else {
constraintTime_ = simParams->getStatusTime();
}
constraintOutputFile_ = getPrefix(info_->getFinalConfigFileName()) +
".constraintForces";
// create ConstraintWriter
constraintWriter_ = new ConstraintWriter(info_,
constraintOutputFile_.c_str());
if (!constraintWriter_){
sprintf(painCave.errMsg, "Failed to create ConstraintWriter\n");
painCave.isFatal = 1;
simError();
}
}
示例3: FuncScopeVariableEnvironment
FuncScopeVariableEnvironment::
FuncScopeVariableEnvironment(const FunctionStatement *func, int argc)
: m_func(func), m_staticEnv(NULL), m_argc(argc),
m_argStart(RequestEvalState::argStack().pos()) {
const Block::VariableIndices &vi = func->varIndices();
m_byIdx.resize(vi.size());
Globals *g = NULL;
for (Block::VariableIndices::const_iterator it = vi.begin();
it != vi.end(); ++it) {
const VariableIndex &v = it->second;
if (v.superGlobal() != VariableIndex::Normal &&
v.superGlobal() != VariableIndex::Globals) {
if (!g) g = get_globals();
// This is safe because superglobals are real members of the globals
// and do not live in an array
m_byIdx[v.idx()] = &g->get(String(it->first.c_str(), it->first.size(),
AttachLiteral), v.hash());
} else {
Variant &val = m_alist.prepend(String(it->first.c_str(),
it->first.size(),
AttachLiteral));
m_byIdx[v.idx()] = &val;
if (v.superGlobal() == VariableIndex::Globals) {
val = get_global_array_wrapper();
}
}
}
}
示例4: EndAnalyze
void FittingAnalyzer::Analyze(Trace &trace, const std::string &detType,
const std::string &detSubtype,
const std::map<std::string, int> & tagMap) {
TraceAnalyzer::Analyze(trace, detType, detSubtype, tagMap);
if(trace.HasValue("saturation") || trace.empty() ||
trace.GetWaveform().size() == 0) {
EndAnalyze();
return;
}
Globals *globals = Globals::get();
const double sigmaBaseline = trace.GetValue("sigmaBaseline");
const double maxVal = trace.GetValue("maxval");
const double qdc = trace.GetValue("qdc");
const double maxPos = trace.GetValue("maxpos");
const vector<double> waveform = trace.GetWaveform();
bool isDblBeta = detType == "beta" && detSubtype == "double";
bool isDblBetaT = isDblBeta && tagMap.find("timing") != tagMap.end();
trace.plot(D_SIGMA, sigmaBaseline*100);
if(!isDblBetaT) {
if(sigmaBaseline > globals->sigmaBaselineThresh()) {
EndAnalyze();
return;
}
} else {
if(sigmaBaseline > globals->siPmtSigmaBaselineThresh()) {
EndAnalyze();
return;
}
}
pair<double,double> pars = globals->fitPars(detType+":"+detSubtype);
if(isDblBetaT)
pars = globals->fitPars(detType+":"+detSubtype+":timing");
FitDriver *driver;
switch(fitterType_) {
case FitDriver::GSL:
driver = new GslFitter(isDblBetaT);
break;
case FitDriver::UNKNOWN:
default:
EndAnalyze();
return;
}
driver->PerformFit(waveform, pars, sigmaBaseline, qdc);
trace.InsertValue("phase", driver->GetPhase()+maxPos);
trace.plot(DD_AMP, driver->GetAmplitude(), maxVal);
trace.plot(D_PHASE, driver->GetPhase()*1000+100);
trace.plot(D_CHISQPERDOF, driver->GetChiSqPerDof());
delete(driver);
EndAnalyze();
}
示例5: initAL
void initAL(AssocList &al) const {
Globals *g = get_globals();
for (int i = 0; i < s_num-1; i++) {
al.prepend(s_names[i]) = ref(g->get(s_names[i], s_hashes[i]));
}
al.prepend("GLOBALS") = get_global_array_wrapper();
}
示例6: SceneManager
bool SceneLoader::loadScene()
{
TiXmlElement *globalElement = root->FirstChildElement("globals");
TiXmlElement *viewElement = root->FirstChildElement("view");
TiXmlElement *illumElement = root->FirstChildElement("illumination");
if(globalElement == NULL){
cout << "> Error: Globals tag not found!\n" << endl;
return false;
}
if(viewElement == NULL){
cout << "> Error: View tag not found!\n" << endl;
return false;
}
if(illumElement == NULL){
cout << "> Error: Illumination tag not found!\n" << endl;
return false;
}
sceneManager = new SceneManager();
cout << "> loading Globals..." << endl;
Globals* globals = loadGlobals(globalElement);
if(!(sceneManager->setGlobals(globals))){
return false;
}
cout << "> Globals successfully loaded" << endl << endl;
maxLights = globals->getMaxLights();
maxMaterials = globals->getMaxMaterials();
maxTextures = globals->getMaxTextures();
maxObjects = globals->getMaxObjects();
cout << "> loading View..." << endl;
if(!(sceneManager->setView(loadView(viewElement))))
return false;
cout << "> View successfully loaded" << endl << endl;
cout << "> loading Illumination..." << endl;
if(!(sceneManager->setIllumination(loadIllumination(illumElement))))
return false;
cout << "> Illumination successfully loaded" << endl << endl;
cout << "> loading Materials..." << endl;
if(!loadMaterials())
return false;
cout << "> Materials successfully loaded" << endl << endl;
cout << "> loading Textures..." << endl;
if(!loadTextures())
return false;
cout << "> Textures successfully loaded" << endl << endl;
cout << "> loading Objects..." << endl;
if(!loadObjects())
return false;
cout << "> Objects successfully loaded!" << endl << endl;
return true;
}
示例7: VelocityVerletIntegrator
NPT::NPT(SimInfo* info) :
VelocityVerletIntegrator(info), etaTolerance(1e-6), chiTolerance(1e-6),
maxIterNum_(4) {
Globals* simParams = info_->getSimParams();
if (!simParams->getUseIntialExtendedSystemState()) {
Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
currSnapshot->setThermostat(make_pair(0.0, 0.0));
currSnapshot->setBarostat(Mat3x3d(0.0));
}
if (!simParams->haveTargetTemp()) {
sprintf(painCave.errMsg, "You can't use the NVT integrator without a targetTemp!\n");
painCave.isFatal = 1;
painCave.severity = OPENMD_ERROR;
simError();
} else {
targetTemp = simParams->getTargetTemp();
}
// We must set tauThermostat
if (!simParams->haveTauThermostat()) {
sprintf(painCave.errMsg, "If you use the constant temperature\n"
"\tintegrator, you must set tauThermostat.\n");
painCave.severity = OPENMD_ERROR;
painCave.isFatal = 1;
simError();
} else {
tauThermostat = simParams->getTauThermostat();
}
if (!simParams->haveTargetPressure()) {
sprintf(painCave.errMsg, "NPT error: You can't use the NPT integrator\n"
" without a targetPressure!\n");
painCave.isFatal = 1;
simError();
} else {
targetPressure = simParams->getTargetPressure();
}
if (!simParams->haveTauBarostat()) {
sprintf(painCave.errMsg,
"If you use the NPT integrator, you must set tauBarostat.\n");
painCave.severity = OPENMD_ERROR;
painCave.isFatal = 1;
simError();
} else {
tauBarostat = simParams->getTauBarostat();
}
tt2 = tauThermostat * tauThermostat;
tb2 = tauBarostat * tauBarostat;
updateSizes();
}
示例8: OutputEntryFunction
void CLOutputMgr::OutputEntryFunction(Globals& globals) {
// Would ideally use the ExtensionMgr, but there is no way to set it to our
// own custom made one (without modifying the code).
std::ostream& out = get_main_out();
out << "__kernel void entry(__global ulong *result";
if (CLOptions::atomics()) {
out << ", __global volatile uint *g_atomic_input";
out << ", __global volatile uint *g_special_values";
}
if (CLOptions::atomic_reductions()) {
out << ", __global volatile int *g_atomic_reduction";
}
if (CLOptions::emi())
out << ", __global int *emi_input";
if (CLOptions::fake_divergence())
out << ", __global int *sequence_input";
if (CLOptions::inter_thread_comm())
out << ", __global long *g_comm_values";
out << ") {" << std::endl;
globals.OutputArrayControlVars(out);
globals.OutputBufferInits(out);
globals.OutputStructInit(out);
// Block all threads before entering to ensure the local buffers have been
// initialised.
output_tab(out, 1);
StatementBarrier::OutputBarrier(out);
out << std::endl;
output_tab(out, 1);
out << "func_1(";
globals.GetGlobalStructVar().Output(out);
out << ");" << std::endl;
// If using message passing, check and update constraints to prevent deadlock.
if (CLOptions::message_passing())
MessagePassing::OutputMessageEndChecks(out);
// Block all threads after, to prevent hashing stale values.
output_tab(out, 1);
StatementBarrier::OutputBarrier(out);
out << std::endl;
// Handle hashing and outputting.
output_tab(out, 1);
out << "uint64_t crc64_context = 0xFFFFFFFFFFFFFFFFUL;" << std::endl;
output_tab(out, 1);
out << "int print_hash_value = 0;" << std::endl;
HashGlobalVariables(out);
if (CLOptions::atomics())
ExpressionAtomic::OutputHashing(out);
if (CLOptions::inter_thread_comm()) StatementComm::HashCommValues(out);
output_tab(out, 1);
out << "result[get_linear_global_id()] = crc64_context ^ 0xFFFFFFFFFFFFFFFFUL;"
<< std::endl;
out << "}" << std::endl;
}
示例9: Analyze
void CfdAnalyzer::Analyze(Trace &trace, const std::string &detType,
const std::string &detSubtype,
const std::map<std::string, int> & tagMap) {
TraceAnalyzer::Analyze(trace, detType, detSubtype, tagMap);
Globals *globals = Globals::get();
unsigned int saturation = (unsigned int)trace.GetValue("saturation");
if(saturation > 0) {
EndAnalyze();
return;
}
double aveBaseline = trace.GetValue("baseline");
unsigned int maxPos = (unsigned int)trace.GetValue("maxpos");
pair<unsigned int, unsigned int> range = globals->waveformRange("default");
unsigned int waveformLow = range.first;
unsigned int waveformHigh = range.second;
unsigned int delay = 2;
double fraction = 0.25;
vector<double> cfd;
Trace::iterator cfdStart = trace.begin();
advance(cfdStart, (int)(maxPos - waveformLow - 2));
Trace::iterator cfdStop = trace.begin();
advance(cfdStop, (int)(maxPos + waveformHigh));
for(Trace::iterator it = cfdStart; it != cfdStop; it++) {
Trace::iterator it0 = it;
advance(it0, delay);
double origVal = *it;
double transVal = *it0;
cfd.insert(cfd.end(), fraction *
(origVal - transVal - aveBaseline));
}
vector<double>::iterator cfdMax =
max_element(cfd.begin(), cfd.end());
vector<double> fitY;
fitY.insert(fitY.end(), cfd.begin(), cfdMax);
fitY.insert(fitY.end(), *cfdMax);
vector<double>fitX;
for(unsigned int i = 0; i < fitY.size(); i++)
fitX.insert(fitX.end(), i);
double num = fitY.size();
double sumXSq = 0, sumX = 0, sumXY = 0, sumY = 0;
for(unsigned int i = 0; i < num; i++) {
sumXSq += fitX.at(i)*fitX.at(i);
sumX += fitX.at(i);
sumY += fitY.at(i);
sumXY += fitX.at(i)*fitY.at(i);
}
double deltaPrime = num*sumXSq - sumX*sumX;
double intercept =
(1/deltaPrime)*(sumXSq*sumY - sumX*sumXY);
double slope =
(1/deltaPrime)*(num*sumXY - sumX*sumY);
trace.InsertValue("phase", (-intercept/slope)+maxPos);
EndAnalyze();
}
示例10:
void
ConfigureKeys::on_exit()
{
#ifndef DISABLE_LIBSIGC
Globals g;
g.render().DeleteTexture(m_bg);
SDL_EnableKeyRepeat(0, 0); // 0,0 disables key-repeat
m_con_active.clear();
m_con_passive.clear();
#endif // DISABLE_LIBSIGC
}
示例11: NPT
NgammaT::NgammaT(SimInfo* info) : NPT(info) {
Globals* simParams = info_->getSimParams();
if (!simParams->haveSurfaceTension()) {
sprintf(painCave.errMsg,
"If you use the NgammaT integrator, you must set a surface tension.\n");
painCave.severity = OPENMD_ERROR;
painCave.isFatal = 1;
simError();
} else {
surfaceTension= simParams->getSurfaceTension()* PhysicalConstants::surfaceTensionConvert * PhysicalConstants::energyConvert;
}
}
示例12: get_main_out
void CLOutputMgr::Output() {
std::ostream &out = get_main_out();
OutputStructUnionDeclarations(out);
// Type of message_t, for message passing.
if (CLOptions::message_passing())
MessagePassing::OutputMessageType(out);
Globals *globals = Globals::GetGlobals();
globals->OutputStructDefinition(out);
globals->ModifyGlobalVariableReferences();
globals->AddGlobalStructToAllFunctions();
OutputForwardDeclarations(out);
OutputFunctions(out);
OutputEntryFunction(*globals);
}
示例13: createSpecialItemVertical
Item* Globals::createSpecialItemVertical(std::string name, unsigned int value)
{
// 8 est la taille de "Vertical"
std::string basic_name(name.substr(0, name.size() - 8));
Item* item(new SpecialItemVertical(basic_name, value));
item->setTexture(*globals.getTextureManager().getResource(name));
return item;
}
示例14: next_state
void
Outro::on_draw()
{
if (m_snd_game_exit != NULL)
{
if (timer_elapsed() > static_cast<unsigned int>(m_snd_game_exit->length_in_ms) + 100)
{
next_state();
}
}
Globals g;
g.render().DrawTile(0,0, g.values().res_w(), g.values().res_h(), m_img_mainmenu);
string text1 = g.snd2txt().text();
string text2 = "";
if (text1.length() >= 25)
{
text2 = text1;
text1.erase(25, string::npos);
text2.erase(0, 25);
}
g.render().DrawText(500, 400, 1.0, 1.0, 1.0, text1);
g.render().DrawText(500, 450, 1.0, 1.0, 1.0, text2);
}
示例15: mParent
/**
* \class na::ViewDragger
*/
ViewDragger::ViewDragger(Globals& g, ds::ui::Sprite& parent)
: mParent(parent)
, mMomentum(parent.getEngine())
, mIsTouchy(false)
, mReturnTime(g.getSettingsLayout().getFloat("media_viewer:check_bounds:return_time", 0, 0.6f)) {
mParent.enable(true);
mParent.enableMultiTouch(ds::ui::MULTITOUCH_INFO_ONLY);
mParent.setProcessTouchCallback([this](ds::ui::Sprite* bs, const ds::ui::TouchInfo& ti){ onTouched(ti);});
mMomentum.setMomentumParent(&mParent);
mMomentum.setMass(8.0f);
mMomentum.setFriction(0.5f);
}