diff --git a/src/pvxs/client.h b/src/pvxs/client.h index 803d0b7..846bf28 100644 --- a/src/pvxs/client.h +++ b/src/pvxs/client.h @@ -184,6 +184,7 @@ class GetBuilder; class PutBuilder; class RPCBuilder; class MonitorBuilder; +class RequestBuilder; /** An independent PVA protocol client instance * @@ -352,6 +353,23 @@ public: inline MonitorBuilder monitor(const std::string& pvname); + /** Compose a pvRequest independently of a network operation. + * + * This is not a network operation. + * + * Use of request() is optional. pvRequests can be composed + * with individual network operation Builders. + * + * @code + * Value pvReq = Context::request() + * .pvRequest("field(value)field(blah)") + * .record("pipeline", true) + * .build(); + * @endcode + */ + static inline + RequestBuilder request(); + /** Request prompt search of any disconnected channels. * * Optional. Equivalent to detection of a new server. @@ -612,6 +630,17 @@ public: }; MonitorBuilder Context::monitor(const std::string& name) { return MonitorBuilder{pvt, name}; } +class RequestBuilder : public detail::CommonBuilder +{ +public: + RequestBuilder() :CommonBuilder{nullptr,std::string()} {} + //! Return composed pvRequest + Value build() const { + return _buildReq(); + } +}; +RequestBuilder Context::request() { return RequestBuilder{}; } + struct PVXS_API Config { //! List of unicast and broadcast addresses std::vector addressList; diff --git a/test/testpvreq.cpp b/test/testpvreq.cpp index 9d663da..94e3081 100644 --- a/test/testpvreq.cpp +++ b/test/testpvreq.cpp @@ -28,10 +28,6 @@ struct TestBuilder : client::detail::CommonBuilder(nullptr, "") {} - Value makeReq() const { - return _buildReq(); - } - template TestBuilder& set(const std::string& name, const T& val, bool required=true) { const typename impl::StoreAs::store_t& norm(impl::StoreTransform::in(val)); @@ -52,7 +48,7 @@ void testEmpty() { testShow()<<__func__; - auto req = TestBuilder().makeReq(); + auto req = client::Context::request().build(); testShow()<([&pvr](){ - auto req = TestBuilder() + auto req = client::Context::request() .pvRequest(pvr) - .makeReq(); + .build(); testShow()<