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


C++ SpecReader::getBackends方法代码示例

本文整理汇总了C++中SpecReader::getBackends方法的典型用法代码示例。如果您正苦于以下问题:C++ SpecReader::getBackends方法的具体用法?C++ SpecReader::getBackends怎么用?C++ SpecReader::getBackends使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpecReader的用法示例。


在下文中一共展示了SpecReader::getBackends方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mpi

TEST (SpecReader, withNeedsResolved)
{
	using namespace kdb;
	using namespace kdb::tools;
	std::shared_ptr<MockPluginDatabase> mpd = std::make_shared<MockPluginDatabase> ();
	mpd->data[PluginSpec ("a")]["provides"] = "storage";
	mpd->data[PluginSpec ("b")]["provides"] = "resolver";
	BackendBuilderInit mpi (mpd);
	SpecReader sr (mpi);
	// clang-format off
	sr.readSpecification(KeySet(5,
				*Key ("spec", KEY_END),
				*Key ("spec/mp", KEY_META, "mountpoint", "file.ini",
					KEY_META, "config/needs/something", "here",
					KEY_META, "infos/needs", "resolver storage",
					KEY_END),
				*Key ("spec/mp/below",
					KEY_META, "config/needs/else", "too",
					KEY_META, "infos/needs", "a b",
					KEY_END),
				KS_END));
	// clang-format on
	SpecBackendBuilder bi = sr.getBackends ()[Key ("spec/mp", KEY_END)];
	EXPECT_EQ (bi.nodes, 2);
	EXPECT_EQ (bi.getMountpoint (), "/mp");
	EXPECT_EQ (bi.getConfigFile (), "file.ini");
	EXPECT_EQ (bi.getBackendConfig (),
		   KeySet (5, *Key ("user/something", KEY_VALUE, "here", KEY_END), *Key ("user/else", KEY_VALUE, "too", KEY_END), KS_END));
	bi.resolveNeeds ();
	ASSERT_EQ (std::distance (bi.begin (), bi.end ()), 2) << "there should be a resolver and storage added";
	EXPECT_EQ (bi.begin ()[0], PluginSpec ("b", "resolver"));
	EXPECT_EQ (bi.begin ()[1], PluginSpec ("a", "storage"));
}
开发者ID:KurtMi,项目名称:libelektra,代码行数:33,代码来源:testtool_specreader.cpp

示例2: buildBackend

void SpecMountCommand::buildBackend (Cmdline const & cl)
{
	SpecReader sr;

	kdb::KeySet specToRead;
	kdb.get (specToRead, "spec" + mp);
	specToRead = specToRead.cut (Key ("spec" + mp, KEY_END));

	sr.readSpecification (specToRead);

	SpecReader::Backends const & backends = sr.getBackends ();

	for (auto & p : backends)
	{
		auto backend = p.second;
		if (cl.verbose)
		{
			std::cout << "Got mountpoint from " << p.first.getName () << " with " << backend.nodes
				  << " nodes, configfile: " << backend.getConfigFile () << " and mountpoint: " << backend.getMountpoint ()
				  << std::endl;
		}

		backend.setBackendConfig (cl.getPluginsConfig ("system/"));
		backend.needPlugin (cl.resolver);
		backend.needPlugin ("storage");

		backend.addPlugins (parseArguments (cl.plugins));

		const int alreadyRead = 1; // we already read mountpoint
		if (cl.arguments.size () <= alreadyRead)
		{
			backend.addPlugins (parseArguments (cl.arguments.begin () + alreadyRead, cl.arguments.end ()));
		}

		// Call it a day
		outputMissingRecommends (backend.resolveNeeds (cl.withRecommends));
		Backends::umount (backend.getMountpoint (), mountConf);
		backend.serialize (mountConf);
	}

	if (!cl.quiet && backends.empty ())
	{
		std::cout << "No metadata \"mountpoint\" found below spec" << mp << std::endl;
	}
}
开发者ID:nikonthethird,项目名称:libelektra,代码行数:45,代码来源:specmount.cpp


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