boost::optional<IddObject> IddFileAndFactoryWrapper::getObject(IddObjectType objectType) const {

  OptionalIddObject result;

  if (objectType == IddObjectType::UserCustom) {
    LOG(Info,"Asked to return IddObject of type IddObjectType::UserCustom. Since "
        << "UserCustom object types are generally not unique, returning false rather than "
        << "an IddObject. Please specify a different IddObjectType, or use "
        << "getObject(const std::string&).");
    return result;
  }

  if (m_iddFile) {
    result = m_iddFile->getObject(objectType);
  }
  else if (m_iddFileType) {
    if (isInFile(objectType)) {
      result = IddFactory::instance().getObject(objectType);
    }
  }
  else {
    LOG_AND_THROW("Invalid IddFactoryWrapper has no IddFile set.");
  }

  return result;
}
boost::optional<IddObject> IddFileAndFactoryWrapper::getObject(const std::string& objectName) const {
  OptionalIddObject result;

  if (m_iddFile) {
    result = m_iddFile->getObject(objectName);
  }
  else if (m_iddFileType) {
    OptionalIddObject candidate = IddFactory::instance().getObject(objectName);
    if (candidate) {
      if (isInFile(candidate->type())) {
        result = candidate;
      }
    }
  }
  else {
    LOG_AND_THROW("Invalid IddFactoryWrapper has no IddFile set.");
  }

  return result;
}
예제 #3
0
// File, Rank のどちらかがおかしいかも知れない時は、
// こちらを使う。
// こちらの方が遅いが、どんな File, Rank にも対応している。
inline bool isInSquare(const File f, const Rank r) {
	return isInFile(f) && isInRank(r);
}