15 #ifdef epicsExportSharedSymbols
16 # define monitorEpicsExportSharedSymbols
17 # undef epicsExportSharedSymbols
20 #include <epicsMutex.h>
21 #include <pv/status.h>
22 #include <pv/pvData.h>
23 #include <pv/sharedPtr.h>
24 #include <pv/bitSet.h>
25 #include <pv/createRequest.h>
27 #ifdef monitorEpicsExportSharedSymbols
28 # define epicsExportSharedSymbols
29 # undef monitorEpicsExportSharedSymbols
32 #include <pv/requester.h>
33 #include <pv/destroyable.h>
37 namespace epics {
namespace pvAccess {
41 typedef std::tr1::shared_ptr<MonitorElement> MonitorElementPtr;
45 typedef std::tr1::shared_ptr<Monitor> MonitorPtr;
57 MonitorElement(epics::pvData::PVStructurePtr
const & pvStructurePtr);
58 const epics::pvData::PVStructurePtr pvStructurePtr;
59 const epics::pvData::BitSet::shared_pointer changedBitSet;
60 const epics::pvData::BitSet::shared_pointer overrunBitSet;
79 virtual epics::pvData::Status
start() = 0;
84 virtual epics::pvData::Status stop() = 0;
92 virtual MonitorElementPtr poll() = 0;
98 virtual void release(MonitorElementPtr
const & monitorElement) = 0;
106 virtual void getStats(Stats& s)
const {
107 s.nfilled = s.noutstanding = s.nempty = 0;
149 MonitorElementPtr elem;
151 Ref() :mon(0), elem() {}
152 Ref(
Monitor& M) :mon(&M), elem(mon->poll()) {}
153 Ref(
const Monitor::shared_pointer& M) :mon(M.get()), elem(mon->poll()) {}
155 #if __cplusplus>=201103L
156 Ref(
Ref&& o) :mon(o.mon), elem(o.elem) {
168 MonitorElementPtr ret;
176 void attach(
const Monitor::shared_pointer& M) {
186 if(elem && mon) mon->
release(elem);
193 #if __cplusplus>=201103L
194 inline explicit operator bool()
const {
return elem.get(); }
197 typedef const Monitor*
const * hidden_bool_type;
199 operator hidden_bool_type()
const {
return elem.get() ? &mon : 0; }
201 inline MonitorElement* operator->() {
return elem.get(); }
202 inline MonitorElement& operator*() {
return *elem; }
203 inline MonitorElement*
get() {
return elem.get(); }
205 inline bool operator==(
const Ref& o)
const {
return elem==o.elem; }
206 inline bool operator!=(
const Ref& o)
const {
return !(*
this==o); }
208 EPICS_NOT_COPYABLE(Ref)
211 #if __cplusplus>=201103L
213 inline MonitorElement::Ref
begin(Monitor& mon) {
return MonitorElement::Ref(mon); }
214 inline MonitorElement::Ref
end(Monitor& mon) {
return MonitorElement::Ref(); }
215 #endif // __cplusplus<201103L
259 public std::tr1::enable_shared_from_this<MonitorFIFO>
267 POINTER_DEFINITIONS(
Source);
274 struct epicsShareClass Config {
278 bool dropEmptyUpdates;
279 epics::pvData::PVRequestMapper::mode_t mapperMode;
289 MonitorFIFO(
const std::tr1::shared_ptr<MonitorRequester> &requester,
290 const pvData::PVStructure::const_shared_pointer &pvRequest,
291 const Source::shared_pointer& source = Source::shared_pointer(),
293 virtual ~MonitorFIFO();
297 inline const std::tr1::shared_ptr<MonitorRequester>
getRequester()
const {
return requester.lock(); }
301 virtual void destroy() OVERRIDE FINAL;
308 void setFreeHighMark(
double level);
312 void open(const epics::pvData::StructureConstPtr& type);
321 bool tryPost(const pvData::PVStructure& value,
322 const epics::pvData::BitSet& changed,
323 const epics::pvData::BitSet& overrun = epics::pvData::BitSet(),
326 void post(const pvData::PVStructure& value,
327 const epics::pvData::BitSet& changed,
328 const epics::pvData::BitSet& overrun = epics::pvData::BitSet());
336 virtual epics::pvData::Status
start() OVERRIDE FINAL;
337 virtual epics::pvData::Status stop() OVERRIDE FINAL;
338 virtual MonitorElementPtr poll() OVERRIDE FINAL;
339 virtual
void release(MonitorElementPtr const & monitorElement) OVERRIDE FINAL;
340 virtual
void getStats(Stats& s) const OVERRIDE FINAL;
341 virtual
void reportRemoteQueueStatus(epics::pvData::int32 freeElements) OVERRIDE FINAL;
344 size_t freeCount() const;
346 size_t _freeCount() const;
348 friend
void providerRegInit(
void*);
349 static
size_t num_instances;
365 mutable epicsMutex mutex;
377 const epics::pvData::PVStructure::const_shared_pointer pvRequest;
381 const Source::shared_pointer upstream;
391 epics::pvData::BitSet scratch, oscratch;
398 epics::pvData::Status error;
400 size_t freeHighLevel;
401 epicsInt32 flowCount;
403 epics::pvData::PVRequestMapper mapper;
409 buffer_t inuse, empty, returned;
417 EPICS_NOT_COPYABLE(MonitorFIFO)
428 namespace epics {
namespace pvData {
431 using epics::pvAccess::MonitorElementPtr;
434 using epics::pvAccess::MonitorPtr;
MonitorElementPtr letGo()
analogous to auto_ptr<>::release() but given a different name to avoid being confused with Monitor::r...
virtual void freeHighMark(MonitorFIFO *mon, size_t numEmpty)
Called when MonitorFIFO::freeCount() rises above the level computed from MonitorFIFO::setFreeHighMark...
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__str)
Source methods may be called with downstream mutex locked.
Access to Monitor subscription and queue.
Utility implementation of Monitor.
const std::tr1::shared_ptr< MonitorRequester > getRequester() const
Access to MonitorRequester passed to ctor, or NULL if it has already been destroyed.
enable_if< __and_< __not_< __is_tuple_like< _Tp > >, is_move_constructible< _Tp >, is_move_assignable< _Tp > >::value >::type swap(_Tp &__a, _Tp &__b) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
_Tp * begin(valarray< _Tp > &__va)
Callback implemented by monitor clients.
virtual void release(MonitorElementPtr const &monitorElement)=0
Release a MonitorElement that was returned by poll.
virtual void reportRemoteQueueStatus(epics::pvData::int32 freeElements)
Report remote queue status.
Instance declaring destroy method.
_Tp * end(valarray< _Tp > &__va)
A (single ownership) smart pointer to extract a MonitorElement from a Monitor queue.
virtual MonitorElementPtr poll()=0
If monitor has occurred return data.
An element for a monitorQueue.