diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dcac7c..2b92abf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.8.0) project( Faodel LANGUAGES CXX C - VERSION 1.1906.1 + VERSION 1.1906.2 ) diff --git a/src/kelpie/CMakeLists.txt b/src/kelpie/CMakeLists.txt index 74aefa7..ffc1a8e 100644 --- a/src/kelpie/CMakeLists.txt +++ b/src/kelpie/CMakeLists.txt @@ -8,6 +8,7 @@ set( HEADERS_PUBLIC Kelpie.hh Key.hh common/KelpieInternal.hh + common/ObjectCapacities.hh common/Types.hh ioms/IomBase.hh ioms/IomRegistry.hh @@ -42,6 +43,7 @@ set( SOURCES Kelpie.cpp Key.cpp common/KelpieInternal.cpp + common/ObjectCapacities.cpp common/OpArgsObjectAvailable.cpp common/Types.cpp core/KelpieCoreBase.cpp @@ -126,7 +128,7 @@ install(TARGETS kelpie install( FILES Kelpie.hh Key.hh DESTINATION ${INCLUDE_INSTALL_DIR}/faodel/kelpie ) -install( FILES common/Types.hh common/KelpieInternal.hh +install( FILES common/Types.hh common/KelpieInternal.hh common/ObjectCapacities.hh DESTINATION ${INCLUDE_INSTALL_DIR}/faodel/kelpie/common ) install( FILES ioms/IomBase.hh ioms/IomRegistry.hh DESTINATION ${INCLUDE_INSTALL_DIR}/faodel/kelpie/ioms ) diff --git a/src/kelpie/common/ObjectCapacities.cpp b/src/kelpie/common/ObjectCapacities.cpp new file mode 100644 index 0000000..46b7ca1 --- /dev/null +++ b/src/kelpie/common/ObjectCapacities.cpp @@ -0,0 +1,57 @@ +// Copyright 2021 National Technology & Engineering Solutions of Sandia, +// LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. + +#include "kelpie/common/Types.hh" + +using namespace std; + +namespace kelpie { + +/// Append a key/capacity to this ObjectCapacities. Does NOT dedupe +void ObjectCapacities::Append(const kelpie::Key &key, size_t capacity) { + keys.emplace_back(key); + capacities.emplace_back(capacity); +} + +/// Append one ObjectCapacities to another. Does NOT dedupe +void ObjectCapacities::Append(const ObjectCapacities &other) { + keys.insert(keys.end(), other.keys.begin(), other.keys.end()); + capacities.insert(capacities.end(), other.capacities.begin(), other.capacities.end()); +} + +/// Merge two ObjectCapacities. If key exists, do not append from other +void ObjectCapacities::Merge(const ObjectCapacities &other) { + for(int i = 0; i=0) { + for(int i=0; i + +#include "faodel-common/InfoInterface.hh" + +namespace kelpie { + +class Key; //Forward reference + +class ObjectCapacities : + public faodel::InfoInterface { +public: + + //Note: These data structures are plain vectors because some callers need to update capacities first, then set the keys + std::vector keys; + std::vector capacities; + + /// Append a ket/capacity to this ObjectCapacities. Does NOT dedupe + void Append(const kelpie::Key &key, size_t capacity); + void Append(const ObjectCapacities &other); + + void Merge(const ObjectCapacities &other); + + int FindIndex(const kelpie::Key &key); + void Wipe(); + + /// How many entries are here + size_t Size() { return keys.size(); } + + //Serialization hook + template + void serialize(Archive &ar, const unsigned int version) { + ar & keys; + ar & capacities; + } + + //InfoInterface function + void sstr(std::stringstream &ss, int depth, int indent) const override; +}; + +} // namespace kelpie + +#endif //FAODEL_OBJECTCAPACITIES_HH diff --git a/src/kelpie/common/Types.hh b/src/kelpie/common/Types.hh index a5aa3ea..c8d977a 100644 --- a/src/kelpie/common/Types.hh +++ b/src/kelpie/common/Types.hh @@ -1,4 +1,4 @@ -// Copyright 2018 National Technology & Engineering Solutions of Sandia, +// Copyright 2021 National Technology & Engineering Solutions of Sandia, // LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. @@ -14,6 +14,7 @@ #include "lunasa/DataObject.hh" #include "kelpie/Key.hh" +#include "kelpie/common/ObjectCapacities.hh" #include //For packing ObjectCapacities @@ -138,22 +139,6 @@ struct PoolBehavior { }; -class ObjectCapacities { -public: - std::vector keys; - std::vector capacities; - - void Append(const ObjectCapacities &other) { - keys.insert(keys.end(), other.keys.begin(), other.keys.end()); - capacities.insert(capacities.end(), other.capacities.begin(), other.capacities.end()); - } - //Serialization hook - template - void serialize(Archive &ar, const unsigned int version){ - ar & keys; - ar & capacities; - } -};