From c9197dbf6687b026d0325c958c10fcfe20899aeb Mon Sep 17 00:00:00 2001 From: Dominik Drexler Date: Tue, 21 Nov 2023 14:57:58 +0100 Subject: [PATCH] removed more serialization code --- include/dlplan/core.h | 197 -------------------------------- include/dlplan/novelty.h | 35 ------ src/core/atom.cpp | 5 - src/core/base_element.cpp | 3 - src/core/boolean.cpp | 4 - src/core/concept.cpp | 6 - src/core/concept_denotation.cpp | 2 - src/core/constant.cpp | 4 - src/core/core.cpp | 3 - src/core/instance_info.cpp | 2 - src/core/numerical.cpp | 1 - src/core/object.cpp | 1 - src/core/predicate.cpp | 1 - src/core/role.cpp | 1 - src/core/role_denotation.cpp | 1 - src/core/state.cpp | 2 - src/novelty/novelty_base.cpp | 1 - src/novelty/tuple_graph.cpp | 9 -- src/novelty/tuple_node.cpp | 8 -- 19 files changed, 286 deletions(-) diff --git a/include/dlplan/core.h b/include/dlplan/core.h index c3e3d06d..5b7691e7 100644 --- a/include/dlplan/core.h +++ b/include/dlplan/core.h @@ -38,88 +38,6 @@ class SyntacticElementFactoryImpl; } - -// Forward declarations of template spezializations for serialization -namespace boost::serialization { - class access; - - template - void serialize(Archive& ar, dlplan::core::ConceptDenotation& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::RoleDenotation& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::DenotationsCaches& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Constant& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Predicate& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Object& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Atom& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::State& t, const unsigned int version); - - template - void serialize(Archive& ar, std::pair& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const std::pair* t, const unsigned int version); - template - void load_construct_data(Archive& ar, std::pair* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::VocabularyInfo& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::InstanceInfo& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::BaseElement& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const dlplan::core::BaseElement* t, const unsigned int version); - template - void load_construct_data(Archive& ar, dlplan::core::BaseElement* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Concept& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const dlplan::core::Concept* t, const unsigned int version); - template - void load_construct_data(Archive& ar, dlplan::core::Concept* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Role& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const dlplan::core::Role* t, const unsigned int version); - template - void load_construct_data(Archive& ar, dlplan::core::Role* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Boolean& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const dlplan::core::Boolean* t, const unsigned int version); - template - void load_construct_data(Archive& ar, dlplan::core::Boolean* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::Numerical& t, const unsigned int version); - template - void save_construct_data(Archive& ar, const dlplan::core::Numerical* t, const unsigned int version); - template - void load_construct_data(Archive& ar, dlplan::core::Numerical* t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::core::SyntacticElementFactory& t, const unsigned int version); -} - - namespace dlplan::core { using ConceptDenotations = std::vector; using RoleDenotations = std::vector; @@ -213,13 +131,6 @@ class ConceptDenotation { int m_num_objects; dlplan::utils::DynamicBitset m_data; - /// @brief Constructor for serialization. - ConceptDenotation(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, ConceptDenotation& t, const unsigned int version); - public: explicit ConceptDenotation(int num_objects); ConceptDenotation(const ConceptDenotation& other); @@ -286,13 +197,6 @@ class RoleDenotation { int m_num_objects; dlplan::utils::DynamicBitset m_data; - /// @brief Constructor for serialization. - RoleDenotation(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, RoleDenotation& t, const unsigned int version); - public: explicit RoleDenotation(int num_objects); RoleDenotation(const RoleDenotation& other); @@ -456,16 +360,9 @@ class Constant { ///< The index of the constant. ConstantIndex m_index; - /// @brief Constructor for serialization. - Constant(); - Constant(const std::string& name, ConstantIndex index); friend class VocabularyInfo; - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, Constant& t, const unsigned int version); - public: Constant(const Constant& other); Constant& operator=(const Constant& other); @@ -524,16 +421,9 @@ class Predicate { int m_arity; bool m_is_static; - /// @brief Constructor for serialization. - Predicate(); - Predicate(const std::string& name, PredicateIndex index, int arity, bool is_static=false); friend class VocabularyInfo; - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, Predicate& t, const unsigned int version); - public: Predicate(const Predicate& other); Predicate& operator=(const Predicate& other); @@ -585,9 +475,6 @@ class VocabularyInfo { std::unordered_map m_constant_name_to_index; std::vector m_constants; - template - friend void boost::serialization::serialize(Archive& ar, VocabularyInfo& t, const unsigned int version); - public: VocabularyInfo(); VocabularyInfo(const VocabularyInfo& other); @@ -632,16 +519,9 @@ class Object { std::string m_name; ObjectIndex m_index; - /// @brief Constructor for serialization. - Object(); - Object(const std::string& name, int index); friend class InstanceInfo; - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, Object& t, const unsigned int version); - public: Object(const Object& other); Object& operator=(const Object& other); @@ -682,9 +562,6 @@ class Atom { ObjectIndices m_object_indices; bool m_is_static; - /// @brief Constructor for serialization. - Atom(); - Atom(const std::string& name, AtomIndex index, PredicateIndex predicate_index, @@ -692,9 +569,6 @@ class Atom { bool is_static=false); friend class InstanceInfo; - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, Atom& t, const unsigned int version); public: Atom(const Atom& other); @@ -745,17 +619,10 @@ class InstanceInfo { std::unordered_map m_object_name_to_index; std::vector m_objects; - /// @brief Constructor for serialization. - InstanceInfo(); - const Atom& add_atom(PredicateIndex predicate_index, const ObjectIndices& object_indices, bool is_static); const Atom& add_atom(const Predicate& predicate, const std::vector& objects, bool is_static); const Atom& add_atom(const std::string& predicate_name, const std::vector& object_names, bool is_static); - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, InstanceInfo& t, const unsigned int version); - public: InstanceInfo(std::shared_ptr vocabulary_info, InstanceIndex index=-1); InstanceInfo(const InstanceInfo& other); @@ -826,13 +693,6 @@ class State { AtomIndices m_atom_indices; int m_index; - /// @brief Constructor for serialization. - State(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, State& t, const unsigned int version); - public: State(std::shared_ptr instance_info, const std::vector& atoms, StateIndex index=-1); State(std::shared_ptr instance_info, const AtomIndices& atom_indices, StateIndex index=-1); @@ -887,16 +747,6 @@ class BaseElement { BaseElement(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static); - /// @brief Constructor for serialization. - BaseElement(); - - template - friend void boost::serialization::serialize(Archive& ar, BaseElement& t, const unsigned int version); - template - friend void boost::serialization::save_construct_data(Archive & ar, const BaseElement* t, const unsigned int version); - template - friend void boost::serialization::load_construct_data(Archive & ar, BaseElement* t, const unsigned int version); - public: virtual ~BaseElement(); @@ -939,19 +789,9 @@ class Concept : public BaseElement { protected: Concept(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static); - /// @brief Constructor for serialization. - Concept(); - virtual ConceptDenotation evaluate_impl(const State& , DenotationsCaches& ) const = 0; virtual ConceptDenotations evaluate_impl(const States& , DenotationsCaches& ) const = 0; - template - friend void boost::serialization::serialize(Archive& ar, Concept& t, const unsigned int version); - template - friend void boost::serialization::save_construct_data(Archive & ar, const Concept* t, const unsigned int version); - template - friend void boost::serialization::load_construct_data(Archive & ar, Concept* t, const unsigned int version); - public: Concept(const Concept& other); Concept& operator=(const Concept& other); @@ -974,19 +814,9 @@ class Role : public BaseElement { protected: Role(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static); - /// @brief Constructor for serialization. - Role(); - virtual RoleDenotation evaluate_impl(const State& , DenotationsCaches& ) const = 0; virtual RoleDenotations evaluate_impl(const States& , DenotationsCaches& ) const = 0; - template - friend void boost::serialization::serialize(Archive& ar, Role& t, const unsigned int version); - template - friend void boost::serialization::save_construct_data(Archive & ar, const Role* t, const unsigned int version); - template - friend void boost::serialization::load_construct_data(Archive & ar, Role* t, const unsigned int version); - public: Role(const Role& other); Role& operator=(const Role& other); @@ -1009,19 +839,9 @@ class Numerical : public BaseElement { protected: Numerical(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static); - /// @brief Constructor for serialization. - Numerical(); - virtual int evaluate_impl(const State& , DenotationsCaches& ) const = 0; virtual NumericalDenotations evaluate_impl(const States& , DenotationsCaches& ) const = 0; - template - friend void boost::serialization::serialize(Archive& ar, Numerical& t, const unsigned int version); - template - friend void boost::serialization::save_construct_data(Archive & ar, const Numerical* t, const unsigned int version); - template - friend void boost::serialization::load_construct_data(Archive & ar, Numerical* t, const unsigned int version); - public: Numerical(const Numerical& other); Numerical& operator=(const Numerical& other); @@ -1044,19 +864,9 @@ class Boolean : public BaseElement { protected: Boolean(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static); - /// @brief Constructor for serialization. - Boolean(); - virtual bool evaluate_impl(const State& , DenotationsCaches& ) const = 0; virtual BooleanDenotations evaluate_impl(const States& , DenotationsCaches& ) const = 0; - template - friend void boost::serialization::serialize(Archive& ar, Boolean& t, const unsigned int version); - template - friend void boost::serialization::save_construct_data(Archive & ar, const Boolean* t, const unsigned int version); - template - friend void boost::serialization::load_construct_data(Archive & ar, Boolean* t, const unsigned int version); - public: Boolean(const Boolean& other); Boolean& operator=(const Boolean& other); @@ -1078,13 +888,6 @@ class SyntacticElementFactory { private: dlplan::utils::pimpl m_pImpl; - /// @brief Constructor for serialization - SyntacticElementFactory(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, SyntacticElementFactory& t, const unsigned int version); - public: SyntacticElementFactory(std::shared_ptr vocabulary_info); SyntacticElementFactory(const SyntacticElementFactory& other); diff --git a/include/dlplan/novelty.h b/include/dlplan/novelty.h index 44f5b743..24704ff8 100644 --- a/include/dlplan/novelty.h +++ b/include/dlplan/novelty.h @@ -20,21 +20,6 @@ class TupleGraph; } -// Forward declarations of template spezializations for serialization -namespace boost::serialization { - class access; - - template - void serialize(Archive& ar, dlplan::novelty::NoveltyBase& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::novelty::TupleNode& t, const unsigned int version); - - template - void serialize(Archive& ar, dlplan::novelty::TupleGraph& t, const unsigned int version); -} - - namespace dlplan::novelty { using AtomIndex = int; @@ -55,13 +40,6 @@ class NoveltyBase int m_num_atoms; int m_arity; - /// @brief Constructor for serialization. - NoveltyBase(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, NoveltyBase& t, const unsigned int version); - public: NoveltyBase(int num_atoms, int arity); NoveltyBase(const NoveltyBase &other); @@ -180,9 +158,6 @@ class TupleNode TupleNodeIndices m_predecessors; TupleNodeIndices m_successors; - /// @brief Constructor for serialization. - TupleNode(); - TupleNode(TupleNodeIndex index, TupleIndex tuple_index, const state_space::StateIndices &state_indices); TupleNode(TupleNodeIndex index, TupleIndex tuple_index, state_space::StateIndices &&state_indices); @@ -191,9 +166,6 @@ class TupleNode friend class TupleGraphBuilder; friend class TupleGraph; - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, TupleNode& t, const unsigned int version); public: TupleNode(const TupleNode &other); @@ -238,13 +210,6 @@ class TupleGraph std::vector m_node_indices_by_distance; std::vector m_state_indices_by_distance; - /// @brief Constructor for serialization. - TupleGraph(); - - friend class boost::serialization::access; - template - friend void boost::serialization::serialize(Archive& ar, TupleGraph& t, const unsigned int version); - public: TupleGraph( std::shared_ptr novelty_base, diff --git a/src/core/atom.cpp b/src/core/atom.cpp index a670f486..2f628b1a 100644 --- a/src/core/atom.cpp +++ b/src/core/atom.cpp @@ -3,9 +3,6 @@ #include "../utils/collections.h" #include "../utils/logging.h" -#include -#include - #include #include @@ -14,8 +11,6 @@ using namespace std::string_literals; namespace dlplan::core { -Atom::Atom() : m_name(""), m_index(-1), m_predicate_index(-1), m_object_indices(ObjectIndices()), m_is_static(false) { } - Atom::Atom( const std::string& name, AtomIndex index, diff --git a/src/core/base_element.cpp b/src/core/base_element.cpp index 2dc95ab2..3ec29b54 100644 --- a/src/core/base_element.cpp +++ b/src/core/base_element.cpp @@ -1,13 +1,10 @@ #include "../../include/dlplan/core.h" -#include #include namespace dlplan::core { -BaseElement::BaseElement() { } - BaseElement::BaseElement(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) : m_vocabulary_info(vocabulary_info), m_index(index), m_is_static(is_static) { } diff --git a/src/core/boolean.cpp b/src/core/boolean.cpp index fc4174b8..da1167cd 100644 --- a/src/core/boolean.cpp +++ b/src/core/boolean.cpp @@ -1,11 +1,7 @@ #include "../../include/dlplan/core.h" -#include - namespace dlplan::core { -Boolean::Boolean() { } - Boolean::Boolean(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) : BaseElement(vocabulary_info, index, is_static) { } diff --git a/src/core/concept.cpp b/src/core/concept.cpp index 053e5371..bda472eb 100644 --- a/src/core/concept.cpp +++ b/src/core/concept.cpp @@ -1,13 +1,7 @@ #include "../../include/dlplan/core.h" -#include -#include -#include -#include - namespace dlplan::core { -Concept::Concept() { } Concept::Concept(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) : BaseElement(vocabulary_info, index, is_static) { diff --git a/src/core/concept_denotation.cpp b/src/core/concept_denotation.cpp index e6f89509..00fef804 100644 --- a/src/core/concept_denotation.cpp +++ b/src/core/concept_denotation.cpp @@ -11,8 +11,6 @@ namespace dlplan::core { -ConceptDenotation::ConceptDenotation() : m_num_objects(0), m_data(utils::DynamicBitset(0)) { } - ConceptDenotation::ConceptDenotation(int num_objects) : m_num_objects(num_objects), m_data(utils::DynamicBitset(num_objects)) { } diff --git a/src/core/constant.cpp b/src/core/constant.cpp index 6c7009d8..cd3c0c38 100644 --- a/src/core/constant.cpp +++ b/src/core/constant.cpp @@ -1,13 +1,9 @@ #include "../../include/dlplan/core.h" -#include -#include - #include namespace dlplan::core { -Constant::Constant() : m_name(""), m_index(-1) { } Constant::Constant(const std::string& name, ConstantIndex index) : m_name(name), m_index(index) { } diff --git a/src/core/core.cpp b/src/core/core.cpp index 8ca58801..30eda528 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -48,9 +48,6 @@ size_t hash_impl>::operator()(const std::vector& data) con return dlplan::utils::hash>()(data); } -SyntacticElementFactory::SyntacticElementFactory() - : m_pImpl(nullptr) { } - SyntacticElementFactory::SyntacticElementFactory(std::shared_ptr vocabulary_info) : m_pImpl(SyntacticElementFactoryImpl(vocabulary_info)) { } diff --git a/src/core/instance_info.cpp b/src/core/instance_info.cpp index 4be3de5c..e619cd68 100644 --- a/src/core/instance_info.cpp +++ b/src/core/instance_info.cpp @@ -24,8 +24,6 @@ static std::string compute_atom_name(const Predicate& predicate, const std::vect return ss.str(); } -InstanceInfo::InstanceInfo() : m_vocabulary_info(nullptr), m_index(-1) { } - InstanceInfo::InstanceInfo(std::shared_ptr vocabulary_info, InstanceIndex index) : m_vocabulary_info(vocabulary_info), m_index(index) { } diff --git a/src/core/numerical.cpp b/src/core/numerical.cpp index c7e406c2..e3733c52 100644 --- a/src/core/numerical.cpp +++ b/src/core/numerical.cpp @@ -2,7 +2,6 @@ namespace dlplan::core { -Numerical::Numerical() { } Numerical::Numerical(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) : BaseElement(vocabulary_info, index, is_static) { diff --git a/src/core/object.cpp b/src/core/object.cpp index 8340d349..600fcf1f 100644 --- a/src/core/object.cpp +++ b/src/core/object.cpp @@ -4,7 +4,6 @@ namespace dlplan::core { -Object::Object() : m_name(""), m_index(-1) { } Object::Object(const std::string& name, ObjectIndex index) : m_name(name), m_index(index) { } diff --git a/src/core/predicate.cpp b/src/core/predicate.cpp index d1aa5e73..900c6d8c 100644 --- a/src/core/predicate.cpp +++ b/src/core/predicate.cpp @@ -4,7 +4,6 @@ namespace dlplan::core { -Predicate::Predicate() : m_name(""), m_index(-1), m_arity(0), m_is_static(false) { } Predicate::Predicate(const std::string& name, PredicateIndex index, int arity, bool is_static) : m_name(name), m_index(index), m_arity(arity), m_is_static(is_static) { } diff --git a/src/core/role.cpp b/src/core/role.cpp index 7abb0cd7..71f8b247 100644 --- a/src/core/role.cpp +++ b/src/core/role.cpp @@ -2,7 +2,6 @@ namespace dlplan::core { -Role::Role() { } Role::Role(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) : BaseElement(vocabulary_info, index, is_static) { diff --git a/src/core/role_denotation.cpp b/src/core/role_denotation.cpp index 25b3d0be..fc58b3e4 100644 --- a/src/core/role_denotation.cpp +++ b/src/core/role_denotation.cpp @@ -8,7 +8,6 @@ namespace dlplan::core { -RoleDenotation::RoleDenotation() : m_num_objects(0), m_data(utils::DynamicBitset(0)) { } RoleDenotation::RoleDenotation(int num_objects) : m_num_objects(num_objects), m_data(utils::DynamicBitset(num_objects * num_objects)) { } diff --git a/src/core/state.cpp b/src/core/state.cpp index 37618456..0668ca6d 100644 --- a/src/core/state.cpp +++ b/src/core/state.cpp @@ -16,8 +16,6 @@ static AtomIndices sort_atom_idxs(AtomIndices&& atom_idxs) { return atom_idxs; } -State::State() : m_instance_info(nullptr), m_atom_indices(AtomIndices()), m_index(-1) { } - State::State(std::shared_ptr instance_info, const std::vector& atoms, StateIndex index) : m_instance_info(instance_info), m_index(index) { if (!std::all_of(atoms.begin(), atoms.end(), [&](const auto& atom){ return !atom.is_static(); })) { diff --git a/src/novelty/novelty_base.cpp b/src/novelty/novelty_base.cpp index c21d06af..d430d226 100644 --- a/src/novelty/novelty_base.cpp +++ b/src/novelty/novelty_base.cpp @@ -11,7 +11,6 @@ namespace dlplan::novelty { -NoveltyBase::NoveltyBase() : m_factors(std::vector()), m_num_atoms(0), m_arity(0) { } NoveltyBase::NoveltyBase(int num_atoms, int arity) : m_num_atoms(num_atoms), m_arity(arity) { diff --git a/src/novelty/tuple_graph.cpp b/src/novelty/tuple_graph.cpp index abcb5bad..11e8e4e0 100644 --- a/src/novelty/tuple_graph.cpp +++ b/src/novelty/tuple_graph.cpp @@ -12,15 +12,6 @@ using namespace dlplan::state_space; namespace dlplan::novelty { -TupleGraph::TupleGraph() - : m_novelty_base(nullptr), - m_state_space(nullptr), - m_root_state_index(-1), - m_nodes(TupleNodes()), - m_node_indices_by_distance(std::vector()), - m_state_indices_by_distance(std::vector()) { -} - TupleGraph::TupleGraph( std::shared_ptr novelty_base, std::shared_ptr state_space, diff --git a/src/novelty/tuple_node.cpp b/src/novelty/tuple_node.cpp index 555cdfae..1968f5c9 100644 --- a/src/novelty/tuple_node.cpp +++ b/src/novelty/tuple_node.cpp @@ -9,14 +9,6 @@ using namespace dlplan::state_space; namespace dlplan::novelty { -TupleNode::TupleNode() - : m_index(-1), - m_tuple_index(-1), - m_state_indices(state_space::StateIndices()), - m_predecessors(TupleNodeIndices()), - m_successors(TupleNodeIndices()) { -} - TupleNode::TupleNode(TupleNodeIndex index, TupleIndex tuple_index, const StateIndices& state_indices) : m_index(index), m_tuple_index(tuple_index), m_state_indices(state_indices) { }