This is Unofficial EPICS BASE Doxygen Site
epics::pvAccess::ServerChannelPutGetRequesterImpl Class Reference

#include "responseHandlers.h"

+ Inheritance diagram for epics::pvAccess::ServerChannelPutGetRequesterImpl:
+ Collaboration diagram for epics::pvAccess::ServerChannelPutGetRequesterImpl:

Public Types

typedef std::tr1::shared_ptr< ServerChannelPutGetRequesterImplshared_pointer
 
typedef std::tr1::shared_ptr< const ServerChannelPutGetRequesterImplconst_shared_pointer
 
- Public Types inherited from epics::pvAccess::ChannelPutGetRequester
typedef ChannelPutGet operation_type
 

Public Member Functions

virtual ~ServerChannelPutGetRequesterImpl ()
 
virtual void channelPutGetConnect (const epics::pvData::Status &status, ChannelPutGet::shared_pointer const &channelPutGet, epics::pvData::Structure::const_shared_pointer const &putStructure, epics::pvData::Structure::const_shared_pointer const &getStructure) OVERRIDE FINAL
 
virtual void getGetDone (const epics::pvData::Status &status, ChannelPutGet::shared_pointer const &channelPutGet, epics::pvData::PVStructure::shared_pointer const &pvStructure, epics::pvData::BitSet::shared_pointer const &bitSet) OVERRIDE FINAL
 
virtual void getPutDone (const epics::pvData::Status &status, ChannelPutGet::shared_pointer const &channelPutGet, epics::pvData::PVStructure::shared_pointer const &pvStructure, epics::pvData::BitSet::shared_pointer const &bitSet) OVERRIDE FINAL
 
virtual void putGetDone (const epics::pvData::Status &status, ChannelPutGet::shared_pointer const &channelPutGet, epics::pvData::PVStructure::shared_pointer const &pvStructure, epics::pvData::BitSet::shared_pointer const &bitSet) OVERRIDE FINAL
 
virtual void destroy () OVERRIDE FINAL
 
ChannelPutGet::shared_pointer getChannelPutGet ()
 
virtual std::tr1::shared_ptr< ChannelRequestgetOperation () OVERRIDE FINAL
 The Operation associated with this Requester, except for GetField and Monitor (which are special snowflakes...) More...
 
epics::pvData::PVStructure::shared_pointer getPutGetPVStructure ()
 
epics::pvData::BitSet::shared_pointer getPutGetBitSet ()
 
virtual void send (epics::pvData::ByteBuffer *buffer, TransportSendControl *control) OVERRIDE FINAL
 
- Public Member Functions inherited from epics::pvAccess::BaseChannelRequester
 POINTER_DEFINITIONS (BaseChannelRequester)
 
 BaseChannelRequester (ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
 
virtual ~BaseChannelRequester ()
 
bool startRequest (epics::pvData::int32 qos)
 
void stopRequest ()
 
epics::pvData::int32 getPendingRequest ()
 
virtual std::string getRequesterName () OVERRIDE FINAL
 
virtual void message (std::string const &message, epics::pvData::MessageType messageType) OVERRIDE FINAL
 
virtual void stats (Stats &s) const OVERRIDE FINAL
 Query current counter values. More...
 
- Public Member Functions inherited from epics::pvAccess::TransportSender
 POINTER_DEFINITIONS (TransportSender)
 
 TransportSender ()
 
virtual ~TransportSender ()
 
- Public Member Functions inherited from epics::pvAccess::Lockable
 POINTER_DEFINITIONS (Lockable)
 
virtual ~Lockable ()
 
virtual void lock ()
 
virtual void unlock ()
 
- Public Member Functions inherited from epics::pvAccess::fair_queue< T >::entry
 entry ()
 
 ~entry ()
 
- Public Member Functions inherited from epics::pvAccess::NetStats
virtual ~NetStats ()
 
- Public Member Functions inherited from epics::pvAccess::Destroyable
 POINTER_DEFINITIONS (Destroyable)
 
- Public Member Functions inherited from epics::pvAccess::ChannelPutGetRequester
 POINTER_DEFINITIONS (ChannelPutGetRequester)
 
virtual ~ChannelPutGetRequester ()
 
- Public Member Functions inherited from epics::pvAccess::ChannelBaseRequester
 POINTER_DEFINITIONS (ChannelBaseRequester)
 
 ChannelBaseRequester ()
 
virtual ~ChannelBaseRequester ()
 
virtual void channelDisconnect (bool destroy)
 

Static Public Member Functions

static ChannelPutGetRequester::shared_pointer create (ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport, epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
- Static Public Member Functions inherited from epics::pvAccess::BaseChannelRequester
static void message (Transport::shared_pointer const &transport, const pvAccessID ioid, const std::string message, const epics::pvData::MessageType messageType)
 
static void sendFailureMessage (const epics::pvData::int8 command, Transport::shared_pointer const &transport, const pvAccessID ioid, const epics::pvData::int8 qos, const epics::pvData::Status status)
 

Protected Member Functions

 ServerChannelPutGetRequesterImpl (ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
 
void activate (epics::pvData::PVStructure::shared_pointer const &pvRequest)
 
- Protected Member Functions inherited from epics::pvAccess::Destroyable
virtual ~Destroyable ()
 

Additional Inherited Members

- Public Attributes inherited from epics::pvAccess::TransportSender
size_t bytesTX
 
size_t bytesRX
 
- Static Public Attributes inherited from epics::pvAccess::BaseChannelRequester
static const epics::pvData::Status okStatus = Status()
 
static const epics::pvData::Status badCIDStatus
 
static const epics::pvData::Status badIOIDStatus
 
static const epics::pvData::Status noReadACLStatus
 
static const epics::pvData::Status noWriteACLStatus
 
static const epics::pvData::Status noProcessACLStatus
 
static const epics::pvData::Status otherRequestPendingStatus
 
static const epics::pvData::Status notAChannelRequestStatus
 
- Static Public Attributes inherited from epics::pvAccess::ChannelBaseRequester
static size_t num_instances
 
- Protected Attributes inherited from epics::pvAccess::BaseChannelRequester
const pvAccessID _ioid
 
const Transport::shared_pointer _transport
 
const std::tr1::shared_ptr< ServerChannel_channel
 
epics::pvData::Mutex _mutex
 

Detailed Description

Definition at line 400 of file responseHandlers.h.

Member Typedef Documentation

Constructor & Destructor Documentation

epics::pvAccess::ServerChannelPutGetRequesterImpl::ServerChannelPutGetRequesterImpl ( ServerContextImpl::shared_pointer const &  context,
std::tr1::shared_ptr< ServerChannel > const &  channel,
const pvAccessID  ioid,
Transport::shared_pointer const &  transport 
)
protected

Definition at line 1570 of file responseHandlers.cpp.

1571  :
1572  BaseChannelRequester(context, channel, ioid, transport), _channelPutGet(), _pvPutStructure(), _pvGetStructure()
1573 {
1574 }
BaseChannelRequester(ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
virtual epics::pvAccess::ServerChannelPutGetRequesterImpl::~ServerChannelPutGetRequesterImpl ( )
inlinevirtual

Definition at line 417 of file responseHandlers.h.

417 {}

Member Function Documentation

void epics::pvAccess::ServerChannelPutGetRequesterImpl::activate ( epics::pvData::PVStructure::shared_pointer const &  pvRequest)
protected

Definition at line 1586 of file responseHandlers.cpp.

1587 {
1589  shared_pointer thisPointer(shared_from_this());
1590  _channel->registerRequest(_ioid, thisPointer);
1591  INIT_EXCEPTION_GUARD(CMD_PUT_GET, _channelPutGet, _channel->getChannel()->createChannelPutGet(thisPointer, pvRequest));
1592 }
const std::tr1::shared_ptr< ServerChannel > _channel
#define INIT_EXCEPTION_GUARD(cmd, var, code)
bool startRequest(epics::pvData::int32 qos)
std::tr1::shared_ptr< ServerChannelPutGetRequesterImpl > shared_pointer
void epics::pvAccess::ServerChannelPutGetRequesterImpl::channelPutGetConnect ( const epics::pvData::Status status,
ChannelPutGet::shared_pointer const &  channelPutGet,
epics::pvData::Structure::const_shared_pointer const &  putStructure,
epics::pvData::Structure::const_shared_pointer const &  getStructure 
)
virtual

The client and server have both completed the createChannelPutGet request.

Parameters
statusCompletion status.
channelPutGetThe channelPutGet interface or null if the request failed.
putStructureThe put structure introspection data or nullptr if the request failed.
getStructureThe get structure introspection data or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutGetRequester.

Definition at line 1594 of file responseHandlers.cpp.

1596 {
1597  {
1598  Lock guard(_mutex);
1599  _status = status;
1600  _channelPutGet = channelPutGet;
1601  if (_status.isSuccess())
1602  {
1603  _pvPutStructure = std::tr1::static_pointer_cast<PVStructure>(reuseOrCreatePVField(putStructure, _pvPutStructure));
1604  _pvPutBitSet = createBitSetFor(_pvPutStructure, _pvPutBitSet);
1605 
1606  _pvGetStructure = std::tr1::static_pointer_cast<PVStructure>(reuseOrCreatePVField(getStructure, _pvGetStructure));
1607  _pvGetBitSet = createBitSetFor(_pvGetStructure, _pvGetBitSet);
1608  }
1609  }
1610 
1611  TransportSender::shared_pointer thisSender = shared_from_this();
1612  _transport->enqueueSendRequest(thisSender);
1613 
1614  // self-destruction
1615  if (!status.isSuccess())
1616  {
1617  destroy();
1618  }
1619 }
pvd::Status status
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
bool isSuccess() const
Definition: status.h:103
Data interface for a structure,.
Definition: pvData.h:712
ChannelPutGetRequester::shared_pointer epics::pvAccess::ServerChannelPutGetRequesterImpl::create ( ServerContextImpl::shared_pointer const &  context,
std::tr1::shared_ptr< ServerChannel > const &  channel,
const pvAccessID  ioid,
Transport::shared_pointer const &  transport,
epics::pvData::PVStructure::shared_pointer const &  pvRequest 
)
static

Definition at line 1576 of file responseHandlers.cpp.

1578 {
1579  // TODO use std::make_shared
1580  std::tr1::shared_ptr<ServerChannelPutGetRequesterImpl> tp(new ServerChannelPutGetRequesterImpl(context, channel, ioid, transport));
1581  ChannelPutGetRequester::shared_pointer thisPointer = tp;
1582  static_cast<ServerChannelPutGetRequesterImpl*>(thisPointer.get())->activate(pvRequest);
1583  return thisPointer;
1584 }
ServerChannelPutGetRequesterImpl(ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
void activate(epics::pvData::PVStructure::shared_pointer const &pvRequest)
void epics::pvAccess::ServerChannelPutGetRequesterImpl::destroy ( )
virtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Definition at line 1669 of file responseHandlers.cpp.

1670 {
1671  // keep a reference to ourselves as the owner
1672  // could release its reference and we don't want to be
1673  // destroyed prematurely
1674  shared_pointer self(shared_from_this());
1675 
1676  // hold a reference to channelPutGet so that _channelPutGet.reset()
1677  // does not call ~ChannelPutGet (external code) while we are holding a lock
1678  ChannelPutGet::shared_pointer channelPutGet = _channelPutGet;
1679  {
1680  Lock guard(_mutex);
1681  _channel->unregisterRequest(_ioid);
1682 
1683  if (_channelPutGet)
1684  {
1685  _channelPutGet->destroy();
1686  _channelPutGet.reset();
1687  }
1688  }
1689 }
const std::tr1::shared_ptr< ServerChannel > _channel
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< ServerChannelPutGetRequesterImpl > shared_pointer
ChannelPutGet::shared_pointer epics::pvAccess::ServerChannelPutGetRequesterImpl::getChannelPutGet ( )

Definition at line 1691 of file responseHandlers.cpp.

1692 {
1693  //Lock guard(_mutex);
1694  return _channelPutGet;
1695 }
void epics::pvAccess::ServerChannelPutGetRequesterImpl::getGetDone ( const epics::pvData::Status status,
ChannelPutGet::shared_pointer const &  channelPutGet,
epics::pvData::PVStructure::shared_pointer const &  pvGetStructure,
epics::pvData::BitSet::shared_pointer const &  getBitSet 
)
virtual

The getGet request is done. This is always called with no locks held.

Parameters
statusCompletion status.
channelPutGetThe channelPutGet interface.
pvGetStructureThe PVStructure that holds the getData or nullptr if the request failed.
getBitSetgetPVStructure changed bit-set or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutGetRequester.

Definition at line 1621 of file responseHandlers.cpp.

1623 {
1624  {
1625  Lock guard(_mutex);
1626  _status = status;
1627  if (_status.isSuccess())
1628  {
1629  *_pvGetBitSet = *bitSet;
1630  _pvGetStructure->copyUnchecked(*pvStructure, *_pvGetBitSet);
1631  }
1632  }
1633  TransportSender::shared_pointer thisSender = shared_from_this();
1634  _transport->enqueueSendRequest(thisSender);
1635 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
bool isSuccess() const
Definition: status.h:103
virtual std::tr1::shared_ptr<ChannelRequest> epics::pvAccess::ServerChannelPutGetRequesterImpl::getOperation ( )
inlinevirtual

The Operation associated with this Requester, except for GetField and Monitor (which are special snowflakes...)

Implements epics::pvAccess::BaseChannelRequester.

Definition at line 434 of file responseHandlers.h.

434 { return getChannelPutGet(); }
void epics::pvAccess::ServerChannelPutGetRequesterImpl::getPutDone ( const epics::pvData::Status status,
ChannelPutGet::shared_pointer const &  channelPutGet,
epics::pvData::PVStructure::shared_pointer const &  pvPutStructure,
epics::pvData::BitSet::shared_pointer const &  putBitSet 
)
virtual

The getPut request is done. This is always called with no locks held.

Parameters
statusCompletion status.
channelPutGetThe channelPutGet interface.
pvPutStructureThe PVStructure that holds the putData or nullptr if the request failed.
putBitSetputPVStructure changed bit-set or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutGetRequester.

Definition at line 1637 of file responseHandlers.cpp.

1639 {
1640  {
1641  Lock guard(_mutex);
1642  _status = status;
1643  if (_status.isSuccess())
1644  {
1645  *_pvPutBitSet = *bitSet;
1646  _pvPutStructure->copyUnchecked(*pvStructure, *_pvPutBitSet);
1647  }
1648  }
1649  TransportSender::shared_pointer thisSender = shared_from_this();
1650  _transport->enqueueSendRequest(thisSender);
1651 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
bool isSuccess() const
Definition: status.h:103
BitSet::shared_pointer epics::pvAccess::ServerChannelPutGetRequesterImpl::getPutGetBitSet ( )

Definition at line 1703 of file responseHandlers.cpp.

1704 {
1705  //Lock guard(_mutex);
1706  return _pvPutBitSet;
1707 }
PVStructure::shared_pointer epics::pvAccess::ServerChannelPutGetRequesterImpl::getPutGetPVStructure ( )

Definition at line 1697 of file responseHandlers.cpp.

1698 {
1699  //Lock guard(_mutex);
1700  return _pvPutStructure;
1701 }
void epics::pvAccess::ServerChannelPutGetRequesterImpl::putGetDone ( const epics::pvData::Status status,
ChannelPutGet::shared_pointer const &  channelPutGet,
epics::pvData::PVStructure::shared_pointer const &  pvGetStructure,
epics::pvData::BitSet::shared_pointer const &  getBitSet 
)
virtual

The putGet request is done. This is always called with no locks held.

Parameters
statusCompletion status.
channelPutGetThe channelPutGet interface.
pvGetStructureThe PVStructure that holds the getData or nullptr if the request failed.
getBitSetgetPVStructure changed bit-set or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutGetRequester.

Definition at line 1653 of file responseHandlers.cpp.

1655 {
1656  {
1657  Lock guard(_mutex);
1658  _status = status;
1659  if (_status.isSuccess())
1660  {
1661  *_pvGetBitSet = *bitSet;
1662  _pvGetStructure->copyUnchecked(*pvStructure, *_pvGetBitSet);
1663  }
1664  }
1665  TransportSender::shared_pointer thisSender = shared_from_this();
1666  _transport->enqueueSendRequest(thisSender);
1667 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
bool isSuccess() const
Definition: status.h:103
void epics::pvAccess::ServerChannelPutGetRequesterImpl::send ( epics::pvData::ByteBuffer buffer,
TransportSendControl control 
)
virtual

Called by transport. By this call transport gives callee ownership over the buffer. Calls on TransportSendControl instance must be made from calling thread. Moreover, ownership is valid only for the time of call of this method. NOTE: these limitations allow efficient implementation.

Implements epics::pvAccess::TransportSender.

Definition at line 1709 of file responseHandlers.cpp.

1710 {
1711  const int32 request = getPendingRequest();
1712 
1713  ChannelPutGet::shared_pointer channelPutGet;
1714  {
1715  Lock guard(_mutex);
1716  channelPutGet = _channelPutGet;
1717  // we must respond to QOS_INIT (e.g. creation error)
1718  if (!channelPutGet && !(request & QOS_INIT))
1719  return;
1720  }
1721 
1722  control->startMessage(CMD_PUT_GET, sizeof(int32)/sizeof(int8) + 1);
1723  buffer->putInt(_ioid);
1724  buffer->putByte((int8)request);
1725  {
1726  Lock guard(_mutex);
1727  _status.serialize(buffer, control);
1728  }
1729 
1730  if (_status.isSuccess())
1731  {
1732  if ((QOS_INIT & request) != 0)
1733  {
1734  Lock guard(_mutex);
1735  control->cachedSerialize(_pvPutStructure->getStructure(), buffer);
1736  control->cachedSerialize(_pvGetStructure->getStructure(), buffer);
1737  }
1738  else if ((QOS_GET & request) != 0)
1739  {
1740  Lock guard(_mutex);
1741  _pvGetBitSet->serialize(buffer, control);
1742  _pvGetStructure->serialize(buffer, control, _pvGetBitSet.get());
1743  }
1744  else if ((QOS_GET_PUT & request) != 0)
1745  {
1746  ScopedLock lock(channelPutGet);
1747  //Lock guard(_mutex);
1748  _pvPutBitSet->serialize(buffer, control);
1749  _pvPutStructure->serialize(buffer, control, _pvPutBitSet.get());
1750  }
1751  else
1752  {
1753  ScopedLock lock(channelPutGet);
1754  //Lock guard(_mutex);
1755  _pvGetBitSet->serialize(buffer, control);
1756  _pvGetStructure->serialize(buffer, control, _pvGetBitSet.get());
1757  }
1758  }
1759 
1760  stopRequest();
1761 
1762  // lastRequest
1763  if ((QOS_DESTROY & request) != 0)
1764  destroy();
1765 }
int8_t int8
Definition: pvType.h:75
std::string request
EPICS_ALWAYS_INLINE void putInt(int32 value)
Definition: byteBuffer.h:537
A lock for multithreading.
Definition: lock.h:36
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const
Definition: status.cpp:45
bool isSuccess() const
Definition: status.h:103
EPICS_ALWAYS_INLINE void putByte(int8 value)
Definition: byteBuffer.h:525
virtual void cachedSerialize(std::tr1::shared_ptr< const Field > const &field, ByteBuffer *buffer)=0
virtual void lock()
Definition: pvAccess.h:97
virtual void startMessage(epics::pvData::int8 command, std::size_t ensureCapacity, epics::pvData::int32 payloadSize=0)=0
int32_t int32
Definition: pvType.h:83

The documentation for this class was generated from the following files: