Put PDDL translation sections into separate methods.

This commit is contained in:
Patrick Lühne 2016-06-12 22:39:04 +02:00
parent 49002ac52d
commit 9c2f49e4a0
2 changed files with 104 additions and 79 deletions

View File

@ -27,6 +27,10 @@ class TranslatorASP
void checkSupport() const;
void translateDomain() const;
void translateTypes() const;
void translateConstants() const;
void translatePredicates() const;
void translateProblem() const;
const Description &m_description;

View File

@ -72,9 +72,31 @@ void TranslatorASP::translateDomain() const
if (!domain.types().empty())
{
m_ostream << std::endl;
translateTypes();
}
// Constants
if (!domain.constants().empty())
{
m_ostream << std::endl;
translateConstants();
}
// Predicates
if (!domain.predicates().empty())
{
m_ostream << std::endl;
translatePredicates();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void TranslatorASP::translateTypes() const
{
m_ostream << "% types";
const auto &types = domain.types();
const auto &types = m_description.domain().types();
std::for_each(types.cbegin(), types.cend(),
[&](const auto &type)
@ -93,13 +115,13 @@ void TranslatorASP::translateDomain() const
});
}
// Constants
if (!domain.constants().empty())
////////////////////////////////////////////////////////////////////////////////////////////////////
void TranslatorASP::translateConstants() const
{
m_ostream << std::endl;
m_ostream << "% constants";
const auto &constants = domain.constants();
const auto &constants = m_description.domain().constants();
std::for_each(constants.cbegin(), constants.cend(),
[&](const auto &constant)
@ -117,13 +139,13 @@ void TranslatorASP::translateDomain() const
});
}
// Predicates
if (!domain.predicates().empty())
////////////////////////////////////////////////////////////////////////////////////////////////////
void TranslatorASP::translatePredicates() const
{
m_ostream << std::endl;
m_ostream << "% predicates";
const auto &predicates = domain.predicates();
const auto &predicates = m_description.domain().predicates();
std::for_each(predicates.cbegin(), predicates.cend(),
[&](const auto &predicate)
@ -164,7 +186,6 @@ void TranslatorASP::translateDomain() const
m_ostream << ".";
});
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////