Exemplo n.º 1
0
PluginSpec ModulesPluginDatabase::lookupProvides (std::string const & which) const
{
	// check if plugin itself exists:
	if (status (PluginSpec (which)) == real)
	{
		return PluginSpec (which);
	}

	std::string errors;
	std::vector<std::string> allPlugins = listAllPlugins ();
	std::map<int, PluginSpec> foundPlugins;
	for (auto const & plugin : allPlugins)
	{
		// TODO: make sure (non)-equal plugins (i.e. with same/different contract) are handled correctly
		try
		{
			// TODO: support for generic plugins with config
			std::istringstream ss (
				lookupInfo (PluginSpec (plugin, KeySet (5, *Key ("system/module", KEY_VALUE,
										 "this plugin was loaded without a config", KEY_END),
									KS_END)),
					    "provides"));
			std::string provide;
			while (ss >> provide)
			{
				if (provide == which)
				{
					int s = calculateStatus (lookupInfo (
						PluginSpec (plugin, KeySet (5, *Key ("system/module", KEY_VALUE,
										     "this plugin was loaded without a config", KEY_END),
									    KS_END)),
						"status"));
					foundPlugins.insert (std::make_pair (s, PluginSpec (plugin)));
				}
			}
		}
		catch (std::exception const & e)
		{
			errors += e.what ();
			errors += ",";
		} // assume not loaded
	}

	if (foundPlugins.empty ())
	{
		if (!errors.empty ())
			throw NoPlugin ("No plugin that provides " + which + " could be found, got errors: " + errors);
		else
			throw NoPlugin ("No plugin that provides " + which + " could be found");
	}

	// the largest element of the map contains the best-suited plugin:
	return foundPlugins.rbegin ()->second;
}
Exemplo n.º 2
0
PluginSpec ModulesPluginDatabase::lookupMetadata (std::string const & which) const
{
	std::vector<std::string> allPlugins = listAllPlugins ();
	std::map<int, PluginSpec> foundPlugins;

	std::string errors;
	// collect possible plugins
	for (auto const & plugin : allPlugins)
	{
		try
		{
			// TODO remove /module hack
			std::istringstream ss (
				lookupInfo (PluginSpec (plugin, KeySet (5, *Key ("system/module", KEY_VALUE,
										 "this plugin was loaded without a config", KEY_END),
									KS_END)),
					    "metadata"));
			std::string metadata;
			while (ss >> metadata)
			{
				if (metadata == which)
				{
					int s = calculateStatus (lookupInfo (
						PluginSpec (plugin, KeySet (5, *Key ("system/module", KEY_VALUE,
										     "this plugin was loaded without a config", KEY_END),
									    KS_END)),
						"status"));
					foundPlugins.insert (std::make_pair (s, PluginSpec (plugin)));
					break;
				}
			}
		}
		catch (std::exception const & e)
		{
			errors += e.what ();
			errors += ",";
		} // assume not loaded
	}

	if (foundPlugins.empty ())
	{
		if (!errors.empty ())
			throw NoPlugin ("No plugin that provides " + which + " could be found, got errors: " + errors);
		else
			throw NoPlugin ("No plugin that provides " + which + " could be found");
	}

	// the largest element of the map contains the best-suited plugin:
	return foundPlugins.rbegin ()->second;
}
Exemplo n.º 3
0
std::map<int, PluginSpec> ModulesPluginDatabase::lookupAllProvidesWithStatus (std::string const & which) const
{
	std::string errors;
	std::vector<std::string> allPlugins = listAllPlugins ();
	std::map<int, PluginSpec> foundPlugins;
	for (auto const & plugin : allPlugins)
	{
		// TODO: make sure (non)-equal plugins (i.e. with same/different contract) are handled correctly
		try
		{
			PluginSpec spec = PluginSpec (
				plugin,
				KeySet (5, *Key ("system/module", KEY_VALUE, "this plugin was loaded without a config", KEY_END), KS_END));

			// lets see if there is a plugin named after the required provider
			if (plugin == which)
			{
				int s = calculateStatus (lookupInfo (spec, "status"));
				foundPlugins.insert (std::make_pair (s, PluginSpec (plugin)));
				continue; // we are done with this plugin
			}

			// TODO: support for generic plugins with config
			std::istringstream ss (lookupInfo (spec, "provides"));
			std::string provide;
			while (ss >> provide)
			{
				if (provide == which)
				{
					int s = calculateStatus (lookupInfo (spec, "status"));
					foundPlugins.insert (std::make_pair (s, PluginSpec (plugin)));
				}
			}
		}
		catch (std::exception const & e)
		{
			errors += e.what ();
			errors += ",";
		} // assume not loaded
	}

	if (foundPlugins.empty ())
	{
		if (!errors.empty ())
			throw NoPlugin ("No plugin that provides " + which + " could be found, got errors: " + errors);
		else
			throw NoPlugin ("No plugin that provides " + which + " could be found");
	}

	return foundPlugins;
}
Exemplo n.º 4
0
			void CPipelineState::SetProgram(SharedPointer<IShaderProgram> inShaderProgram)
			{
				if (inShaderProgram)
				{
					ShaderProgram = std::dynamic_pointer_cast<CShaderProgram>(inShaderProgram);
					if (! ShaderProgram->Linked)
					{
						ShaderProgram->Link();

						if (! ShaderProgram->Linked)
						{
							Log::Error("Failed to link shader prograg in PipelineState creation, unsetting shader.");
							ShaderProgram = nullptr;
							return;
						}
					}

					UnboundUniforms = KeySet(ShaderProgram->Uniforms);
					UnboundAttributes = KeySet(ShaderProgram->Attributes);
					UnboundAttributes.erase("gl_VertexID");

					Loaded = false;
				}
			}
Exemplo n.º 5
0
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	HDC hdc;
	BITMAPINFOHEADER bmih = {0};
	switch (uMsg) {
	case WM_PAINT:
		bmih.biSize = sizeof(BITMAPINFOHEADER);
		bmih.biSizeImage = sizeof(sImage);
		bmih.biHeight = -HEIGHT;
		bmih.biWidth = WIDTH;
		bmih.biBitCount = 24;
		bmih.biPlanes = 1;
		hdc = GetDC(hwnd);
		StretchDIBits(hdc, 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, sImage, (BITMAPINFO *)&bmih, DIB_RGB_COLORS, SRCCOPY);
		ReleaseDC(hwnd, hdc);
		break;
	case WM_KEYDOWN:
		if (wParam == 0x0041) KeySet(0, KEY_A | KEY_PRESSED);
		if (wParam == 0x0042) KeySet(0, KEY_B | KEY_PRESSED);
		if (wParam == 0x0020) KeySet(0, KEY_SELECT | KEY_PRESSED);
		if (wParam == 0x000D) KeySet(0, KEY_START | KEY_PRESSED);
		if (wParam == 0x0026) KeySet(0, KEY_UP | KEY_PRESSED);
		if (wParam == 0x0028) KeySet(0, KEY_DOWN | KEY_PRESSED);
		if (wParam == 0x0025) KeySet(0, KEY_LEFT | KEY_PRESSED);
		if (wParam == 0x0027) KeySet(0, KEY_RIGHT | KEY_PRESSED);
		break;
	case WM_KEYUP:
		if (wParam == 0x0041) KeySet(0, KEY_A);
		if (wParam == 0x0042) KeySet(0, KEY_B);
		if (wParam == 0x0020) KeySet(0, KEY_SELECT);
		if (wParam == 0x000D) KeySet(0, KEY_START);
		if (wParam == 0x0026) KeySet(0, KEY_UP);
		if (wParam == 0x0028) KeySet(0, KEY_DOWN);
		if (wParam == 0x0025) KeySet(0, KEY_LEFT);
		if (wParam == 0x0027) KeySet(0, KEY_RIGHT);
		break;
	case WM_CLOSE:
		break;
	default: if (1) {return DefWindowProc(hwnd, uMsg, wParam, lParam);} break;
	}
	return 0;
}
Exemplo n.º 6
0
/**
 * @copydoc ksCut()
 */
inline KeySet KeySet::cut (Key k)
{
	return KeySet(ckdb::ksCut(ks, k.getKey()));
}