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


C++ SystemInfo::GetSystemInfo方法代码示例

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


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

示例1: locker

status_t
DebugReportGenerator::_GenerateReportHeader(BFile& _output)
{
	AutoLocker< ::Team> locker(fTeam);

	BString data;
	data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n",
		fTeam->Name(), fTeam->ID());
	WRITE_AND_CHECK(_output, data);

	cpu_platform platform = B_CPU_UNKNOWN;
	cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN;
	uint32 cpuModel = 0;
	uint32 topologyNodeCount = 0;
	cpu_topology_node_info* topology = NULL;
	get_cpu_topology_info(NULL, &topologyNodeCount);
	if (topologyNodeCount != 0) {
		topology = new(std::nothrow) cpu_topology_node_info[topologyNodeCount];
		if (topology == NULL)
			return B_NO_MEMORY;

		BPrivate::ArrayDeleter<cpu_topology_node_info> deleter(topology);
		get_cpu_topology_info(topology, &topologyNodeCount);

		for (uint32 i = 0; i < topologyNodeCount; i++) {
			switch (topology[i].type) {
				case B_TOPOLOGY_ROOT:
					platform = topology[i].data.root.platform;
					break;

				case B_TOPOLOGY_PACKAGE:
					cpuVendor = topology[i].data.package.vendor;
					break;

				case B_TOPOLOGY_CORE:
					cpuModel = topology[i].data.core.model;
					break;

				default:
					break;
			}
		}
	}

	SystemInfo sysInfo;
	if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) {
		const system_info &info = sysInfo.GetSystemInfo();
		data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n",
			info.cpu_count, get_cpu_vendor_string(cpuVendor),
			get_cpu_model_string(platform, cpuVendor, cpuModel));
		WRITE_AND_CHECK(_output, data);

		char maxSize[32];
		char usedSize[32];

		data.SetToFormat("Memory: %s total, %s used\n",
			BPrivate::string_for_size((int64)info.max_pages * B_PAGE_SIZE,
				maxSize, sizeof(maxSize)),
			BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE,
				usedSize, sizeof(usedSize)));
		WRITE_AND_CHECK(_output, data);

		const utsname& name = sysInfo.GetSystemName();
		data.SetToFormat("Haiku revision: %s (%s)\n", name.version,
			name.machine);
		WRITE_AND_CHECK(_output, data);
	}

	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:70,代码来源:DebugReportGenerator.cpp


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