From 582b1b9a79c2f51f4d6c2bde6b263e072df4120b Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 10 Dec 2019 18:38:22 -0800 Subject: [PATCH] add skeleton for server Get/Put/RPC --- src/pvxs/server.h | 72 +++++++++++++++++++++++++++++++++++++++++++++-- src/server.cpp | 22 +++++++++++++-- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/src/pvxs/server.h b/src/pvxs/server.h index 5a51b7d..0f733ae 100644 --- a/src/pvxs/server.h +++ b/src/pvxs/server.h @@ -17,9 +17,9 @@ #include #include +#include namespace pvxs { -class Value; namespace impl { struct ServerConn; } @@ -180,6 +180,7 @@ struct OpBase { const std::string& name); virtual ~OpBase() =0; }; + /** Manipulate an active Channel, and any in-progress Operations through it. * */ @@ -258,10 +259,10 @@ struct PVXS_API Source { //! Token for an in-progress request for Channel data type information. struct PVXS_API Introspect : public OpBase { + //! Positive reply. Only the type of the provided Value is used. Any field values are ignored. virtual void reply(const Value& prototype) =0; //! Negative reply w/ error message virtual void error(const std::string& msg) =0; - // void success(Data); Introspect(const std::string& peerName, const std::string& iface, @@ -271,6 +272,69 @@ struct PVXS_API Introspect : public OpBase virtual ~Introspect() =0; }; +struct PVXS_API Get : public OpBase +{ + const Value request; + + //! Positive reply w/ data + virtual void reply(const Value& prototype) =0; + //! Negative reply w/ error message + virtual void error(const std::string& msg) =0; + + Get(const std::string& peerName, + const std::string& iface, + const std::string& name, + const Value& request) + :OpBase (peerName, iface, name) + ,request(request) + {} + virtual ~Get() =0; +}; + +struct PVXS_API Put : public OpBase +{ + const Value request; + const Value value; + + //! Positive reply + virtual void complete() =0; + //! Negative reply w/ error message + virtual void error(const std::string& msg) =0; + + Put(const std::string& peerName, + const std::string& iface, + const std::string& name, + const Value& request, + const Value& value) + :OpBase (peerName, iface, name) + ,request(request) + ,value(value) + {} + virtual ~Put() =0; +}; + +struct PVXS_API RPC : public OpBase +{ + const Value request; + const Value value; + + //! Positive reply w/ data + virtual void reply(const Value& prototype) =0; + //! Negative reply w/ error message + virtual void error(const std::string& msg) =0; + + RPC(const std::string& peerName, + const std::string& iface, + const std::string& name, + const Value& request, + const Value& value) + :OpBase (peerName, iface, name) + ,request(request) + ,value(value) + {} + virtual ~RPC() =0; +}; + /** Requests for a particular Channel are dispatched through me. * * User code will sub-class. @@ -285,6 +349,10 @@ struct PVXS_API Handler { * the Introspect to be deleted prior to replying. */ virtual void onIntrospect(std::unique_ptr&& op); + + virtual void onGet(std::unique_ptr&& op); + virtual void onPut(std::unique_ptr&& op); + virtual void onRPC(std::unique_ptr&& op); }; }} // namespace pvxs::server diff --git a/src/server.cpp b/src/server.cpp index b153860..b2f981b 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -610,10 +610,28 @@ OpBase::~OpBase() {} ChannelControl::~ChannelControl() {} Introspect::~Introspect() {} +Get::~Get() {} +Put::~Put() {} +RPC::~RPC() {} Handler::~Handler() {} void Handler::onIntrospect(std::unique_ptr&& op) -{} +{ + op->error("Not Implemented"); +} +void Handler::onGet(std::unique_ptr&& op) +{ + op->error("Not Implemented"); +} +void Handler::onPut(std::unique_ptr&& op) +{ + op->error("Not Implemented"); +} +void Handler::onRPC(std::unique_ptr &&op) +{ + op->error("Not Implemented");} -}} // namespace pvxs::server +} + +} // namespace pvxs::server