diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..ea3b1d4c
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,60 @@
+---
+AccessModifierOffset: -4
+AlignAfterOpenBracket: Align
+AlignEscapedNewlines: Left
+AlignOperands: 'true'
+AlignTrailingComments: 'true'
+AllowAllArgumentsOnNextLine: 'false'
+AllowAllConstructorInitializersOnNextLine: 'false'
+AllowAllParametersOfDeclarationOnNextLine: 'false'
+AllowShortBlocksOnASingleLine: 'true'
+AllowShortCaseLabelsOnASingleLine: 'false'
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: 'false'
+AlwaysBreakTemplateDeclarations: 'Yes'
+BinPackArguments: 'false'
+BinPackParameters: 'false'
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeBraces: Allman
+BreakBeforeTernaryOperators: 'false'
+BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+ColumnLimit: '160'
+CompactNamespaces: 'false'
+ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
+Cpp11BracedListStyle: 'false'
+FixNamespaceComments: 'false'
+IncludeBlocks: Regroup
+IndentAccessModifiers: 'false'
+IndentCaseLabels: 'true'
+IndentPPDirectives: None
+IndentWidth: '4'
+IndentWrappedFunctionNames: 'false'
+KeepEmptyLinesAtTheStartOfBlocks: 'false'
+Language: Cpp
+MaxEmptyLinesToKeep: '1'
+NamespaceIndentation: None
+PointerAlignment: Left
+SortIncludes: 'true'
+SortUsingDeclarations: 'true'
+SpaceAfterCStyleCast: 'true'
+SpaceAfterLogicalNot: 'false'
+SpaceAfterTemplateKeyword: 'false'
+SpaceBeforeAssignmentOperators: 'true'
+SpaceBeforeCpp11BracedList: 'true'
+SpaceBeforeCtorInitializerColon: 'true'
+SpaceBeforeInheritanceColon: 'true'
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: 'true'
+SpaceInEmptyParentheses: 'false'
+SpacesBeforeTrailingComments: '2'
+SpacesInAngles: 'false'
+SpacesInCStyleCastParentheses: 'false'
+SpacesInParentheses: 'false'
+SpacesInSquareBrackets: 'false'
+Standard: Cpp11
+TabWidth: '4'
+UseTab: Never
+...
diff --git a/examples/multiple_problems.cpp b/examples/multiple_problems.cpp
index 2e1da903..8b6b34fc 100644
--- a/examples/multiple_problems.cpp
+++ b/examples/multiple_problems.cpp
@@ -15,13 +15,12 @@
* along with this program. If not, see .
*/
+#include
#include
#include
-#include
-
-
-int main() {
+int main()
+{
// Parse the domain
auto domain_parser = loki::DomainParser("data/gripper/domain.pddl");
const auto domain = domain_parser.get_domain();
@@ -44,6 +43,5 @@ int main() {
the idexing scheme is most likely fragmented per problem.
(In this specific case, it is not fragmented because both problems are structurally equivalent) */
-
return 0;
}
diff --git a/examples/position_cache.cpp b/examples/position_cache.cpp
index 60c1ade6..f87d5126 100644
--- a/examples/position_cache.cpp
+++ b/examples/position_cache.cpp
@@ -15,34 +15,38 @@
* along with this program. If not, see .
*/
-#include
-#include
-
#include
#include
-
+#include
+#include
/// @brief Prints an error message when encourtering an And-Condition.
-struct TestUnsupportedAndConditionVisitor {
+struct TestUnsupportedAndConditionVisitor
+{
const loki::Position position;
const loki::PDDLPositionCache& position_cache;
const loki::PDDLErrorHandler& error_handler;
- TestUnsupportedAndConditionVisitor(
- const loki::Position position_,
- const loki::PDDLPositionCache& position_cache_,
- const loki::PDDLErrorHandler& error_handler_)
- : position(position_)
- , position_cache(position_cache_)
- , error_handler(error_handler_) { }
+ TestUnsupportedAndConditionVisitor(const loki::Position position_,
+ const loki::PDDLPositionCache& position_cache_,
+ const loki::PDDLErrorHandler& error_handler_) :
+ position(position_),
+ position_cache(position_cache_),
+ error_handler(error_handler_)
+ {
+ }
/// @brief For leaf nodes we do not need to do anything
template
- void operator()(const Node&) { }
+ void operator()(const Node&)
+ {
+ }
/// @brief For inner nodes we need to recursively call the visitor
- void operator()(const loki::pddl::ConditionOrImpl& node) {
- for (const auto& child_node : node.get_conditions()) {
+ void operator()(const loki::pddl::ConditionOrImpl& node)
+ {
+ for (const auto& child_node : node.get_conditions())
+ {
// We call front() to obtain the first occurence.
const auto child_position = position_cache.get(child_node).front();
std::visit(TestUnsupportedAndConditionVisitor(child_position, position_cache, error_handler), *child_node);
@@ -51,15 +55,16 @@ struct TestUnsupportedAndConditionVisitor {
/// @brief For the unsupported And-Condition,
/// we print an clang-style error message and throw an exception.
- void operator()(const loki::pddl::ConditionAndImpl&) {
+ void operator()(const loki::pddl::ConditionAndImpl&)
+ {
std::cout << error_handler(position, "Your awesome error message.") << std::endl;
throw std::runtime_error("Unexpected And-Condition.");
}
};
-
/// @brief In this example, we show how to print custom error message for unsupported PDDL types.
-int main() {
+int main()
+{
// Parse the domain
auto domain_parser = loki::DomainParser("data/gripper/domain.pddl");
const auto domain = domain_parser.get_domain();
@@ -68,16 +73,16 @@ int main() {
const loki::PDDLPositionCache& position_cache = domain_parser.get_position_cache();
const loki::PDDLErrorHandler& error_handler = position_cache.get_error_handler();
- for (const auto& action : domain->get_actions()) {
+ for (const auto& action : domain->get_actions())
+ {
const auto condition = action->get_condition();
- if (!condition.has_value()) {
+ if (!condition.has_value())
+ {
continue;
}
// We call front() to obtain the first occurence.
auto condition_position = position_cache.get(condition.value()).front();
- std::visit(
- TestUnsupportedAndConditionVisitor(condition_position, position_cache, error_handler),
- *condition.value());
+ std::visit(TestUnsupportedAndConditionVisitor(condition_position, position_cache, error_handler), *condition.value());
}
return 0;
diff --git a/examples/single_problem.cpp b/examples/single_problem.cpp
index 56f8d65a..f6cda4ed 100644
--- a/examples/single_problem.cpp
+++ b/examples/single_problem.cpp
@@ -15,13 +15,12 @@
* along with this program. If not, see .
*/
+#include
#include
#include
-#include
-
-
-int main() {
+int main()
+{
// Parse the domain
auto domain_parser = loki::DomainParser("data/gripper/domain.pddl");
const auto domain = domain_parser.get_domain();
diff --git a/examples/undefined_behavior.cpp b/examples/undefined_behavior.cpp
index b9a07fd1..4990a276 100644
--- a/examples/undefined_behavior.cpp
+++ b/examples/undefined_behavior.cpp
@@ -15,15 +15,14 @@
* along with this program. If not, see .
*/
+#include
#include
#include
-#include
-
-
/// @brief This example illustrates incorrect ownership handling
-int main() {
- auto domain = loki::pddl::Domain{nullptr};
+int main()
+{
+ auto domain = loki::pddl::Domain { nullptr };
{
// Parse the domain
auto domain_parser = loki::DomainParser("data/gripper/domain.pddl");
diff --git a/exe/domain.cpp b/exe/domain.cpp
index c6066124..feb627a5 100644
--- a/exe/domain.cpp
+++ b/exe/domain.cpp
@@ -15,17 +15,17 @@
* along with this program. If not, see .
*/
-#include
-
#include
+#include
-
-int main(int argc, char** argv) {
- if (argc < 2) {
+int main(int argc, char** argv)
+{
+ if (argc < 2)
+ {
std::cout << "Usage: interpreter " << std::endl;
return 1;
}
- const auto domain_file = std::string{argv[1]};
+ const auto domain_file = std::string { argv[1] };
// 1. Parse the domain
const auto domain_parser = loki::DomainParser(domain_file);
diff --git a/exe/problem.cpp b/exe/problem.cpp
index 9e5d5a0f..10f1305b 100644
--- a/exe/problem.cpp
+++ b/exe/problem.cpp
@@ -15,19 +15,19 @@
* along with this program. If not, see .
*/
+#include
#include
#include
-#include
-
-
-int main(int argc, char** argv) {
- if (argc < 3) {
+int main(int argc, char** argv)
+{
+ if (argc < 3)
+ {
std::cout << "Usage: interpreter " << std::endl;
return 1;
}
- const auto domain_file = std::string{argv[1]};
- const auto problem_file = std::string{argv[2]};
+ const auto domain_file = std::string { argv[1] };
+ const auto problem_file = std::string { argv[2] };
// 1. Parse the domain
auto domain_parser = loki::DomainParser(domain_file);
diff --git a/include/loki/common/ast/config.hpp b/include/loki/common/ast/config.hpp
index 5a7ea21b..e2c50e81 100644
--- a/include/loki/common/ast/config.hpp
+++ b/include/loki/common/ast/config.hpp
@@ -21,42 +21,33 @@
#include
#include
#include
-
#include
-
/// @brief Defines types of our parsers.
/// The configuration is relevant when reusing the parsers instantiated by the library.
namespace loki
{
- namespace x3 = boost::spirit::x3;
-
- using Position = x3::position_tagged;
- using PositionList = std::vector;
-
- // Our iterator type
- typedef std::string::const_iterator iterator_type;
+namespace x3 = boost::spirit::x3;
+using Position = x3::position_tagged;
+using PositionList = std::vector;
- /* X3 error handler utility */
- template
- using error_handler = x3::error_handler;
+// Our iterator type
+typedef std::string::const_iterator iterator_type;
- using error_handler_tag = x3::error_handler_tag;
+/* X3 error handler utility */
+template
+using error_handler = x3::error_handler;
- typedef error_handler error_handler_type;
+using error_handler_tag = x3::error_handler_tag;
+typedef error_handler error_handler_type;
- /* The phrase parse context */
- typedef
- x3::phrase_parse_context::type phrase_context_type;
+/* The phrase parse context */
+typedef x3::phrase_parse_context::type phrase_context_type;
- /* Combined error handler, pddl, and phrase parse Context */
- typedef x3::context<
- error_handler_tag,
- std::reference_wrapper,
- phrase_context_type>
- context_type;
+/* Combined error handler, pddl, and phrase parse Context */
+typedef x3::context, phrase_context_type> context_type;
}
#endif
diff --git a/include/loki/common/ast/error_handler.hpp b/include/loki/common/ast/error_handler.hpp
index d284619e..e6bf11dd 100644
--- a/include/loki/common/ast/error_handler.hpp
+++ b/include/loki/common/ast/error_handler.hpp
@@ -18,45 +18,48 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_HANDLER_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_HANDLER_HPP_
-#include "config.hpp"
+#include "loki/common/ast/config.hpp"
-#include
#include
-
+#include
namespace loki
{
- namespace x3 = boost::spirit::x3;
+namespace x3 = boost::spirit::x3;
- ////////////////////////////////////////////////////////////////////////////
- // Our error handler
- ////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+// Our error handler
+////////////////////////////////////////////////////////////////////////////
- struct error_handler_base
- {
- std::unordered_map id_map;
+struct error_handler_base
+{
+ std::unordered_map id_map;
- error_handler_base() { }
+ error_handler_base() {}
- template
- x3::error_handler_result on_error(
- Iterator& /*first*/, Iterator const& /*last*/
- , Exception const& x, Context const& context) {
+ template
+ x3::error_handler_result on_error(Iterator& /*first*/,
+ Iterator const& /*last*/
+ ,
+ Exception const& x,
+ Context const& context)
+ {
+ {
+ std::string which = x.which();
+ auto iter = id_map.find(which);
+ if (iter != id_map.end())
{
- std::string which = x.which();
- auto iter = id_map.find(which);
- if (iter != id_map.end()) {
- which = iter->second;
- }
+ which = iter->second;
+ }
- std::string message = "Error! Expecting: " + which + " here:";
- auto& error_handler = x3::get(context).get();
- error_handler(x.where(), message);
+ std::string message = "Error! Expecting: " + which + " here:";
+ auto& error_handler = x3::get(context).get();
+ error_handler(x.where(), message);
- return x3::error_handler_result::fail;
- }
+ return x3::error_handler_result::fail;
}
- };
+ }
+};
}
#endif
diff --git a/include/loki/common/ast/error_reporting.hpp b/include/loki/common/ast/error_reporting.hpp
index 7722e961..728cdc4c 100644
--- a/include/loki/common/ast/error_reporting.hpp
+++ b/include/loki/common/ast/error_reporting.hpp
@@ -18,48 +18,39 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_REPORTING_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_AST_ERROR_REPORTING_HPP_
-#include "config.hpp"
+#include "loki/common/ast/config.hpp"
#include
-
// Clang-style error handling utilities
namespace loki
{
- /* Combined error handler and output stream. */
- class X3ErrorHandler {
- private:
- // Order of initialization matters
- std::ostringstream m_error_stream;
- error_handler_type m_error_handler;
+/* Combined error handler and output stream. */
+class X3ErrorHandler
+{
+private:
+ // Order of initialization matters
+ std::ostringstream m_error_stream;
+ error_handler_type m_error_handler;
- public:
- X3ErrorHandler(iterator_type first, iterator_type last, const std::string& file)
- : m_error_handler(error_handler_type(first, last, m_error_stream, file)) { }
+public:
+ X3ErrorHandler(iterator_type first, iterator_type last, const std::string& file) : m_error_handler(error_handler_type(first, last, m_error_stream, file)) {}
- // delete copy and move to avoid dangling references.
- X3ErrorHandler(const X3ErrorHandler& other) = delete;
- X3ErrorHandler& operator=(const X3ErrorHandler& other) = delete;
- X3ErrorHandler(X3ErrorHandler&& other) = delete;
- X3ErrorHandler& operator=(X3ErrorHandler&& other) = delete;
+ // delete copy and move to avoid dangling references.
+ X3ErrorHandler(const X3ErrorHandler& other) = delete;
+ X3ErrorHandler& operator=(const X3ErrorHandler& other) = delete;
+ X3ErrorHandler(X3ErrorHandler&& other) = delete;
+ X3ErrorHandler& operator=(X3ErrorHandler&& other) = delete;
- const error_handler_type& get_error_handler() const {
- return m_error_handler;
- }
+ const error_handler_type& get_error_handler() const { return m_error_handler; }
- error_handler_type& get_error_handler() {
- return m_error_handler;
- }
+ error_handler_type& get_error_handler() { return m_error_handler; }
- const std::ostringstream& get_error_stream() const {
- return m_error_stream;
- }
+ const std::ostringstream& get_error_stream() const { return m_error_stream; }
- std::ostringstream& get_error_stream() {
- return m_error_stream;
- }
- };
+ std::ostringstream& get_error_stream() { return m_error_stream; }
+};
}
#endif
diff --git a/include/loki/common/ast/parser_wrapper.hpp b/include/loki/common/ast/parser_wrapper.hpp
index f747424c..3b6e3087 100644
--- a/include/loki/common/ast/parser_wrapper.hpp
+++ b/include/loki/common/ast/parser_wrapper.hpp
@@ -18,50 +18,48 @@
#ifndef LOKI_INCLUDE_COMMON_AST_PARSER_WRAPPER_HPP_
#define LOKI_INCLUDE_COMMON_AST_PARSER_WRAPPER_HPP_
-#include "config.hpp"
+#include "loki/common/ast/config.hpp"
#include
-
-namespace loki {
+namespace loki
+{
template
-bool parse_ast(Iterator& iter, Iterator end, const Parser& parser, Node& out, error_handler_type& error_handler) {
- out = Node(); // reinitialize
+bool parse_ast(Iterator& iter, Iterator end, const Parser& parser, Node& out, error_handler_type& error_handler)
+{
+ out = Node(); // reinitialize
- //assert(error_handler.get_position_cache().first() <= iter &&
- // end < error_handler.get_position_cache().last());
+ // assert(error_handler.get_position_cache().first() <= iter &&
+ // end < error_handler.get_position_cache().last());
using boost::spirit::x3::with;
- auto const wrapped_parser =
- with(std::ref(error_handler))
- [
- parser
- ];
+ auto const wrapped_parser = with(std::ref(error_handler))[parser];
using boost::spirit::x3::ascii::space;
bool success = phrase_parse(iter, end, wrapped_parser, space, out);
return success;
}
template
-bool parse_ast(const std::string& source, const Parser& parser, Node& out, error_handler_type& error_handler) {
+bool parse_ast(const std::string& source, const Parser& parser, Node& out, error_handler_type& error_handler)
+{
auto iter = source.begin();
return parse_ast(iter, source.end(), parser, out, error_handler);
}
template
-void parse_ast(const std::string& source, const Parser& parser, Node& out) {
+void parse_ast(const std::string& source, const Parser& parser, Node& out)
+{
loki::iterator_type iter(source.begin());
const loki::iterator_type end(source.end());
error_handler_type error_handler(iter, end, std::cerr);
bool success = parse_ast(source, parser, out, error_handler);
- if (!success) {
+ if (!success)
+ {
throw std::runtime_error("Failed parse.");
}
}
-
-
}
#endif
diff --git a/include/loki/common/collections.hpp b/include/loki/common/collections.hpp
index 100ca236..9a5705f1 100644
--- a/include/loki/common/collections.hpp
+++ b/include/loki/common/collections.hpp
@@ -18,20 +18,20 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_COLLECTIONS_HPP_
-#include
-
#include
+#include
#include
-
-namespace loki {
+namespace loki
+{
/// @brief Returns the sorted vector
/// @tparam T
/// @param vec
/// @return
template
-boost::container::small_vector get_sorted_vector(const Collection& collection) {
+boost::container::small_vector get_sorted_vector(const Collection& collection)
+{
boost::container::small_vector result(collection.begin(), collection.end());
std::sort(result.begin(), result.end());
return result;
diff --git a/include/loki/common/exceptions.hpp b/include/loki/common/exceptions.hpp
index a97b5411..a4109c78 100644
--- a/include/loki/common/exceptions.hpp
+++ b/include/loki/common/exceptions.hpp
@@ -20,32 +20,32 @@
#include
-
-namespace loki {
-class FileNotExistsError : public std::runtime_error {
+namespace loki
+{
+class FileNotExistsError : public std::runtime_error
+{
public:
explicit FileNotExistsError(const std::string& path_to_file);
};
-
-class SyntaxParserError : public std::runtime_error {
+class SyntaxParserError : public std::runtime_error
+{
public:
explicit SyntaxParserError(const std::string& message, const std::string& error_handler_output);
};
-
-class SemanticParserError : public std::runtime_error {
+class SemanticParserError : public std::runtime_error
+{
public:
explicit SemanticParserError(const std::string& message, const std::string& error_handler_output);
};
-
-class NotImplementedError : public std::runtime_error {
+class NotImplementedError : public std::runtime_error
+{
public:
explicit NotImplementedError(const std::string& message);
};
-
}
#endif
\ No newline at end of file
diff --git a/include/loki/common/filesystem.hpp b/include/loki/common/filesystem.hpp
index cb2726b0..e3036c03 100644
--- a/include/loki/common/filesystem.hpp
+++ b/include/loki/common/filesystem.hpp
@@ -18,24 +18,22 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_FILESYSTEM_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_FILESYSTEM_HPP_
-
// Older versions of LibC++ does not have filesystem (e.g., ubuntu 18.04), use the experimental version
// https://stackoverflow.com/questions/55474690/stdfilesystem-has-not-been-declared-after-including-experimental-filesystem
#ifndef __has_include
- static_assert(false, "__has_include not supported");
+static_assert(false, "__has_include not supported");
#else
-# if __cplusplus >= 201703L && __has_include()
-# include
- namespace fs = std::filesystem;
-# elif __has_include()
-# include
- namespace fs = std::experimental::filesystem;
-# elif __has_include()
-# include
- namespace fs = boost::filesystem;
-# endif
+#if __cplusplus >= 201703L && __has_include()
+#include
+namespace fs = std::filesystem;
+#elif __has_include()
+#include
+namespace fs = std::experimental::filesystem;
+#elif __has_include()
+#include
+namespace fs = boost::filesystem;
+#endif
#endif
-
namespace loki
{
diff --git a/include/loki/common/hash.hpp b/include/loki/common/hash.hpp
index 4c13061b..8245548f 100644
--- a/include/loki/common/hash.hpp
+++ b/include/loki/common/hash.hpp
@@ -18,13 +18,13 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_HASH_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_HASH_HPP_
-#include
#include
+#include
#include
#include
-
-namespace loki {
+namespace loki
+{
// --------------
// Hash functions
@@ -65,13 +65,11 @@ inline std::size_t hash_container(const Container& container)
}
template
-struct hash_container_type {
- size_t operator()(const Container& container) const {
- return hash_container(container);
- }
+struct hash_container_type
+{
+ size_t operator()(const Container& container) const { return hash_container(container); }
};
}
-
#endif
\ No newline at end of file
diff --git a/include/loki/common/memory.hpp b/include/loki/common/memory.hpp
index a28926c1..09843910 100644
--- a/include/loki/common/memory.hpp
+++ b/include/loki/common/memory.hpp
@@ -17,12 +17,12 @@
// Taken from: https://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-runtime-using-c
-#include
+#include
#include
#include
-#include
#include
#include
+#include
//////////////////////////////////////////////////////////////////////////////
//
@@ -30,7 +30,8 @@
// size and resident set size, and return the results in KB.
//
// On failure, returns 0.0, 0.0
-namespace loki {
+namespace loki
+{
extern std::tuple process_mem_usage();
diff --git a/include/loki/common/pddl/base.hpp b/include/loki/common/pddl/base.hpp
index d7213097..bdc00aa9 100644
--- a/include/loki/common/pddl/base.hpp
+++ b/include/loki/common/pddl/base.hpp
@@ -18,14 +18,14 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_BASE_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_BASE_HPP_
-#include "../printer.hpp"
+#include "loki/common/printer.hpp"
#include
#include
#include
-
-namespace loki {
+namespace loki
+{
/// @brief Implements a common base class for PDDL objects.
///
/// Each PDDL object has an identifier.
@@ -50,11 +50,12 @@ namespace loki {
/// For example, loki detects semantic equivalence of a conjunction of atoms
/// but loki does not detect semantic equivalence of an arbitrary formula of atoms.
template
-class Base {
+class Base
+{
protected:
int m_identifier;
- explicit Base(int identifier) : m_identifier(identifier) { }
+ explicit Base(int identifier) : m_identifier(identifier) {}
friend Derived;
public:
@@ -66,49 +67,37 @@ class Base {
constexpr const auto& self() const { return static_cast(*this); }
- bool operator==(const Base& other) const {
- return self().is_structurally_equivalent_to_impl(other.self());
- }
+ bool operator==(const Base& other) const { return self().is_structurally_equivalent_to_impl(other.self()); }
- bool operator!=(const Base& other) const {
- return !(*this == other);
- }
+ bool operator!=(const Base& other) const { return !(*this == other); }
- bool operator<(const Base& other) const {
- return m_identifier < other.m_identifier;
- }
+ bool operator<(const Base& other) const { return m_identifier < other.m_identifier; }
- bool operator>(const Base& other) const {
- return m_identifier > other.m_identifier;
- }
+ bool operator>(const Base& other) const { return m_identifier > other.m_identifier; }
- size_t hash() const {
- return self().hash_impl();
- }
+ size_t hash() const { return self().hash_impl(); }
/// @brief Overload of the output stream insertion operator (operator<<).
- friend std::ostream& operator<<(std::ostream& os, const Base& element) {
+ friend std::ostream& operator<<(std::ostream& os, const Base& element)
+ {
os << element.str();
return os;
}
/// @brief Compute a string representation of this object.
- void str(std::ostringstream& out, const FormattingOptions& options) const {
- self().str_impl(out, options);
- }
+ void str(std::ostringstream& out, const FormattingOptions& options) const { self().str_impl(out, options); }
/// @brief Compute a string representation of this object.
- std::string str() const {
+ std::string str() const
+ {
std::ostringstream out;
- FormattingOptions options{0, 4};
+ FormattingOptions options { 0, 4 };
str(out, options);
return out.str();
}
/// @brief Returns the identifier
- int get_identifier() const {
- return m_identifier;
- }
+ int get_identifier() const { return m_identifier; }
};
}
diff --git a/include/loki/common/pddl/config.hpp b/include/loki/common/pddl/config.hpp
index b177b906..7a213f7b 100644
--- a/include/loki/common/pddl/config.hpp
+++ b/include/loki/common/pddl/config.hpp
@@ -18,14 +18,12 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_CONFIG_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_CONFIG_HPP_
-#include "error_reporting.hpp"
-
-#include "../ast/config.hpp"
-
+#include "loki/common/ast/config.hpp"
+#include "loki/common/pddl/error_reporting.hpp"
namespace loki
{
- typedef PDDLErrorHandlerImpl PDDLErrorHandler;
+typedef PDDLErrorHandlerImpl PDDLErrorHandler;
}
#endif
diff --git a/include/loki/common/pddl/context.hpp b/include/loki/common/pddl/context.hpp
index 1d32cd02..7ad151d5 100644
--- a/include/loki/common/pddl/context.hpp
+++ b/include/loki/common/pddl/context.hpp
@@ -18,30 +18,36 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_CONTEXT_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_CONTEXT_HPP_
-#include "position.hpp"
-#include "reference.hpp"
-#include "scope.hpp"
-#include "types.hpp"
+#include "loki/common/pddl/position.hpp"
+#include "loki/common/pddl/reference.hpp"
+#include "loki/common/pddl/scope.hpp"
+#include "loki/common/pddl/types.hpp"
namespace loki
{
- struct Context
- {
- // For the unique construction of PDDL objects
- PDDLFactories& factories;
- // For storing the positions in the input PDDL file
- PDDLPositionCache& positions;
- // For referencing to existing bindings
- ScopeStack& scopes;
- // For checking that certain PDDL objects were referenced at least once
- ReferencedPDDLObjects references;
- // For convenience, to avoid an additional parameter during semantic parsing
- pddl::Requirements requirements;
+struct Context
+{
+ // For the unique construction of PDDL objects
+ PDDLFactories& factories;
+ // For storing the positions in the input PDDL file
+ PDDLPositionCache& positions;
+ // For referencing to existing bindings
+ ScopeStack& scopes;
+ // For checking that certain PDDL objects were referenced at least once
+ ReferencedPDDLObjects references;
+ // For convenience, to avoid an additional parameter during semantic parsing
+ pddl::Requirements requirements;
- Context(PDDLFactories &factories_, PDDLPositionCache& positions_, ScopeStack &scopes_)
- : factories(factories_), positions(positions_), scopes(scopes_), references(ReferencedPDDLObjects()), requirements(nullptr) {}
- };
+ Context(PDDLFactories& factories_, PDDLPositionCache& positions_, ScopeStack& scopes_) :
+ factories(factories_),
+ positions(positions_),
+ scopes(scopes_),
+ references(ReferencedPDDLObjects()),
+ requirements(nullptr)
+ {
+ }
+};
}
diff --git a/include/loki/common/pddl/error_reporting.hpp b/include/loki/common/pddl/error_reporting.hpp
index 1bb774dc..c83c406c 100644
--- a/include/loki/common/pddl/error_reporting.hpp
+++ b/include/loki/common/pddl/error_reporting.hpp
@@ -18,13 +18,11 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_ERROR_REPORTING_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_ERROR_REPORTING_HPP_
-#include "../filesystem.hpp"
+#include "loki/common/filesystem.hpp"
#include
-
-#include
#include
-
+#include
// Clang-style error handling utilities
@@ -35,173 +33,166 @@
namespace loki
{
- using position_tagged = boost::spirit::x3::position_tagged;
+using position_tagged = boost::spirit::x3::position_tagged;
- template
- class PDDLErrorHandlerImpl
- {
- public:
-
- typedef Iterator iterator_type;
- using position_cache = boost::spirit::x3::position_cache>;
+template
+class PDDLErrorHandlerImpl
+{
+public:
+ typedef Iterator iterator_type;
+ using position_cache = boost::spirit::x3::position_cache>;
- PDDLErrorHandlerImpl(position_cache pos_cache, fs::path file = "", int tabs = 4)
- : pos_cache(pos_cache)
- , file(file)
- , tabs(tabs) {}
+ PDDLErrorHandlerImpl(position_cache pos_cache, fs::path file = "", int tabs = 4) : pos_cache(pos_cache), file(file), tabs(tabs) {}
- std::string operator()(Iterator err_pos, std::string const& error_message) const;
- std::string operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const;
- std::string operator()(position_tagged pos, std::string const& message) const
- {
- auto where = pos_cache.position_of(pos);
- return (*this)(where.begin(), where.end(), message);
- }
-
- boost::iterator_range position_of(position_tagged pos) const
- {
- return pos_cache.position_of(pos);
- }
+ std::string operator()(Iterator err_pos, std::string const& error_message) const;
+ std::string operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const;
+ std::string operator()(position_tagged pos, std::string const& message) const
+ {
+ auto where = pos_cache.position_of(pos);
+ return (*this)(where.begin(), where.end(), message);
+ }
- private:
+ boost::iterator_range position_of(position_tagged pos) const { return pos_cache.position_of(pos); }
- std::string print_file_line(std::size_t line) const;
- std::string print_line(Iterator line_start, Iterator last) const;
- std::string print_indicator(Iterator& line_start, Iterator last, char ind) const;
- Iterator get_line_start(Iterator first, Iterator pos) const;
- std::size_t position(Iterator i) const;
+private:
+ std::string print_file_line(std::size_t line) const;
+ std::string print_line(Iterator line_start, Iterator last) const;
+ std::string print_indicator(Iterator& line_start, Iterator last, char ind) const;
+ Iterator get_line_start(Iterator first, Iterator pos) const;
+ std::size_t position(Iterator i) const;
- position_cache pos_cache;
- std::string file;
- int tabs;
- };
+ position_cache pos_cache;
+ std::string file;
+ int tabs;
+};
- template
- std::string PDDLErrorHandlerImpl::print_file_line(std::size_t line) const
+template
+std::string PDDLErrorHandlerImpl::print_file_line(std::size_t line) const
+{
+ std::ostringstream err_out;
+ if (file != "")
{
- std::ostringstream err_out;
- if (file != "")
- {
- err_out << "In file " << file << ", ";
- }
- else
- {
- err_out << "In ";
- }
-
- err_out << "line " << line << ':' << std::endl;
- return err_out.str();
+ err_out << "In file " << file << ", ";
}
-
- template
- std::string PDDLErrorHandlerImpl::print_line(Iterator start, Iterator last) const
+ else
{
- std::ostringstream err_out;
- auto end = start;
- while (end != last)
- {
- auto c = *end;
- if (c == '\r' || c == '\n')
- break;
- else
- ++end;
- }
- typedef typename std::iterator_traits::value_type char_type;
- std::basic_string line{start, end};
- err_out << boost::spirit::x3::to_utf8(line) << std::endl;
- return err_out.str();
+ err_out << "In ";
}
- template
- std::string PDDLErrorHandlerImpl::print_indicator(Iterator& start, Iterator last, char ind) const
+ err_out << "line " << line << ':' << std::endl;
+ return err_out.str();
+}
+
+template
+std::string PDDLErrorHandlerImpl::print_line(Iterator start, Iterator last) const
+{
+ std::ostringstream err_out;
+ auto end = start;
+ while (end != last)
{
- std::ostringstream err_out;
- for (; start != last; ++start)
- {
- auto c = *start;
- if (c == '\r' || c == '\n')
- break;
- else if (c == '\t')
- for (int i = 0; i < tabs; ++i)
- err_out << ind;
- else
- err_out << ind;
- }
- return err_out.str();
+ auto c = *end;
+ if (c == '\r' || c == '\n')
+ break;
+ else
+ ++end;
}
+ typedef typename std::iterator_traits::value_type char_type;
+ std::basic_string line { start, end };
+ err_out << boost::spirit::x3::to_utf8(line) << std::endl;
+ return err_out.str();
+}
- template
- inline Iterator PDDLErrorHandlerImpl::get_line_start(Iterator first, Iterator pos) const
+template
+std::string PDDLErrorHandlerImpl::print_indicator(Iterator& start, Iterator last, char ind) const
+{
+ std::ostringstream err_out;
+ for (; start != last; ++start)
{
- Iterator latest = first;
- for (Iterator i = first; i != pos;)
- if (*i == '\r' || *i == '\n')
- latest = ++i;
- else
- ++i;
- return latest;
+ auto c = *start;
+ if (c == '\r' || c == '\n')
+ break;
+ else if (c == '\t')
+ for (int i = 0; i < tabs; ++i)
+ err_out << ind;
+ else
+ err_out << ind;
}
+ return err_out.str();
+}
- template
- std::size_t PDDLErrorHandlerImpl::position(Iterator i) const
- {
- std::size_t line { 1 };
- typename std::iterator_traits::value_type prev { 0 };
+template
+inline Iterator PDDLErrorHandlerImpl::get_line_start(Iterator first, Iterator pos) const
+{
+ Iterator latest = first;
+ for (Iterator i = first; i != pos;)
+ if (*i == '\r' || *i == '\n')
+ latest = ++i;
+ else
+ ++i;
+ return latest;
+}
+
+template
+std::size_t PDDLErrorHandlerImpl::position(Iterator i) const
+{
+ std::size_t line { 1 };
+ typename std::iterator_traits::value_type prev { 0 };
- for (Iterator pos = pos_cache.first(); pos != i; ++pos) {
- auto c = *pos;
- switch (c) {
+ for (Iterator pos = pos_cache.first(); pos != i; ++pos)
+ {
+ auto c = *pos;
+ switch (c)
+ {
case '\n':
- if (prev != '\r') ++line;
+ if (prev != '\r')
+ ++line;
break;
case '\r':
++line;
break;
default:
break;
- }
- prev = c;
}
-
- return line;
+ prev = c;
}
- template
- std::string PDDLErrorHandlerImpl::operator()(
- Iterator err_pos, std::string const& error_message) const
- {
- Iterator first = pos_cache.first();
- Iterator last = pos_cache.last();
-
- std::ostringstream err_out;
- err_out << print_file_line(position(err_pos));
- err_out << error_message << std::endl;
-
- Iterator start = get_line_start(first, err_pos);
- err_out << print_line(start, last);
- err_out << print_indicator(start, err_pos, '_');
- err_out << "^_" << std::endl;
- return err_out.str();
- }
+ return line;
+}
- template
- std::string PDDLErrorHandlerImpl::operator()(
- Iterator err_first, Iterator err_last, std::string const& error_message) const
- {
- Iterator first = pos_cache.first();
- Iterator last = pos_cache.last();
-
- std::ostringstream err_out;
- err_out << print_file_line(position(err_first));
- err_out << error_message << std::endl;
-
- Iterator start = get_line_start(first, err_first);
- err_out << print_line(start, last);
- err_out << print_indicator(start, err_first, ' ');
- err_out << print_indicator(start, err_last, '~');
- err_out << " <<-- Here" << std::endl;
- return err_out.str();
- }
+template
+std::string PDDLErrorHandlerImpl::operator()(Iterator err_pos, std::string const& error_message) const
+{
+ Iterator first = pos_cache.first();
+ Iterator last = pos_cache.last();
+
+ std::ostringstream err_out;
+ err_out << print_file_line(position(err_pos));
+ err_out << error_message << std::endl;
+
+ Iterator start = get_line_start(first, err_pos);
+ err_out << print_line(start, last);
+ err_out << print_indicator(start, err_pos, '_');
+ err_out << "^_" << std::endl;
+ return err_out.str();
+}
+
+template
+std::string PDDLErrorHandlerImpl::operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const
+{
+ Iterator first = pos_cache.first();
+ Iterator last = pos_cache.last();
+
+ std::ostringstream err_out;
+ err_out << print_file_line(position(err_first));
+ err_out << error_message << std::endl;
+
+ Iterator start = get_line_start(first, err_first);
+ err_out << print_line(start, last);
+ err_out << print_indicator(start, err_first, ' ');
+ err_out << print_indicator(start, err_last, '~');
+ err_out << " <<-- Here" << std::endl;
+ return err_out.str();
+}
}
diff --git a/include/loki/common/pddl/garbage_collected_factory.hpp b/include/loki/common/pddl/garbage_collected_factory.hpp
index 6f82196e..51b3a9cf 100644
--- a/include/loki/common/pddl/garbage_collected_factory.hpp
+++ b/include/loki/common/pddl/garbage_collected_factory.hpp
@@ -19,14 +19,14 @@
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_GARBAGE_COLLECTED_FACTORY_HPP_
#include
-#include
-#include
#include
#include
#include
+#include
+#include
-
-namespace loki {
+namespace loki
+{
/* Not used anymore but still a useful piece of code. */
@@ -35,18 +35,20 @@ namespace loki {
/// Custom deleter idea: https://stackoverflow.com/questions/49782011/herb-sutters-10-liner-with-cleanup
/// TODO: improve the quality of the answer on stackoverflow
template
-class GarbageCollectedFactory {
+class GarbageCollectedFactory
+{
private:
-
/// @brief Encapsulates the data of a single type.
template
- struct PerTypeCache {
+ struct PerTypeCache
+ {
std::unordered_set uniqueness;
std::unordered_map> identifier_to_object;
};
/// @brief Encapsulates the data of all types.
- struct Cache {
+ struct Cache
+ {
std::tuple...> data;
// Identifiers are shared across types since types can be polymorphic
int count = 0;
@@ -57,8 +59,7 @@ class GarbageCollectedFactory {
std::shared_ptr m_cache;
public:
- GarbageCollectedFactory()
- : m_cache(std::make_shared()) { }
+ GarbageCollectedFactory() : m_cache(std::make_shared()) {}
/// @brief Gets a shared reference to the object of type T with the given arguments.
/// If such an object does not exists then it creates one.
@@ -66,7 +67,8 @@ class GarbageCollectedFactory {
/// @param ...args
/// @return
template
- [[nodiscard]] std::shared_ptr get_or_create(Args... args) {
+ [[nodiscard]] std::shared_ptr get_or_create(Args... args)
+ {
/* we must declare sp before locking the mutex
s.t. the deleter is called after the mutex was released in case of stack unwinding. */
std::shared_ptr sp;
@@ -76,7 +78,8 @@ class GarbageCollectedFactory {
int identifier = m_cache->count;
auto key = T(identifier, args...);
const auto [it, inserted] = t_cache.uniqueness.insert(key);
- if (!inserted) {
+ if (!inserted)
+ {
assert(t_cache.identifier_to_object.count(it->get_identifier()));
return t_cache.identifier_to_object.at(it->get_identifier()).lock();
}
@@ -84,27 +87,26 @@ class GarbageCollectedFactory {
/* Must explicitly call the constructor of T to give exclusive access to the factory. */
// Extensions: To ensure that the memory for T and the control block is allocated once,
// we could use std::allocated_shared and provide a custom allocator.
- sp = std::shared_ptr(
- new T(identifier, args...),
- [cache=m_cache, identifier](T* x)
- {
- {
- std::lock_guard hold(cache->mutex);
- auto& t_cache = std::get>(cache->data);
- t_cache.uniqueness.erase(*x);
- t_cache.identifier_to_object.erase(identifier);
- }
- /* After cache removal, we can call the objects destructor
- and recursively call the deleter of children if their ref count goes to 0 */
- delete x;
- }
- );
+ sp = std::shared_ptr(new T(identifier, args...),
+ [cache = m_cache, identifier](T* x)
+ {
+ {
+ std::lock_guard hold(cache->mutex);
+ auto& t_cache = std::get>(cache->data);
+ t_cache.uniqueness.erase(*x);
+ t_cache.identifier_to_object.erase(identifier);
+ }
+ /* After cache removal, we can call the objects destructor
+ and recursively call the deleter of children if their ref count goes to 0 */
+ delete x;
+ });
t_cache.identifier_to_object.emplace(identifier, sp);
return sp;
}
template
- size_t size() const {
+ size_t size() const
+ {
std::lock_guard hold(m_cache->mutex);
auto& t_cache = std::get>(m_cache->data);
return t_cache.uniqueness.size();
diff --git a/include/loki/common/pddl/persistent_factory.hpp b/include/loki/common/pddl/persistent_factory.hpp
index 66832392..af885928 100644
--- a/include/loki/common/pddl/persistent_factory.hpp
+++ b/include/loki/common/pddl/persistent_factory.hpp
@@ -18,18 +18,18 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_PERSISTENT_FACTORY_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_PERSISTENT_FACTORY_HPP_
-#include "declarations.hpp"
-#include "segmented_vector.hpp"
+#include "loki/common/pddl/declarations.hpp"
+#include "loki/common/pddl/segmented_vector.hpp"
-#include
#include
#include
#include
#include
+#include
#include
-
-namespace loki {
+namespace loki
+{
/// @brief The PersistentFactory class manages unique objects in a persistent
/// and efficient manner, utilizing a combination of unordered_set for
/// uniqueness checks and SegmentedVector for continuous and
@@ -37,21 +37,20 @@ namespace loki {
/// @tparam HolderType is the nested type which can be an std::variant.
/// @tparam N is the number of elements per segment
template
-class PersistentFactory {
+class PersistentFactory
+{
private:
template
- struct DerferencedHash {
- std::size_t operator()(const T* ptr) const {
- return std::hash()(*ptr);
- }
+ struct DerferencedHash
+ {
+ std::size_t operator()(const T* ptr) const { return std::hash()(*ptr); }
};
/// @brief Equality comparison of the objects underlying the pointers.
template
- struct DereferencedEquality {
- bool operator()(const T* left, const T* right) const {
- return *left == *right;
- }
+ struct DereferencedEquality
+ {
+ bool operator()(const T* left, const T* right) const { return *left == *right; }
};
// We use an unordered_set to test for uniqueness.
@@ -68,30 +67,32 @@ class PersistentFactory {
/// @brief Returns a pointer to an existing object
/// or creates it before if it does not exist.
template
- [[nodiscard]] HolderType const* get_or_create(Args&&... args) {
+ [[nodiscard]] HolderType const* get_or_create(Args&&... args)
+ {
std::lock_guard hold(m_mutex);
/* Construct and insert the element in persistent memory. */
size_t identifier = m_count;
// Ensure that element with identifier i is stored at position i.
- assert((identifier == (m_persistent_vector.size()-1))
- || (identifier == m_persistent_vector.size()));
+ assert((identifier == (m_persistent_vector.size() - 1)) || (identifier == m_persistent_vector.size()));
// Explicitly call the constructor of T to give exclusive access to the factory.
auto element = HolderType(std::move(SubType(identifier, std::forward(args)...)));
bool overwrite_last_element = (identifier == m_persistent_vector.size() - 1);
// The pointer to the location in persistent memory.
- const auto* element_ptr = overwrite_last_element
- ? &(m_persistent_vector[identifier] = std::move(element))
- : &(m_persistent_vector.push_back(std::move(element)));
+ const auto* element_ptr =
+ overwrite_last_element ? &(m_persistent_vector[identifier] = std::move(element)) : &(m_persistent_vector.push_back(std::move(element)));
assert(element_ptr);
/* Test for uniqueness */
auto it = m_uniqueness_set.find(element_ptr);
- if (it == m_uniqueness_set.end()) {
+ if (it == m_uniqueness_set.end())
+ {
// Element is unique!
m_uniqueness_set.emplace(element_ptr);
// Validate the element by increasing the identifier to the next free position
++m_count;
assert(m_uniqueness_set.size() == m_count);
- } else {
+ }
+ else
+ {
// Element is not unique!
// Return the existing one.
element_ptr = *it;
@@ -100,20 +101,19 @@ class PersistentFactory {
}
/// @brief Returns a pointer to an existing object with the given identifier.
- [[nodiscard]] HolderType const* get(size_t identifier) const {
- if (identifier < m_persistent_vector.size()) {
+ [[nodiscard]] HolderType const* get(size_t identifier) const
+ {
+ if (identifier < m_persistent_vector.size())
+ {
return &(m_persistent_vector[identifier]);
}
throw std::invalid_argument("invalid identifier");
}
- size_t size() const {
- return m_count;
- }
+ size_t size() const { return m_count; }
};
}
-
#endif
diff --git a/include/loki/common/pddl/position.hpp b/include/loki/common/pddl/position.hpp
index 9086b291..84061730 100644
--- a/include/loki/common/pddl/position.hpp
+++ b/include/loki/common/pddl/position.hpp
@@ -18,37 +18,37 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_POSITION_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_POSITION_HPP_
-#include "config.hpp"
-#include "declarations.hpp"
-
-#include "../ast/error_reporting.hpp"
-#include "../filesystem.hpp"
+#include "loki/common/ast/error_reporting.hpp"
+#include "loki/common/filesystem.hpp"
+#include "loki/common/pddl/config.hpp"
+#include "loki/common/pddl/declarations.hpp"
#include
-
-namespace loki {
+namespace loki
+{
template
using PositionMapType = std::unordered_map, PositionList>;
/// @brief Stores all occurrences of a PDDL object in the input file for each PDDL type T.
template
-class PositionCache {
- private:
- std::tuple...> m_positions;
+class PositionCache
+{
+private:
+ std::tuple...> m_positions;
- PDDLErrorHandler m_error_handler;
+ PDDLErrorHandler m_error_handler;
- public:
- PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs=4);
+public:
+ PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs = 4);
- template
- void push_back(const PDDLElement& element, const Position& position);
+ template
+ void push_back(const PDDLElement& element, const Position& position);
- template
- PositionList get(const PDDLElement& element) const;
+ template
+ PositionList get(const PDDLElement& element) const;
- const PDDLErrorHandler& get_error_handler() const;
+ const PDDLErrorHandler& get_error_handler() const;
};
}
diff --git a/include/loki/common/pddl/position.tpp b/include/loki/common/pddl/position.tpp
index 4a825295..ce396a86 100644
--- a/include/loki/common/pddl/position.tpp
+++ b/include/loki/common/pddl/position.tpp
@@ -15,34 +15,39 @@
* along with this program. If not, see .
*/
-
-namespace loki {
+namespace loki
+{
template
-PositionCache::PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs)
- : m_error_handler(PDDLErrorHandler(error_handler.get_error_handler().get_position_cache(), file, tabs)) { }
-
+PositionCache::PositionCache(const X3ErrorHandler& error_handler, const fs::path& file, int tabs) :
+ m_error_handler(PDDLErrorHandler(error_handler.get_error_handler().get_position_cache(), file, tabs))
+{
+}
template
template
-void PositionCache::push_back(const PDDLElement& element, const Position& position) {
+void PositionCache::push_back(const PDDLElement& element, const Position& position)
+{
auto& t_positions = std::get>(m_positions);
t_positions[element].push_back(position);
}
template
template
-PositionList PositionCache::get(const PDDLElement& element) const {
+PositionList PositionCache::get(const PDDLElement& element) const
+{
auto& t_positions = std::get>(m_positions);
auto it = t_positions.find(element);
- if (it != t_positions.end()) {
+ if (it != t_positions.end())
+ {
return it->second;
}
return {};
}
template
-const PDDLErrorHandler& PositionCache::get_error_handler() const {
+const PDDLErrorHandler& PositionCache::get_error_handler() const
+{
return m_error_handler;
}
diff --git a/include/loki/common/pddl/reference.hpp b/include/loki/common/pddl/reference.hpp
index 6fa2a38a..4cfae8af 100644
--- a/include/loki/common/pddl/reference.hpp
+++ b/include/loki/common/pddl/reference.hpp
@@ -18,24 +18,23 @@
#ifndef LOKI_INCLUDE_LOKI_COMMON_PDDL_REFERENCE_HPP_
#define LOKI_INCLUDE_LOKI_COMMON_PDDL_REFERENCE_HPP_
-#include "../../common/ast/config.hpp"
-#include "../../domain/pddl/object.hpp"
-#include "../../domain/pddl/predicate.hpp"
-#include "../../domain/pddl/requirements.hpp"
-#include "../../domain/pddl/function_skeleton.hpp"
-#include "../../domain/pddl/variable.hpp"
+#include "loki/common/ast/config.hpp"
+#include "loki/domain/pddl/function_skeleton.hpp"
+#include "loki/domain/pddl/object.hpp"
+#include "loki/domain/pddl/predicate.hpp"
+#include "loki/domain/pddl/requirements.hpp"
+#include "loki/domain/pddl/variable.hpp"
#include
-
#include
-#include
+#include
#include
-#include
#include
-#include
-
+#include
+#include
-namespace loki {
+namespace loki
+{
/// @brief Encapsulates tracking of references of PDDL objects.
///
/// Example usage:
@@ -45,29 +44,26 @@ namespace loki {
/// 3. Verify that all variables are untracked, meaning
/// that they were referenced at least once.
template
-class References {
- private:
- std::tuple...> references;
+class References
+{
+private:
+ std::tuple...> references;
- public:
- /// @brief Returns a pointer if it exists.
- template
- bool exists(T reference) const;
+public:
+ /// @brief Returns a pointer if it exists.
+ template
+ bool exists(T reference) const;
- /// @brief Inserts a pointer of type T
- template
- void track(T reference);
+ /// @brief Inserts a pointer of type T
+ template
+ void track(T reference);
- /// @brief Erases a pointer of Type T
- template
- void untrack(T reference);
+ /// @brief Erases a pointer of Type T
+ template
+ void untrack(T reference);
};
-using ReferencedPDDLObjects = References;
+using ReferencedPDDLObjects = References;
}
diff --git a/include/loki/common/pddl/reference.tpp b/include/loki/common/pddl/reference.tpp
index cc8df305..0dca6ee7 100644
--- a/include/loki/common/pddl/reference.tpp
+++ b/include/loki/common/pddl/reference.tpp
@@ -15,29 +15,29 @@
* along with this program. If not, see .
*/
-
-
-namespace loki {
+namespace loki
+{
template
template
-bool References::exists(T reference) const {
+bool References::exists(T reference) const
+{
const auto& t_references = std::get>(references);
return t_references.count(reference);
}
-
template