本文整理汇总了C++中Floor::HasElevator方法的典型用法代码示例。如果您正苦于以下问题:C++ Floor::HasElevator方法的具体用法?C++ Floor::HasElevator怎么用?C++ Floor::HasElevator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floor
的用法示例。
在下文中一共展示了Floor::HasElevator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Validate
void Elevator::Validate() {
Entity::Validate();
if (speed_ <= 0) {
std::ostringstream oss("Speed of ", std::ostringstream::ate);
oss << GetName() << " must be positive.";
throw TestfileException(oss.str());
}
if (load_ < 10) {
std::ostringstream oss("Maximum load of ", std::ostringstream::ate);
oss << GetName() << " must be greater or equal to 10.";
throw TestfileException(oss.str());
}
if (!current_) {
std::ostringstream oss("Starting floor of ", std::ostringstream::ate);
oss << GetName() << " is null.";
throw TestfileException(oss.str());
}
if (current_->GetType() != "Floor") {
std::ostringstream oss("Starting floor of ", std::ostringstream::ate);
oss << GetName() << " does not reference a floor object.";
throw TestfileException(oss.str());
}
if (count_ < 2) {
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;
//.........这里部分代码省略.........