本文整理汇总了C++中Floor::IsAbove方法的典型用法代码示例。如果您正苦于以下问题:C++ Floor::IsAbove方法的具体用法?C++ Floor::IsAbove怎么用?C++ Floor::IsAbove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floor
的用法示例。
在下文中一共展示了Floor::IsAbove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Validate
//.........这里部分代码省略.........
std::ostringstream oss("", std::ostringstream::ate);
oss << GetName() << " must have at least 2 interfaces.";
throw TestfileException(oss.str());
}
std::set<Interface*> unique;
Floor *lowest = nullptr;
Floor *highest = nullptr;
for (int i = 0; i < count_; ++i) {
Interface *interf = interfs_[i];
if (!interf) {
std::ostringstream oss("An interface of ", std::ostringstream::ate);
oss << GetName() << " is null.";
throw TestfileException(oss.str());
}
if (unique.count(interf)) {
std::ostringstream oss("Interfaces used by ", std::ostringstream::ate);
oss << GetName() << " are not unique.";
throw TestfileException(oss.str());
}
unique.insert(interf);
if (interf->GetType() != "Interface") {
std::ostringstream oss("Interface ", std::ostringstream::ate);
oss << interf->GetId() << " of ";
oss << GetName() << " is not an interface object.";
throw TestfileException(oss.str());
}
if (interf->GetLoadableCount() != 1) {
std::ostringstream oss("", std::ostringstream::ate);
oss << interf->GetName() << " of ";
oss << GetName() << " must reference exactly one object.";
throw TestfileException(oss.str());
}
Loadable *loadable = interf->GetLoadable(0);
if (!loadable) {
std::ostringstream oss("Referenced object of ", std::ostringstream::ate);
oss << interf->GetName() << " of ";
oss << GetName() << " is null.";
throw TestfileException(oss.str());
}
if (loadable->GetType() != "Floor") {
std::ostringstream oss("Referenced object of ", std::ostringstream::ate);
oss << interf->GetName() << " of ";
oss << GetName() << " must be an floor object.";
throw TestfileException(oss.str());
}
Floor *floor = static_cast<Floor*>(loadable);
if (!floor->HasElevator(this)) {
std::ostringstream oss("Floor ", std::ostringstream::ate);
oss << floor->GetId() << " referenced by ";
oss << interf->GetName() << " of ";
oss << GetName() << " does not point back to the elevator.";
throw TestfileException(oss.str());
}
if (!lowest)
lowest = floor;
else if (lowest->IsBelow(floor)) {
lowest = floor;
}
if (!highest)
highest = floor;
else if (highest->IsAbove(floor)) {
highest = floor;
}
}
if (highest->IsAbove(current_) || lowest->IsBelow(current_)) {
std::ostringstream oss("Starting floor of ", std::ostringstream::ate);
oss << GetName() << " is not between Floor " << lowest->GetId() << " and Floor " << highest->GetId() << ".";
throw TestfileException(oss.str());
}
// validate if the elevator can start in the starting floor
if (!HasFloor(this->current_)) {
std::ostringstream oss("Elevator ", std::ostringstream::ate);
oss << GetId() << " can not start in Floor " << current_->GetId() << " because the Floor has no interface to this Elevator.";
throw TestfileException(oss.str());
}
Floor* floorTmp = CanReachFloor(lowest, highest);
if (floorTmp) {
std::ostringstream oss("Elevator ", std::ostringstream::ate);
oss << GetId() << " can not reach center of Floor " << floorTmp->GetId() << ".";
throw TestfileException(oss.str());
}
}