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

#include "responseHandlers.h"

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

Public Types

typedef std::tr1::shared_ptr< ServerChannelPutRequesterImplshared_pointer
 
typedef std::tr1::shared_ptr< const ServerChannelPutRequesterImplconst_shared_pointer
 
- Public Types inherited from epics::pvAccess::ChannelPutRequester
typedef ChannelPut operation_type
 

Public Member Functions

virtual ~ServerChannelPutRequesterImpl ()
 
virtual void channelPutConnect (const epics::pvData::Status &status, ChannelPut::shared_pointer const &channelPut, epics::pvData::Structure::const_shared_pointer const &structure) OVERRIDE FINAL
 
virtual void putDone (const epics::pvData::Status &status, ChannelPut::shared_pointer const &channelPut) OVERRIDE FINAL
 
virtual void getDone (const epics::pvData::Status &status, ChannelPut::shared_pointer const &channelPut, epics::pvData::PVStructure::shared_pointer const &pvStructure, epics::pvData::BitSet::shared_pointer const &bitSet) OVERRIDE FINAL
 
virtual void destroy () OVERRIDE FINAL
 
ChannelPut::shared_pointer getChannelPut ()
 
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::BitSet::shared_pointer getPutBitSet ()
 
epics::pvData::PVStructure::shared_pointer getPutPVStructure ()
 
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::ChannelPutRequester
 POINTER_DEFINITIONS (ChannelPutRequester)
 
virtual ~ChannelPutRequester ()
 
- Public Member Functions inherited from epics::pvAccess::ChannelBaseRequester
 POINTER_DEFINITIONS (ChannelBaseRequester)
 
 ChannelBaseRequester ()
 
virtual ~ChannelBaseRequester ()
 
virtual void channelDisconnect (bool destroy)
 

Static Public Member Functions

static ChannelPutRequester::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

 ServerChannelPutRequesterImpl (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 342 of file responseHandlers.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 1328 of file responseHandlers.cpp.

1329  :
1330  BaseChannelRequester(context, channel, ioid, transport)
1331 {
1332 }
BaseChannelRequester(ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
virtual epics::pvAccess::ServerChannelPutRequesterImpl::~ServerChannelPutRequesterImpl ( )
inlinevirtual

Definition at line 360 of file responseHandlers.h.

360 {}

Member Function Documentation

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

Definition at line 1344 of file responseHandlers.cpp.

1345 {
1347  shared_pointer thisPointer(shared_from_this());
1348  _channel->registerRequest(_ioid, thisPointer);
1349  INIT_EXCEPTION_GUARD(CMD_PUT, _channelPut, _channel->getChannel()->createChannelPut(thisPointer, pvRequest));
1350 }
const std::tr1::shared_ptr< ServerChannel > _channel
#define INIT_EXCEPTION_GUARD(cmd, var, code)
bool startRequest(epics::pvData::int32 qos)
std::tr1::shared_ptr< ServerChannelPutRequesterImpl > shared_pointer
void epics::pvAccess::ServerChannelPutRequesterImpl::channelPutConnect ( const epics::pvData::Status status,
ChannelPut::shared_pointer const &  channelPut,
epics::pvData::Structure::const_shared_pointer const &  structure 
)
virtual

The client and server have both processed the createChannelPut request.

Parameters
statusCompletion status.
channelPutThe channelPut interface or null if the request failed.
structureThe introspection interface of requested put/get structure or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutRequester.

Definition at line 1352 of file responseHandlers.cpp.

1353 {
1354  {
1355  Lock guard(_mutex);
1356  _status = status;
1357  _channelPut = channelPut;
1358  if (_status.isSuccess())
1359  {
1360  _pvStructure = std::tr1::static_pointer_cast<PVStructure>(reuseOrCreatePVField(structure, _pvStructure));
1361  _bitSet = createBitSetFor(_pvStructure, _bitSet);
1362  }
1363  }
1364 
1365  TransportSender::shared_pointer thisSender = shared_from_this();
1366  _transport->enqueueSendRequest(thisSender);
1367 
1368  // self-destruction
1369  if (!status.isSuccess())
1370  {
1371  destroy();
1372  }
1373 }
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
ChannelPutRequester::shared_pointer epics::pvAccess::ServerChannelPutRequesterImpl::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 1334 of file responseHandlers.cpp.

1336 {
1337  // TODO use std::make_shared
1338  std::tr1::shared_ptr<ServerChannelPutRequesterImpl> tp(new ServerChannelPutRequesterImpl(context, channel, ioid, transport));
1339  ChannelPutRequester::shared_pointer thisPointer = tp;
1340  static_cast<ServerChannelPutRequesterImpl*>(thisPointer.get())->activate(pvRequest);
1341  return thisPointer;
1342 }
ServerChannelPutRequesterImpl(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::ServerChannelPutRequesterImpl::destroy ( )
virtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Definition at line 1400 of file responseHandlers.cpp.

1401 {
1402  // keep a reference to ourselves as the owner
1403  // could release its reference and we don't want to be
1404  // destroyed prematurely
1405  shared_pointer self(shared_from_this());
1406 
1407  // hold a reference to channelGet so that _channelPut.reset()
1408  // does not call ~ChannelPut (external code) while we are holding a lock
1409  ChannelPut::shared_pointer channelPut = _channelPut;
1410  {
1411  Lock guard(_mutex);
1412  _channel->unregisterRequest(_ioid);
1413 
1414  if (_channelPut)
1415  {
1416  _channelPut->destroy();
1417  _channelPut.reset();
1418  }
1419  }
1420 }
const std::tr1::shared_ptr< ServerChannel > _channel
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< ServerChannelPutRequesterImpl > shared_pointer
ChannelPut::shared_pointer epics::pvAccess::ServerChannelPutRequesterImpl::getChannelPut ( )

Definition at line 1422 of file responseHandlers.cpp.

1423 {
1424  //Lock guard(_mutex);
1425  return _channelPut;
1426 }
void epics::pvAccess::ServerChannelPutRequesterImpl::getDone ( const epics::pvData::Status status,
ChannelPut::shared_pointer const &  channelPut,
epics::pvData::PVStructure::shared_pointer const &  pvStructure,
epics::pvData::BitSet::shared_pointer const &  bitSet 
)
virtual

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

Ownership transfer as with ChannelGetRequester::getDone()

Parameters
statusCompletion status.
channelPutThe channelPut interface.
pvStructureThe PVStructure that holds the data or nullptr if the request failed.
bitSetThe bitSet for that shows what data has changed or nullptr if the request failed.

Implements epics::pvAccess::ChannelPutRequester.

Definition at line 1385 of file responseHandlers.cpp.

1386 {
1387  {
1388  Lock guard(_mutex);
1389  _status = status;
1390  if (_status.isSuccess())
1391  {
1392  *_bitSet = *bitSet;
1393  _pvStructure->copyUnchecked(*pvStructure, *_bitSet);
1394  }
1395  }
1396  TransportSender::shared_pointer thisSender = shared_from_this();
1397  _transport->enqueueSendRequest(thisSender);
1398 }
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::ServerChannelPutRequesterImpl::getOperation ( )
inlinevirtual

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

Implements epics::pvAccess::BaseChannelRequester.

Definition at line 370 of file responseHandlers.h.

370 { return getChannelPut(); }
BitSet::shared_pointer epics::pvAccess::ServerChannelPutRequesterImpl::getPutBitSet ( )

Definition at line 1428 of file responseHandlers.cpp.

1429 {
1430  //Lock guard(_mutex);
1431  return _bitSet;
1432 }
PVStructure::shared_pointer epics::pvAccess::ServerChannelPutRequesterImpl::getPutPVStructure ( )

Definition at line 1434 of file responseHandlers.cpp.

1435 {
1436  //Lock guard(_mutex);
1437  return _pvStructure;
1438 }
void epics::pvAccess::ServerChannelPutRequesterImpl::putDone ( const epics::pvData::Status status,
ChannelPut::shared_pointer const &  channelPut 
)
virtual

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

Parameters
statusCompletion status.
channelPutThe channelPut interface.

Implements epics::pvAccess::ChannelPutRequester.

Definition at line 1375 of file responseHandlers.cpp.

1376 {
1377  {
1378  Lock guard(_mutex);
1379  _status = status;
1380  }
1381  TransportSender::shared_pointer thisSender = shared_from_this();
1382  _transport->enqueueSendRequest(thisSender);
1383 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
void epics::pvAccess::ServerChannelPutRequesterImpl::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 1440 of file responseHandlers.cpp.

1441 {
1442  const int32 request = getPendingRequest();
1443 
1444  ChannelPut::shared_pointer channelPut;
1445  {
1446  Lock guard(_mutex);
1447  channelPut = _channelPut;
1448  // we must respond to QOS_INIT (e.g. creation error)
1449  if (!channelPut && !(request & QOS_INIT))
1450  return;
1451  }
1452 
1453  control->startMessage((int32)CMD_PUT, sizeof(int32)/sizeof(int8) + 1);
1454  buffer->putInt(_ioid);
1455  buffer->putByte((int8)request);
1456  {
1457  Lock guard(_mutex);
1458  _status.serialize(buffer, control);
1459  }
1460 
1461  if (_status.isSuccess())
1462  {
1463  if ((QOS_INIT & request) != 0)
1464  {
1465  Lock guard(_mutex);
1466  control->cachedSerialize(_pvStructure->getStructure(), buffer);
1467  }
1468  else if ((QOS_GET & request) != 0)
1469  {
1470  ScopedLock lock(channelPut);
1471  _bitSet->serialize(buffer, control);
1472  _pvStructure->serialize(buffer, control, _bitSet.get());
1473  }
1474  }
1475 
1476  stopRequest();
1477 
1478  // lastRequest
1479  if ((QOS_DESTROY & request) != 0)
1480  destroy();
1481 }
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: