diff --git a/src/include/darma/serialization/CMakeLists.txt b/src/include/darma/serialization/CMakeLists.txt index 99fc070c..625a175c 100644 --- a/src/include/darma/serialization/CMakeLists.txt +++ b/src/include/darma/serialization/CMakeLists.txt @@ -18,4 +18,5 @@ set(DARMA_SERIALIZATION_HEADERS install (FILES ${DARMA_SERIALIZATION_HEADERS} DESTINATION include/darma/serialization) add_subdirectory(serializers) +add_subdirectory(polymorphic) diff --git a/src/include/darma/serialization/polymorphic/CMakeLists.txt b/src/include/darma/serialization/polymorphic/CMakeLists.txt index cf2d0f59..e7ae58ab 100644 --- a/src/include/darma/serialization/polymorphic/CMakeLists.txt +++ b/src/include/darma/serialization/polymorphic/CMakeLists.txt @@ -1,12 +1,13 @@ set(DARMA_SERIALIZATION_POLYMORPHIC_HEADERS - impl/polymorphic_serializable_object.impl.h polymorphic_serializable_object.h polymorphic_serialization_adapter.h registry.h ) +add_subdirectory(impl) + install (FILES ${DARMA_SERIALIZATION_POLYMORPHIC_HEADERS} - DESTINATION include/darma/serialization/serializers + DESTINATION include/darma/serialization/polymorphic ) diff --git a/src/include/darma/serialization/polymorphic/impl/CMakeLists.txt b/src/include/darma/serialization/polymorphic/impl/CMakeLists.txt new file mode 100644 index 00000000..46c94425 --- /dev/null +++ b/src/include/darma/serialization/polymorphic/impl/CMakeLists.txt @@ -0,0 +1,9 @@ + +set(DARMA_SERIALIZATION_POLYMORPHIC_IMPL_HEADERS + polymorphic_serializable_object.impl.h +) + +install (FILES ${DARMA_SERIALIZATION_POLYMORPHIC_IMPL_HEADERS} + DESTINATION include/darma/serialization/polymorphic/impl +) + diff --git a/src/include/darma/serialization/serializers/CMakeLists.txt b/src/include/darma/serialization/serializers/CMakeLists.txt index 21bdeb33..69ec51a0 100644 --- a/src/include/darma/serialization/serializers/CMakeLists.txt +++ b/src/include/darma/serialization/serializers/CMakeLists.txt @@ -3,6 +3,7 @@ set(DARMA_SERIALIZATION_SERIALIZERS_HEADERS all.h arithmetic_types.h array.h + c_string.h const.h enum.h ) diff --git a/src/include/darma/serialization/serializers/all.h b/src/include/darma/serialization/serializers/all.h index 7989e6df..7e760433 100644 --- a/src/include/darma/serialization/serializers/all.h +++ b/src/include/darma/serialization/serializers/all.h @@ -56,5 +56,6 @@ #include #include #include +#include #endif //DARMAFRONTEND_SERIALIZATION_SERIALIZERS_ALL_H diff --git a/src/include/darma/serialization/serializers/standard_library/CMakeLists.txt b/src/include/darma/serialization/serializers/standard_library/CMakeLists.txt index 3570f62c..f77a6af6 100644 --- a/src/include/darma/serialization/serializers/standard_library/CMakeLists.txt +++ b/src/include/darma/serialization/serializers/standard_library/CMakeLists.txt @@ -1,5 +1,6 @@ set(DARMA_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_HEADERS + list.h map.h pair.h set.h diff --git a/src/include/darma/serialization/serializers/standard_library/list.h b/src/include/darma/serialization/serializers/standard_library/list.h new file mode 100644 index 00000000..edb24aba --- /dev/null +++ b/src/include/darma/serialization/serializers/standard_library/list.h @@ -0,0 +1,109 @@ +/* +//@HEADER +// ************************************************************************ +// +// list.h +// DARMA +// Copyright (C) 2018 Sandia Corporation +// +// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +// the U.S. Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the Corporation nor the names of the +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact David S. Hollman (dshollm@sandia.gov) +// +// ************************************************************************ +//@HEADER +*/ + +#ifndef DARMAFRONTEND_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_LIST_H +#define DARMAFRONTEND_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_LIST_H + +#include +#include + +#include + +// TODO serialization of non-standard allocators + +namespace darma_runtime { +namespace serialization { + +template +struct is_sizable_with_archive, Archive> + : is_sizable_with_archive +{ }; + +template +struct is_packable_with_archive, Archive> + : is_packable_with_archive +{ }; + +template +struct is_unpackable_with_archive, Archive> + : is_unpackable_with_archive +{ }; + +template +struct Serializer> { + + using list_t = std::list; + + template + static void compute_size(list_t const& obj, SizingArchive& ar) { + ar | obj.size(); + for(auto&& val : obj) { + ar | val; + } + } + + template + static void pack(list_t const& obj, Archive& ar) { + ar | obj.size(); + for(auto&& val : obj) { + ar | val; + } + } + + template + static void unpack(void* allocated, Archive& ar) { + auto size = ar.template unpack_next_item_as(); + auto& obj = *(new (allocated) list_t( + ar.template get_allocator_as()) + ); + for(int64_t i = 0; i < size; ++i) { + obj.emplace_back(ar.template unpack_next_item_as()); + } + } +}; + +} // end namespace serialization +} // end namespace darma_runtime + +#endif //DARMAFRONTEND_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_LIST_H diff --git a/src/include/darma/utility/CMakeLists.txt b/src/include/darma/utility/CMakeLists.txt index 43669299..be977534 100644 --- a/src/include/darma/utility/CMakeLists.txt +++ b/src/include/darma/utility/CMakeLists.txt @@ -89,7 +89,7 @@ configure_file( ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/config-generated.h - DESTINATION include/darma/impl + DESTINATION include/darma/utility ) ################################################################################