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


C++ Floor::GetInterfaceCount方法代码示例

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


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

示例1: Initialize

void Person::Initialize(Environment &env) {
	env.RegisterEventHandler("UpDownButton::Decide", this, &Person::HandleDecide);
	env.RegisterEventHandler("Elevator::Opened", this, &Person::HandleOpened);
	env.RegisterEventHandler("Elevator::Beeping", this, &Person::HandleBeeping);
	env.RegisterEventHandler("Elevator::Beeped", this, &Person::HandleBeeped);
	env.RegisterEventHandler("Person::Entered", this, &Person::HandleEntered);
	env.RegisterEventHandler("Person::Exiting", this, &Person::HandleExiting);
	env.RegisterEventHandler("Person::Exited", this, &Person::HandleExited);
	env.RegisterEventHandler("Elevator::Closed", this, &Person::HandleClosed);
	env.RegisterEventHandler("Elevator::Moving", this, &Person::HandleMoving);
	env.RegisterEventHandler("Elevator::Fixed", this, &Person::HandleFixed);
	env.RegisterEventHandler("Elevator::Malfunction", this, &Person::HandleMalfunction);
	env.RegisterEventHandler("Interface::Notify", this, &Person::HandleNotify);
	env.RegisterEventHandler("Elevator::Closing", this, &Person::HandleClosing);

	std::list<Floor*> init;
	init.push_front(current_);

	std::list<std::list<Floor*>> paths;
	paths.push_front(init);

	do {

		std::list<Floor*> path = paths.front();
		Floor *current = path.back();

		paths.pop_front();

		if (current == final_) {
			path.pop_front();
			path_ = path;
			break;
		}

		for (int i = 0; i < current->GetInterfaceCount(); ++i) {

			Interface *interf = current->GetInterface(i);
			Elevator *ele = static_cast<Elevator*>(interf->GetLoadable(0));

			for (int j = 0; j < ele->GetInterfaceCount(); ++j) {

				Interface *binterf = ele->GetInterface(j);
				Floor *floor = static_cast<Floor*>(binterf->GetLoadable(0));

				if (floor != current) {
					path.push_back(floor);
					paths.push_back(path);
					path.pop_back();
				}
			}
		}

	} while (true);

	std::cout << "Path for " << GetName() << " is ";
	for (Floor *floor : path_) {
		std::cout << "Floor " << floor->GetId() << " ";
	}
	std::cout << std::endl;

	RequestElevator(env, start_);
}
开发者ID:ChrisDue,项目名称:Elevator,代码行数:62,代码来源:Person.cpp


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