5#ifndef PV_SHAREDSTATE_H
6#define PV_SHAREDSTATE_H
12#include <pv/sharedPtr.h>
13#include <pv/noDefaultMethods.h>
15#include <pv/createRequest.h>
17#include <pva/server.h>
19namespace epics{
namespace pvData{
25namespace epics{
namespace pvAccess{
28class ChannelRequester;
29struct ChannelBaseRequester;
30class GetFieldRequester;
31void providerRegInit(
void*);
38struct SharedMonitorFIFO;
79 friend struct detail::SharedChannel;
80 friend struct detail::SharedMonitorFIFO;
81 friend struct detail::SharedPut;
82 friend struct detail::SharedRPC;
85 struct epicsShareClass Config {
98 virtual void onFirstConnect(
const SharedPV::shared_pointer& pv) {}
112 static shared_pointer
build(
const std::tr1::shared_ptr<Handler>& handler, Config* conf=0);
118 explicit SharedPV(
const std::tr1::shared_ptr<Handler>& handler, Config* conf);
123 void setHandler(
const std::tr1::shared_ptr<Handler>& handler);
124 Handler::shared_pointer getHandler()
const;
153 inline void close(
bool destroy=
false) { realClose(destroy,
true, 0); }
157 std::tr1::shared_ptr<epics::pvData::PVStructure>
build();
173 virtual std::tr1::shared_ptr<epics::pvAccess::Channel>
connect(
174 const std::tr1::shared_ptr<epics::pvAccess::ChannelProvider>& provider,
175 const std::string& channelName,
176 const std::tr1::shared_ptr<epics::pvAccess::ChannelRequester>& requester) OVERRIDE FINAL;
180 void setDebug(
int lvl);
186 friend void epics::pvAccess::providerRegInit(
void*);
187 static size_t num_instances;
189 weak_pointer internal_self;
193 mutable epicsMutex mutex;
195 std::tr1::shared_ptr<SharedPV::Handler> handler;
203 std::tr1::shared_ptr<const epics::pvData::Structure> type;
211 std::tr1::shared_ptr<epics::pvData::PVStructure> current;
233 std::tr1::shared_ptr<Impl> impl;
235 friend struct detail::SharedPut;
236 friend struct detail::SharedRPC;
237 explicit Operation(
const std::tr1::shared_ptr<Impl> impl);
268 std::tr1::shared_ptr<epics::pvAccess::Channel> getChannel();
270 std::tr1::shared_ptr<epics::pvAccess::ChannelBaseRequester> getRequester();
274#if __cplusplus>=201103L
275 explicit operator bool()
const {
return valid(); }
278 typedef bool (
Operation::*bool_type)()
const;
280 operator bool_type()
const {
return valid() ? &Operation::valid : 0; }
An instance of a Client or Server.
A Shared State Process Variable (PV)
void warn(const std::string &)
Send warning message to client. Does not complete().
void close(bool destroy=false)
Force any clients to disconnect, and prevent re-connection.
static shared_pointer buildMailbox(Config *conf=0)
A SharedPV which accepts all Put operations, and fails all RPC operations. In closed state.
void open(const epics::pvData::PVStructure &value, const epics::pvData::BitSet &valid)
Begin allowing clients to connect.
void setHandler(const std::tr1::shared_ptr< Handler > &handler)
Replace Handler given with ctor.
void fetch(epics::pvData::PVStructure &value, epics::pvData::BitSet &valid)
Update arguments with current value, which is the initial value from open() with accumulated post() c...
bool isOpen() const
test open-ness. cf. open() and close()
virtual void disconnect(bool destroy, const epics::pvAccess::ChannelProvider *provider)
Disconnect all Channels created through the given ChannelProvider.
std::tr1::shared_ptr< epics::pvData::PVStructure > build()
Create a new container which may be used to prepare to call post().
void post(const epics::pvData::PVStructure &value, const epics::pvData::BitSet &changed)
Update the cached PVStructure in this SharedPV.
void info(const std::string &)
Send info message to client. Does not complete().
bool dropEmptyUpdates
default true. Drop updates which don't include an field values.
const epics::pvData::PVStructure & pvRequest() const
pvRequest blob, may be used to modify handling.
static shared_pointer build(const std::tr1::shared_ptr< Handler > &handler, Config *conf=0)
Allocate a new PV in the closed state.
virtual void onRPC(const SharedPV::shared_pointer &pv, Operation &op)
Client requests RPC.
void complete(const epics::pvData::Status &sts)
Complete with success or error w/o data.
void open(const epics::pvData::PVStructure &value)
Shorthand for.
const epics::pvData::BitSet & changed() const
Applies to value(). Which fields of input data are actual valid. Others should not be used.
void complete(const epics::pvData::PVStructure &value, const epics::pvData::BitSet &changed)
Sucessful completion with data (RPC only)
std::string channelName() const
The name of the channel through which this request was made (eg. for logging purposes).
Operation()
create empty op for later assignment
void open(const epics::pvData::StructureConstPtr &type)
Shorthand for.
virtual std::tr1::shared_ptr< epics::pvAccess::Channel > connect(const std::tr1::shared_ptr< epics::pvAccess::ChannelProvider > &provider, const std::string &channelName, const std::tr1::shared_ptr< epics::pvAccess::ChannelRequester > &requester)
may call Handler::onFirstConnect()
virtual void onPut(const SharedPV::shared_pointer &pv, Operation &op)
Client requests Put.
epics::pvData::PVRequestMapper::mode_t mapperMode
default Mask.
const epics::pvData::PVStructure & value() const
Input data.
void complete()
shorthand for successful completion w/o data (Put or RPC with void return)
const epics::pvAccess::PeerInfo * peer() const
Information about peer transport and authentication.
static shared_pointer buildReadOnly(Config *conf=0)
A SharedPV which fails all Put and RPC operations. In closed state.
virtual void onLastDisconnect(const SharedPV::shared_pointer &pv)
Called when the last client disconnects. May close()
std::tr1::shared_ptr< const Structure > StructureConstPtr
Copyright - See the COPYRIGHT that is included with this distribution.
Information provded by a client to a server-type ChannelProvider.
An in-progress network operation (Put or RPC).
Callbacks associated with a SharedPV.
Interface for something which can provide Channels. aka A "PV". Typically a SharedPV.