Making sure that PDDL predicates contain only primitive types for the time being.

This commit is contained in:
Patrick Lühne 2016-06-12 22:19:55 +02:00
parent 89bb54a3ec
commit 639b7646c9
2 changed files with 26 additions and 2 deletions

View File

@ -23,9 +23,10 @@ class TranslatorASP
void translate(std::ostream &ostream) const; void translate(std::ostream &ostream) const;
private:
void checkSupport() const;
void translateDomain(std::ostream &ostream) const; void translateDomain(std::ostream &ostream) const;
void translateProblem(std::ostream &ostream) const; void translateProblem(std::ostream &ostream) const;
const Description &m_description; const Description &m_description;

View File

@ -20,8 +20,31 @@ TranslatorASP::TranslatorASP(const Description &description)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void TranslatorASP::checkSupport() const
{
// Check for "either" types
const auto &predicates = m_description.domain().predicates();
std::for_each(predicates.cbegin(), predicates.cend(),
[&](const auto &predicate)
{
const auto &arguments = predicate->arguments();
std::for_each(arguments.cbegin(), arguments.cend(),
[&](const auto &parameter)
{
if (parameter->type()->expressionType() != Expression::Type::PrimitiveType)
throw utils::TranslatorException("Only primitive types supported currently");
});
});
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void TranslatorASP::translate(std::ostream &ostream) const void TranslatorASP::translate(std::ostream &ostream) const
{ {
checkSupport();
translateDomain(ostream); translateDomain(ostream);
if (m_description.containsProblem()) if (m_description.containsProblem())