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


C++ Environment类代码示例

本文整理汇总了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;
}
开发者ID:mapleyustat,项目名称:CalcLib,代码行数:43,代码来源:MultivectorNumber.cpp

示例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;
};
开发者ID:Dunes,项目名称:janitor,代码行数:20,代码来源:LPGPTranslator.cpp

示例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");
  }
}
开发者ID:K1N62,项目名称:LUA-Interpreter,代码行数:12,代码来源:Binop.cpp

示例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;
		}
	}
}
开发者ID:mina86,项目名称:calculator,代码行数:20,代码来源:expression.cpp

示例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;
}
开发者ID:josearcosaneas,项目名称:Inteligencia-Artificial,代码行数:29,代码来源:player53676422.cpp

示例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() );
	}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:21,代码来源:ModelShaders.cpp

示例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();
}
开发者ID:ksherlock,项目名称:mpw-shell,代码行数:20,代码来源:mpw-shell.cpp

示例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();
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:11,代码来源:TestSsdpUListen.cpp

示例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);
}
开发者ID:juniordiscart,项目名称:RPGMaker,代码行数:20,代码来源:PlayConfigWindow.cpp

示例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;
}
开发者ID:Arkange-app,项目名称:eufe,代码行数:20,代码来源:EffectShieldBoostingInterpreter.cpp

示例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();
}
开发者ID:gura-lang,项目名称:gura,代码行数:11,代码来源:Iterator.cpp

示例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()));
}
开发者ID:gura-lang,项目名称:gura,代码行数:11,代码来源:Iterator.cpp

示例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 "";
     }
 }
开发者ID:subutai-io,项目名称:launcher,代码行数:20,代码来源:SSH.cpp

示例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;
}
开发者ID:seanhodges,项目名称:Medes,代码行数:25,代码来源:GeckoEmbed.cpp

示例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);
	}
}
开发者ID:ChrisDue,项目名称:Elevator,代码行数:11,代码来源:Person.cpp


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