Skip to content

Commit

Permalink
Minor changes to get the examples repo working
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hollman committed Apr 3, 2018
1 parent 80b4acb commit ce14764
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/include/darma/serialization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ set(DARMA_SERIALIZATION_HEADERS
install (FILES ${DARMA_SERIALIZATION_HEADERS} DESTINATION include/darma/serialization)

add_subdirectory(serializers)
add_subdirectory(polymorphic)

5 changes: 3 additions & 2 deletions src/include/darma/serialization/polymorphic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)

Original file line number Diff line number Diff line change
@@ -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
)

1 change: 1 addition & 0 deletions src/include/darma/serialization/serializers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(DARMA_SERIALIZATION_SERIALIZERS_HEADERS
all.h
arithmetic_types.h
array.h
c_string.h
const.h
enum.h
)
Expand Down
1 change: 1 addition & 0 deletions src/include/darma/serialization/serializers/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
#include <darma/serialization/serializers/standard_library/vector.h>
#include <darma/serialization/serializers/standard_library/pair.h>
#include <darma/serialization/serializers/standard_library/tuple.h>
#include <darma/serialization/serializers/standard_library/list.h>

#endif //DARMAFRONTEND_SERIALIZATION_SERIALIZERS_ALL_H
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

set(DARMA_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_HEADERS
list.h
map.h
pair.h
set.h
Expand Down
109 changes: 109 additions & 0 deletions src/include/darma/serialization/serializers/standard_library/list.h
Original file line number Diff line number Diff line change
@@ -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 <darma/serialization/nonintrusive.h>
#include <darma/serialization/serialization_traits.h>

#include <list>

// TODO serialization of non-standard allocators

namespace darma_runtime {
namespace serialization {

template <typename T, typename Archive>
struct is_sizable_with_archive<std::list<T>, Archive>
: is_sizable_with_archive<T, Archive>
{ };

template <typename T, typename Archive>
struct is_packable_with_archive<std::list<T>, Archive>
: is_packable_with_archive<T, Archive>
{ };

template <typename T, typename Archive>
struct is_unpackable_with_archive<std::list<T>, Archive>
: is_unpackable_with_archive<T, Archive>
{ };

template <typename T>
struct Serializer<std::list<T>> {

using list_t = std::list<T>;

template <typename SizingArchive>
static void compute_size(list_t const& obj, SizingArchive& ar) {
ar | obj.size();
for(auto&& val : obj) {
ar | val;
}
}

template <typename Archive>
static void pack(list_t const& obj, Archive& ar) {
ar | obj.size();
for(auto&& val : obj) {
ar | val;
}
}

template <typename Archive>
static void unpack(void* allocated, Archive& ar) {
auto size = ar.template unpack_next_item_as<typename list_t::size_type>();
auto& obj = *(new (allocated) list_t(
ar.template get_allocator_as<typename list_t::allocator_type>())
);
for(int64_t i = 0; i < size; ++i) {
obj.emplace_back(ar.template unpack_next_item_as<T>());
}
}
};

} // end namespace serialization
} // end namespace darma_runtime

#endif //DARMAFRONTEND_SERIALIZATION_SERIALIZERS_STANDARD_LIBRARY_LIST_H
2 changes: 1 addition & 1 deletion src/include/darma/utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ configure_file(
)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/config-generated.h
DESTINATION include/darma/impl
DESTINATION include/darma/utility
)

################################################################################
Expand Down

0 comments on commit ce14764

Please sign in to comment.