本文整理汇总了C++中Environment类的典型用法代码示例。如果您正苦于以下问题:C++ Environment类的具体用法?C++ Environment怎么用?C++ Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//=========================================================================================
/*virtual*/ bool MultivectorNumber::Print( char* buffer, int bufferSize, bool printLatex, Environment& environment ) const
{
ScalarAlgebra::PrintPurpose printPurpose = ScalarAlgebra::PRINT_FOR_READING;
if( printLatex )
printPurpose = ScalarAlgebra::PRINT_FOR_LATEX;
if( !environment.IsTypeOf( GeometricAlgebraEnvironment::ClassName() ) )
{
environment.AddError( "Multivector numbers can't be printed in a non-geometric-algebra environment." );
return false;
}
GeometricAlgebraEnvironment* geometricAlgebraEnvironment = ( GeometricAlgebraEnvironment* )&environment;
if( geometricAlgebraEnvironment->displayMode == GeometricAlgebraEnvironment::DISPLAY_AS_SUM_OF_BLADES )
{
if( !multivector.Print( buffer, bufferSize, printPurpose ) )
{
environment.AddError( "Failed to print multivector!" );
return false;
}
}
else if( geometricAlgebraEnvironment->displayMode == GeometricAlgebraEnvironment::DISPLAY_AS_SUM_OF_VERSORS )
{
GeometricAlgebra::SumOfPseudoVersors sumOfPseudoVersors;
if( !sumOfPseudoVersors.AssignSumOfBlades( multivector ) )
return false;
if( !sumOfPseudoVersors.Print( buffer, bufferSize, printPurpose ) )
{
environment.AddError( "Failed to print sum of versors!" );
return false;
}
}
else
{
environment.AddError( "Multivector number display mode is unknown." );
return false;
}
return true;
}
示例2: firstBinding
bool State::firstBinding(Environment & bs,const func_term * fe)
{
int x = 0;
for(parameter_symbol_list::const_iterator i = fe->getArgs()->begin();
i != fe->getArgs()->end();++i,++x)
{
const var_symbol * ps = dynamic_cast<const var_symbol *>(*i);
if(bs.find(ps)==bs.end())
{
if(records[fe->getFunction()][x].empty()) return false;
bs[ps] = *(records[fe->getFunction()][x].begin());
};
};
while(!safeBinding(bs,fe))
{
if(!nextBinding(bs,fe)) return false;
};
cout << "Got first binding\n";
return true;
};
示例3: execute
//! @remark This small limits expressions to integers
bool Binop::execute(Environment& env)
{
switch (this->type) {
case Equal:
env.write(VAL_LEFT, RIGHT);
return true;
default:
throw Error("Tried to execute invalid binary operation");
}
}
示例4: execute
real TimesExpression::execute(Environment &env) const {
SaveOldValue<real> it (env.iteration_value());
SaveOldValue<real> last(env.last_value ());
try {
for (real n = exec<0>(env), i = 0; i < n; i += 1.0) {
it = i;
last = exec<1>(env);
}
return exec<2>(env);
}
catch (BreakException &e) {
if (e.end()) {
return e.getValue();
} else {
throw;
}
}
}
示例5: MiniMax
/**
Esta funcion devuelve la siguiente mejor accion guiada por la heuristica usando el algoritmo minimax.
Devuelve: La siguiente accion a realizar.
Parametros:
"actual" contiene el estado del tablero.
"jug" indica que jugador esta pidiendo el valor heuristico.
"limite_profundidad" establece el limite de exploracion del grafo.
OBSERVACION: esta parametrizacion es solo indicativa, y el alumno podra modificarla segun sus necesidades
*/
Environment::ActionType MiniMax(const Environment & actual, int jug, int limite_profundidad){
Environment::ActionType accion;
int mayor = -INFINITO, mayor_actual, profundidad = 0;
Environment sigact[4];
int n_act = actual.GenerateNextMove(sigact, jug);
for (int i = 0; i < n_act; i++) {
mayor_actual = valorMin(sigact[i], jug, profundidad+1, limite_profundidad, actual.Marcador(jug));
if (mayor_actual > mayor) {
mayor = mayor_actual;
accion = static_cast<Environment::ActionType> (sigact[i].Last_Action(jug));
}
}
cout << "Jugador: " << jug;
cout << " mayor " << mayor;
cout << endl;
return accion;
}
示例6: _SetParameters
//--------------------------------------------------------------------------------------
void ModelPrePixelLight::_SetParameters ()
{
Engine& engine = Engine::Instance();
Device* device = engine.GetDevice();
Environment* env = engine.GetEnvironment();
ICamera* camera = engine.GetCamera();
device->SetShaderParameter(m_hTransform, *(Matrix44f*)(m_pMaterial->Attribute( IAttributeNode::ATT_WORLDTRANSFORM )) );
device->SetShaderParameter(m_hNormalTransform, *(Matrix33f*)(m_pMaterial->Attribute( IAttributeNode::ATT_NORMALTRANSFORM )) );
device->SetShaderParameter(m_hViewProjMatrixLoc, camera->GetViewProj());
device->SetShaderParameter(m_hLightDirectionLoc, -env->GetCurrentLight().GetWorldDirection() );//phong光是像素到光源的方向,所以这里反向
device->SetShaderParameter(m_hCameraPositionLoc, camera->GetPosition() );
device->SetShaderParameter( m_hTextureBase, *((Texture*)m_pMaterial->Attribute(Material::ATT_TEX_DIFFUSE)) );
device->SetShaderParameter(m_hAmbient_AmbientLight, env->GetAmbient() * m_pMaterial->Ambient() );
device->SetShaderParameter(m_hSpecular_Light, env->GetCurrentLight().GetColor() * m_pMaterial->Specular() * m_pMaterial->SpeLevel() );
device->SetShaderParameter(m_hLight, m_pMaterial->Diffuse() * env->GetCurrentLight().GetColor() );
device->SetShaderParameter(m_hShininess, m_pMaterial->Shininess() );
}
示例7: read_file
int read_file(Environment &e, const std::string &file, const fdmask &fds) {
std::error_code ec;
const mapped_file mf(file, mapped_file::readonly, ec);
if (ec) {
fprintf(stderr, "# Error reading %s: %s\n", file.c_str(), ec.message().c_str());
return e.status(-1, false);
}
mpw_parser p(e, fds);
e.status(0, false);
try {
p.parse(mf.begin(), mf.end());
p.finish();
} catch(const execution_of_input_terminated &ex) {
return ex.status();
}
return e.status();
}
示例8: NetworkIf
static TIpAddress NetworkIf(Environment& aEnv, TUint aIndex)
{
const std::vector<NetworkAdapter*>& ifs = aEnv.NetworkAdapterList().List();
ASSERT(ifs.size() > 0 && aIndex < ifs.size());
TIpAddress addr = ifs[aIndex]->Address();
Endpoint endpt(0, addr);
Endpoint::AddressBuf buf;
endpt.AppendAddress(buf);
Print("Using network interface %s\n\n", buf.Ptr());
return ifs[aIndex]->Address();
}
示例9: loadLocationTab
void PlayConfigWindow::loadLocationTab() {
_environmentSelection->clear();
_environment->clear();
_environment->setRowCount(0);
_environment->setColumnCount(0);
QVector<Environment*> environments = _project->getEnvironments()->getEnvironments();
StartEvent *start = _project->getStartEvent();
int index = 0;
for (int i = 0; i < environments.size(); i++) {
Environment *it = environments.at(i);
_environmentSelection->addItem(it->getName());
if (!!start->getLocation().first && (start->getLocation().first->getName() == it->getName()))
index = i;
}
_environmentSelection->setCurrentIndex(index);
}
示例10: removeEffect
bool EffectShieldBoostingInterpreter::removeEffect(const Environment& environment)
{
const char* key = isProjected_ ? "Target" : "Ship";
Environment::const_iterator Target = environment.find(key);
Environment::const_iterator Self = environment.find("Self");
Environment::const_iterator Char = environment.find("Char");
Environment::const_iterator end = environment.end();
if (Target != end && Self != end && Char != end) {
Modifier* modifier = new Modifier(SHIELD_CHARGE_ATTRIBUTE_ID,
Modifier::ASSOCIATION_ADD_RATE,
Self->second->getAttribute(SHIELD_BONUS_ATTRIBUTE_ID),
isAssistance_,
isOffensive_,
dynamic_cast<Character*>(Char->second));
Target->second->removeItemModifier(modifier);
delete modifier;
}
return 1;
}
示例11: Consume
bool Iterator::Consume(Environment &env)
{
Signal &sig = env.GetSignal();
if (IsInfinite()) {
SetError_InfiniteNotAllowed(sig);
return false;
}
Value value;
while (Next(env, value)) ;
return !sig.IsSignalled();
}
示例12: StandardDeviation
Value Iterator::StandardDeviation(Environment &env, size_t &cnt, bool populationFlag)
{
Signal &sig = env.GetSignal();
if (IsInfinite()) {
SetError_InfiniteNotAllowed(sig);
return Value::Nil;
}
Value valueVar = Clone()->Variance(env, cnt, populationFlag);
if (!valueVar.Is_number()) return Value::Nil;
return Value(::sqrt(valueVar.GetNumber()));
}
示例13: getPublicKey
std::string SSH::getPublicKey()
{
Environment env;
auto var = env.getVar("HOME", "~");
var.append("/.ssh/id_rsa.pub");
try {
Poco::FileInputStream fs(var);
std::string buffer;
Poco::StreamCopier::copyToString(fs, buffer);
return buffer;
}
catch (Poco::FileNotFoundException e) {
Poco::Logger::get("subutai").error("id_rsa.pub not found");
return "";
}
catch (std::exception e) {
Poco::Logger::get("subutai").error("Exception: %s", e.what());
return "";
}
}
示例14: init
/**
* Initialise the engine (must be called AFTER gtk_init())
*
* @param config - the config container in use
*/
void GeckoEmbed::init(ConfigContainer config) {
// Set the environment
Environment env;
string configProfilePath = env.getUserGeckoProfilePath();
string configProfileName = "medes-gecko";
gtk_moz_embed_set_profile_path(configProfilePath.c_str(),configProfileName.c_str());
GtkMozEmbed *mozEmbed = GTK_MOZ_EMBED(gtk_moz_embed_new());
gtk_moz_embed_set_chrome_mask(mozEmbed, GTK_MOZ_EMBED_FLAG_ALLCHROME);
// Attach to functors
gtk_signal_connect(GTK_OBJECT(mozEmbed), "open_uri", GTK_SIGNAL_FUNC(&GeckoEmbed::open_uri_cb), this);
gtk_signal_connect(GTK_OBJECT(mozEmbed), "progress", GTK_SIGNAL_FUNC(&GeckoEmbed::progress_change_cb), this);
gtk_signal_connect(GTK_OBJECT(mozEmbed), "net_start", GTK_SIGNAL_FUNC(&GeckoEmbed::load_started_cb), this);
gtk_signal_connect(GTK_OBJECT(mozEmbed), "net_stop", GTK_SIGNAL_FUNC(&GeckoEmbed::load_finished_cb), this);
// Initial object configuration
setMozEmbed(mozEmbed);
setConfig(config);
setUrl(config.getAppUrl());
dataSize = 0;
status = NULL;
}
示例15: HandleBeeping
void Person::HandleBeeping(Environment &env, const Event &e) {
Elevator *ele = static_cast<Elevator*>(e.GetSender());
if (elevator_ == ele && elevator_) {
beeping_ = true;
env.CancelEvent(action_); // Cancel Interface::Interact
Exit(env);
}
}