diff --git a/helios/pipeViewer/pipe_view/model/element_value.py b/helios/pipeViewer/pipe_view/model/element_value.py index 7560011cc1..4bf78fef88 100644 --- a/helios/pipeViewer/pipe_view/model/element_value.py +++ b/helios/pipeViewer/pipe_view/model/element_value.py @@ -4,13 +4,11 @@ # [Element, val]. from __future__ import annotations from bisect import bisect, bisect_left -from typing import Any, Dict, List, Optional, Tuple, Union, TYPE_CHECKING +from typing import Any, Dict, List, Optional, Tuple, Union from . import content_options as content from . import highlighting_utils from .element import Element, FakeElement, PropertyValue - -if TYPE_CHECKING: - from .schedule_element import ScheduleLineElement +from .schedule_element import ScheduleLineElement TimedVal = Tuple[Optional[Union[int, str]], Tuple[int, int]] diff --git a/helios/pipeViewer/pipe_view/model/schedule_element.py b/helios/pipeViewer/pipe_view/model/schedule_element.py index f71b218775..469dc870fd 100644 --- a/helios/pipeViewer/pipe_view/model/schedule_element.py +++ b/helios/pipeViewer/pipe_view/model/schedule_element.py @@ -16,7 +16,9 @@ PropertyValue, ValidatedPropertyDict) from . import element_propsvalid as valid -from .element_value import Element_Value, FakeElementValue + +if TYPE_CHECKING: + from .element_value import Element_Value, FakeElementValue if TYPE_CHECKING: from .clock_manager import ClockManager @@ -387,6 +389,8 @@ def GetQueryFrame(self, period: int) -> Tuple[int, int]: def DetectCollision(self, pt: Union[Tuple[int, int], wx.Point], pair: Element_Value) -> FakeElementValue: + from .element_value import FakeElementValue + mx, my = pt period = pair.GetClockPeriod() diff --git a/sparta/sparta/log/MessageSource.hpp b/sparta/sparta/log/MessageSource.hpp index 74d00edb00..136822656e 100644 --- a/sparta/sparta/log/MessageSource.hpp +++ b/sparta/sparta/log/MessageSource.hpp @@ -149,7 +149,7 @@ namespace sparta //! Move constructor LogObject(LogObject&& rhp) : src_(rhp.src_), - s_(std::move(rhp.s_.str())) // May unfortunately involve a copy + s_(rhp.s_.str()) // May unfortunately involve a copy { } //! \brief Not Copy-constructable diff --git a/sparta/sparta/pipeViewer/Outputter.hpp b/sparta/sparta/pipeViewer/Outputter.hpp index 1637fb51a6..6d40210c88 100644 --- a/sparta/sparta/pipeViewer/Outputter.hpp +++ b/sparta/sparta/pipeViewer/Outputter.hpp @@ -187,7 +187,7 @@ namespace sparta::pipeViewer if(!dat.stringVector[i].empty()){ // We check if we have seen this exact pair, field and value before or not. if(const auto& [val, str] = std::tie(dat.valueVector[i].first, dat.stringVector[i]); - stringMap.try_emplace(std::make_tuple(dat.pairId, i, val), str).second) { + stringMap.emplace(std::piecewise_construct, std::forward_as_tuple(dat.pairId, i, val), std::forward_as_tuple(str)).second) { // We add this mapping into out String Map file which we will // use when reading back from the database. string_file_ << dat.pairId @@ -238,7 +238,7 @@ namespace sparta::pipeViewer if(!dat.stringVector[i].empty()){ // We check if we have seen this exact pair, field and value before or not. if(const auto& [val, str] = std::tie(dat.valueVector[i].first, dat.stringVector[i]); - stringMap.try_emplace(std::make_tuple(dat.pairId, i, val), str).second) { + stringMap.emplace(std::piecewise_construct, std::forward_as_tuple(dat.pairId, i, val), std::forward_as_tuple(str)).second) { // We add this mapping into out String Map file which we will // use when reading back from the database. string_file_ << dat.pairId diff --git a/sparta/sparta/report/Report.hpp b/sparta/sparta/report/Report.hpp index 3149a0b106..7e79336738 100644 --- a/sparta/sparta/report/Report.hpp +++ b/sparta/sparta/report/Report.hpp @@ -379,7 +379,7 @@ namespace sparta r_.add(ctr, name); return *this; } - StatAdder& operator()(TreeNode* n, + StatAdder& operator()(const TreeNode* n, const std::string& name="") { r_.add(n, name); return *this; @@ -435,7 +435,7 @@ namespace sparta * \param n The TreeNode to add * \param name The name of the item in the report */ - StatAdder add(TreeNode* n, const std::string& name=""); + StatAdder add(const TreeNode* n, const std::string& name=""); /*! * \brief Add a single Expression parsed at the current context for this diff --git a/sparta/sparta/resources/Buffer.hpp b/sparta/sparta/resources/Buffer.hpp index f036609bff..f174c3d3c6 100644 --- a/sparta/sparta/resources/Buffer.hpp +++ b/sparta/sparta/resources/Buffer.hpp @@ -95,7 +95,7 @@ namespace sparta */ struct DataPointer { private: - typename std::aligned_storage::type object_memory_; + alignas(value_type) std::byte object_memory_[sizeof(value_type)]; public: DataPointer() { } diff --git a/sparta/sparta/statistics/StatisticInstance.hpp b/sparta/sparta/statistics/StatisticInstance.hpp index 8c189c8e27..aa2bd72ac5 100644 --- a/sparta/sparta/statistics/StatisticInstance.hpp +++ b/sparta/sparta/statistics/StatisticInstance.hpp @@ -44,7 +44,7 @@ namespace sparta * \note Stream insertion operator can be used to add more text to the * reason. */ - ReversedStatisticRange(const std::string & reason) : + explicit ReversedStatisticRange(const std::string & reason) : SpartaException(reason) { } @@ -67,7 +67,7 @@ namespace sparta * \note Stream insertion operator can be used to add more text to the * reason. */ - FutureStatisticRange(const std::string & reason) : + explicit FutureStatisticRange(const std::string & reason) : SpartaException(reason) { } @@ -128,7 +128,7 @@ namespace sparta * \note You *must* set the context (setContext) after this * call. The Expression might or might not know the context for the Scheduler */ - StatisticInstance(statistics::expression::Expression&& expr) : + explicit StatisticInstance(statistics::expression::Expression&& expr) : stat_expr_(expr) { } @@ -136,7 +136,7 @@ namespace sparta * \brief Construct with a StatisticDef or Counter as a TreeNode* * \param node Must be an interface to a StatisticDef or a Counter */ - StatisticInstance(const TreeNode* node) : + explicit StatisticInstance(const TreeNode* node) : StatisticInstance(nullptr, nullptr, nullptr, node, nullptr) { } diff --git a/sparta/sparta/statistics/dispatch/archives/ArchiveNode.hpp b/sparta/sparta/statistics/dispatch/archives/ArchiveNode.hpp index 98cab4604d..53bf7181f8 100644 --- a/sparta/sparta/statistics/dispatch/archives/ArchiveNode.hpp +++ b/sparta/sparta/statistics/dispatch/archives/ArchiveNode.hpp @@ -37,9 +37,7 @@ class ArchiveNode ArchiveNode() = default; //! Construct a named node - ArchiveNode(const std::string & name) : - name_(name) - {} + ArchiveNode(const std::string & name); //! Archive trees are built with the help of the //! ReportStatisticsHierTree class. That class is @@ -61,7 +59,7 @@ class ArchiveNode ArchiveNode(name) {} - virtual ~ArchiveNode() {} + virtual ~ArchiveNode(); //! Return the name that this node was originally created with const std::string & getName() const { diff --git a/sparta/sparta/utils/SpartaSharedPointerAllocator.hpp b/sparta/sparta/utils/SpartaSharedPointerAllocator.hpp index 86eb9c8cc6..14b57991fc 100644 --- a/sparta/sparta/utils/SpartaSharedPointerAllocator.hpp +++ b/sparta/sparta/utils/SpartaSharedPointerAllocator.hpp @@ -285,16 +285,20 @@ namespace sparta friend SpartaSharedPointer allocate_sparta_shared_pointer(SpartaSharedPointerAllocator &, Args&&...args); + template + struct AlignedStorage + { + alignas(T) std::byte buf[sizeof(T)]; + }; + // Internal MemoryBlock struct MemBlock : public BaseAllocator::MemBlockBase { using RefCountType = typename SpartaSharedPointer::RefCount; - using RefCountAlignedStorage = - typename std::aligned_storage::type; + using RefCountAlignedStorage = AlignedStorage; - using PointerTAlignedStorage = - typename std::aligned_storage::type; + using PointerTAlignedStorage = AlignedStorage; template MemBlock(SpartaSharedPointerAllocator * alloc_in, ObjArgs&&...obj_args) : @@ -323,8 +327,7 @@ namespace sparta class MemBlockVector { // Align the storage for the MemBlock - using MemBlockAlignedStorage = - typename std::aligned_storage::type; + using MemBlockAlignedStorage = AlignedStorage; std::vector data_; std::size_t size_ = 0; diff --git a/sparta/sparta/utils/Utils.hpp b/sparta/sparta/utils/Utils.hpp index 1b485fcdb4..a128dccbb7 100644 --- a/sparta/sparta/utils/Utils.hpp +++ b/sparta/sparta/utils/Utils.hpp @@ -27,56 +27,56 @@ /*! * \brief Custom literal for uint64 */ -constexpr inline uint64_t operator "" _u64(unsigned long long i) { +constexpr inline uint64_t operator ""_u64(unsigned long long i) { return i; } /*! * \brief Custom literal for uint32 */ -constexpr inline uint32_t operator "" _u32(unsigned long long i) { +constexpr inline uint32_t operator ""_u32(unsigned long long i) { return i; } /*! * \brief Custom literal for uint16 */ -constexpr inline uint16_t operator "" _u16(unsigned long long i) { +constexpr inline uint16_t operator ""_u16(unsigned long long i) { return i; } /*! * \brief Custom literal for uint8 */ -constexpr inline uint8_t operator "" _u8(unsigned long long i) { +constexpr inline uint8_t operator ""_u8(unsigned long long i) { return i; } /*! * \brief Custom literal for int64 */ -constexpr inline int64_t operator "" _64(unsigned long long i) { +constexpr inline int64_t operator ""_64(unsigned long long i) { return i; } /*! * \brief Custom literal for int32 */ -constexpr inline int32_t operator "" _32(unsigned long long i) { +constexpr inline int32_t operator ""_32(unsigned long long i) { return i; } /*! * \brief Custom literal for int16 */ -constexpr inline int16_t operator "" _16(unsigned long long i) { +constexpr inline int16_t operator ""_16(unsigned long long i) { return i; } /*! * \brief Custom literal for int8 */ -constexpr inline int8_t operator "" _8(unsigned long long i) { +constexpr inline int8_t operator ""_8(unsigned long long i) { return i; } diff --git a/sparta/src/Report.cpp b/sparta/src/Report.cpp index fd7571e758..be2e7eebeb 100644 --- a/sparta/src/Report.cpp +++ b/sparta/src/Report.cpp @@ -1225,7 +1225,7 @@ Report::StatAdder Report::add(CounterBase* ctr, const std::string& name) { return Report::StatAdder(*this); } -Report::StatAdder Report::add(TreeNode* n, const std::string& name) { +Report::StatAdder Report::add(const TreeNode* n, const std::string& name) { sparta_assert(n); if(name != "" && stat_names_.find(name) != stat_names_.end()){ throw SpartaException("There is already a statistic instance in this Report (") diff --git a/sparta/src/StatisticsArchives.cpp b/sparta/src/StatisticsArchives.cpp index 4dc92d4226..9a576aefba 100644 --- a/sparta/src/StatisticsArchives.cpp +++ b/sparta/src/StatisticsArchives.cpp @@ -196,6 +196,15 @@ void RootArchiveNode::saveTo(const std::string & dir) archive_controller_->saveTo(dir); } +ArchiveNode::ArchiveNode(const std::string & name) : + name_(name) +{ +} + +ArchiveNode::~ArchiveNode() +{ +} + //Lazily walk up to the top of the tree to get the root node RootArchiveNode * ArchiveNode::getRoot() {