From 80ee77c2eafcab44beb7291591504a8f530f7c98 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 23 Jul 2020 11:51:02 -0700 Subject: [PATCH] Add StaticSource::list() --- src/pvxs/sharedpv.h | 4 ++++ src/sharedpv.cpp | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pvxs/sharedpv.h b/src/pvxs/sharedpv.h index a953e4f..f3b8152 100644 --- a/src/pvxs/sharedpv.h +++ b/src/pvxs/sharedpv.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "srvcommon.h" @@ -103,6 +104,9 @@ struct PVXS_API StaticSource //! Remove a single name StaticSource& remove(const std::string& name); + typedef std::map list_t; + list_t list() const; + struct Impl; private: std::shared_ptr impl; diff --git a/src/sharedpv.cpp b/src/sharedpv.cpp index 69b1e90..b46c1c0 100644 --- a/src/sharedpv.cpp +++ b/src/sharedpv.cpp @@ -439,7 +439,7 @@ struct StaticSource::Impl : public Source { RWLock lock; - std::map pvs; + list_t pvs; decltype (List::names) list; virtual void onSearch(Search &op) override @@ -540,5 +540,19 @@ StaticSource& StaticSource::remove(const std::string& name) return *this; } +StaticSource::list_t StaticSource::list() const +{ + list_t ret; + + if(!impl) + throw std::logic_error("Empty StaticSource"); + + { + auto G(impl->lock.lockReader()); + + return impl->pvs; // copies map + } +} + } // namespace server } // namespace pvxs