5 #ifndef PV_SHAREDSTATE_H 6 #define PV_SHAREDSTATE_H 12 #include <pv/sharedPtr.h> 13 #include <pv/noDefaultMethods.h> 14 #include <pv/bitSet.h> 15 #include <pv/createRequest.h> 17 #include <pva/server.h> 25 namespace epics{
namespace pvAccess{
26 class ChannelProvider;
28 class ChannelRequester;
29 struct ChannelBaseRequester;
30 class GetFieldRequester;
31 void providerRegInit(
void*);
38 struct SharedMonitorFIFO;
77 :
public pvas::StaticProvider::ChannelBuilder
79 friend struct detail::SharedChannel;
80 friend struct detail::SharedMonitorFIFO;
81 friend struct detail::SharedPut;
82 friend struct detail::SharedRPC;
84 POINTER_DEFINITIONS(SharedPV);
85 struct epicsShareClass Config {
86 bool dropEmptyUpdates;
87 epics::pvData::PVRequestMapper::mode_t mapperMode;
95 struct epicsShareClass Handler {
96 POINTER_DEFINITIONS(Handler);
98 virtual void onFirstConnect(
const SharedPV::shared_pointer& pv) {}
100 virtual void onLastDisconnect(
const SharedPV::shared_pointer& pv) {}
102 virtual void onPut(
const SharedPV::shared_pointer& pv, Operation& op);
104 virtual void onRPC(
const SharedPV::shared_pointer& pv, Operation& op);
112 static shared_pointer build(
const std::tr1::shared_ptr<Handler>& handler, Config* conf=0);
114 static shared_pointer buildReadOnly(Config* conf=0);
116 static shared_pointer buildMailbox(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;
130 void open(
const epics::pvData::PVStructure& value);
138 void open(
const epics::pvData::PVStructure& value,
const epics::pvData::BitSet& valid);
141 void open(
const epics::pvData::StructureConstPtr& type);
153 inline void close(
bool destroy=
false) { realClose(destroy,
true, 0); }
157 std::tr1::shared_ptr<epics::pvData::PVStructure> build();
165 void post(
const epics::pvData::PVStructure& value,
166 const epics::pvData::BitSet& changed);
169 void fetch(epics::pvData::PVStructure& value, epics::pvData::BitSet& valid);
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;
178 virtual void disconnect(
bool destroy,
const epics::pvAccess::ChannelProvider* provider) OVERRIDE FINAL;
180 void setDebug(
int lvl);
184 void realClose(
bool destroy,
bool close,
const epics::pvAccess::ChannelProvider* provider);
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;
197 typedef std::list<detail::SharedPut*> puts_t;
198 typedef std::list<detail::SharedRPC*> rpcs_t;
199 typedef std::list<detail::SharedMonitorFIFO*> monitors_t;
200 typedef std::list<std::tr1::weak_ptr<epics::pvAccess::GetFieldRequester> > getfields_t;
201 typedef std::list<detail::SharedChannel*> channels_t;
203 std::tr1::shared_ptr<
const epics::pvData::Structure> type;
208 getfields_t getfields;
211 std::tr1::shared_ptr<epics::pvData::PVStructure> current;
214 epics::pvData::BitSet valid;
223 EPICS_NOT_COPYABLE(SharedPV)
230 POINTER_DEFINITIONS(Operation);
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);
242 const epics::pvData::PVStructure& pvRequest()
const;
243 const epics::pvData::PVStructure& value()
const;
245 const epics::pvData::BitSet& changed()
const;
247 std::string channelName()
const;
251 const epics::pvAccess::PeerInfo* peer()
const;
255 void complete(
const epics::pvData::Status& sts);
257 void complete(
const epics::pvData::PVStructure& value,
258 const epics::pvData::BitSet& changed);
261 void info(
const std::string&);
263 void warn(
const std::string&);
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; }
Copyright - See the COPYRIGHT that is included with this distribution.
void epicsShareFunc deserializeFromBuffer(Serializable *S, ByteBuffer &in)
A Shared State Process Variable (PV)
An in-progress network operation (Put or RPC).