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

#include "responseHandlers.h"

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

Public Types

typedef std::tr1::shared_ptr< ServerChannelArrayRequesterImplshared_pointer
 
typedef std::tr1::shared_ptr< const ServerChannelArrayRequesterImplconst_shared_pointer
 
- Public Types inherited from epics::pvAccess::ChannelArrayRequester
typedef ChannelArray operation_type
 

Public Member Functions

virtual ~ServerChannelArrayRequesterImpl ()
 
virtual void channelArrayConnect (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray, epics::pvData::Array::const_shared_pointer const &array) OVERRIDE FINAL
 
virtual void getArrayDone (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray, epics::pvData::PVArray::shared_pointer const &pvArray) OVERRIDE FINAL
 
virtual void putArrayDone (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray) OVERRIDE FINAL
 
virtual void setLengthDone (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray) OVERRIDE FINAL
 
virtual void getLengthDone (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray, std::size_t length) OVERRIDE FINAL
 
virtual void destroy () OVERRIDE FINAL
 
ChannelArray::shared_pointer getChannelArray ()
 
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::PVArray::shared_pointer getPVArray ()
 
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::ChannelArrayRequester
 POINTER_DEFINITIONS (ChannelArrayRequester)
 
virtual ~ChannelArrayRequester ()
 
virtual void getLengthDone (const epics::pvData::Status &status, ChannelArray::shared_pointer const &channelArray, size_t length)=0
 
- Public Member Functions inherited from epics::pvAccess::ChannelBaseRequester
 POINTER_DEFINITIONS (ChannelBaseRequester)
 
 ChannelBaseRequester ()
 
virtual ~ChannelBaseRequester ()
 
virtual void channelDisconnect (bool destroy)
 

Static Public Member Functions

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

 ServerChannelArrayRequesterImpl (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 534 of file responseHandlers.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 2209 of file responseHandlers.cpp.

2211  :
2212  BaseChannelRequester(context, channel, ioid, transport)
2213 {
2214 }
BaseChannelRequester(ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
virtual epics::pvAccess::ServerChannelArrayRequesterImpl::~ServerChannelArrayRequesterImpl ( )
inlinevirtual

Definition at line 551 of file responseHandlers.h.

551 {}

Member Function Documentation

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

Definition at line 2227 of file responseHandlers.cpp.

2228 {
2230  shared_pointer thisPointer(shared_from_this());
2231  _channel->registerRequest(_ioid, thisPointer);
2232  INIT_EXCEPTION_GUARD(CMD_ARRAY, _channelArray, _channel->getChannel()->createChannelArray(thisPointer, pvRequest));
2233 }
const std::tr1::shared_ptr< ServerChannel > _channel
#define INIT_EXCEPTION_GUARD(cmd, var, code)
bool startRequest(epics::pvData::int32 qos)
std::tr1::shared_ptr< ServerChannelArrayRequesterImpl > shared_pointer
void epics::pvAccess::ServerChannelArrayRequesterImpl::channelArrayConnect ( const epics::pvData::Status status,
ChannelArray::shared_pointer const &  channelArray,
epics::pvData::Array::const_shared_pointer const &  array 
)
virtual

Underlying Channel is connected and operation setup is complete. May call putArray(), getArray(), getLength(), or setLength() to execute.

Parameters
statusCompletion status.
channelArrayThe channelArray interface or nullptr if the request failed.
pvArrayThe PVArray that holds the data or nullptr if the request failed.

Implements epics::pvAccess::ChannelArrayRequester.

Definition at line 2235 of file responseHandlers.cpp.

2236 {
2237  if (status.isSuccess() && array->getArraySizeType() == Array::fixed)
2238  {
2239  Lock guard(_mutex);
2240  _status = Status(Status::STATUSTYPE_ERROR, "fixed sized array returned as a ChannelArray array instance");
2241  _channelArray.reset();
2242  _pvArray.reset();
2243  }
2244  else
2245  {
2246  Lock guard(_mutex);
2247  _status = status;
2248  _channelArray = channelArray;
2249  if (_status.isSuccess())
2250  {
2251  _pvArray = std::tr1::static_pointer_cast<PVArray>(reuseOrCreatePVField(array, _pvArray));
2252  }
2253  }
2254 
2255  TransportSender::shared_pointer thisSender = shared_from_this();
2256  _transport->enqueueSendRequest(thisSender);
2257 
2258  // self-destruction
2259  if (!status.isSuccess())
2260  {
2261  destroy();
2262  }
2263 }
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
PVArray is the base class for all array types.
Definition: pvData.h:551
ChannelArrayRequester::shared_pointer epics::pvAccess::ServerChannelArrayRequesterImpl::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 2216 of file responseHandlers.cpp.

2219 {
2220  // TODO use std::make_shared
2221  std::tr1::shared_ptr<ServerChannelArrayRequesterImpl> tp(new ServerChannelArrayRequesterImpl(context, channel, ioid, transport));
2222  ChannelArrayRequester::shared_pointer thisPointer = tp;
2223  static_cast<ServerChannelArrayRequesterImpl*>(thisPointer.get())->activate(pvRequest);
2224  return thisPointer;
2225 }
void activate(epics::pvData::PVStructure::shared_pointer const &pvRequest)
ServerChannelArrayRequesterImpl(ServerContextImpl::shared_pointer const &context, std::tr1::shared_ptr< ServerChannel > const &channel, const pvAccessID ioid, Transport::shared_pointer const &transport)
void epics::pvAccess::ServerChannelArrayRequesterImpl::destroy ( )
virtual

Destroy this instance.

Implements epics::pvAccess::Destroyable.

Definition at line 2311 of file responseHandlers.cpp.

2312 {
2313  // keep a reference to ourselves as the owner
2314  // could release its reference and we don't want to be
2315  // destroyed prematurely
2316  shared_pointer self(shared_from_this());
2317 
2318  // hold a reference to channelArray so that _channelArray.reset()
2319  // does not call ~ChannelArray (external code) while we are holding a lock
2320  ChannelArray::shared_pointer channelArray = _channelArray;
2321  {
2322  Lock guard(_mutex);
2323  _channel->unregisterRequest(_ioid);
2324 
2325  if (_channelArray)
2326  {
2327  _channelArray->destroy();
2328  _channelArray.reset();
2329  }
2330  }
2331 }
const std::tr1::shared_ptr< ServerChannel > _channel
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< ServerChannelArrayRequesterImpl > shared_pointer
void epics::pvAccess::ServerChannelArrayRequesterImpl::getArrayDone ( const epics::pvData::Status status,
ChannelArray::shared_pointer const &  channelArray,
epics::pvData::PVArray::shared_pointer const &  pvArray 
)
virtual

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

Ownership of the PVArray is transfered to the ChannelArrayRequester until a subsequent call to ChannelArray::getArray() or ChannelArrayRequester::channelDisconnect().

Parameters
statusCompletion status.
channelArrayThe channelArray interface.
pvArrayThe PVArray that holds the data or nullptr if the request failed.

Implements epics::pvAccess::ChannelArrayRequester.

Definition at line 2265 of file responseHandlers.cpp.

2266 {
2267  {
2268  Lock guard(_mutex);
2269  _status = status;
2270  if (_status.isSuccess())
2271  {
2272  _pvArray->copyUnchecked(*pvArray);
2273  }
2274  }
2275  TransportSender::shared_pointer thisSender = shared_from_this();
2276  _transport->enqueueSendRequest(thisSender);
2277 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
bool isSuccess() const
Definition: status.h:103
ChannelArray::shared_pointer epics::pvAccess::ServerChannelArrayRequesterImpl::getChannelArray ( )

Definition at line 2333 of file responseHandlers.cpp.

2334 {
2335  //Lock guard(_mutex);
2336  return _channelArray;
2337 }
void epics::pvAccess::ServerChannelArrayRequesterImpl::getLengthDone ( const epics::pvData::Status status,
ChannelArray::shared_pointer const &  channelArray,
std::size_t  length 
)
virtual

Definition at line 2299 of file responseHandlers.cpp.

2301 {
2302  {
2303  Lock guard(_mutex);
2304  _status = status;
2305  _length = length;
2306  }
2307  TransportSender::shared_pointer thisSender = shared_from_this();
2308  _transport->enqueueSendRequest(thisSender);
2309 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
virtual std::tr1::shared_ptr<ChannelRequest> epics::pvAccess::ServerChannelArrayRequesterImpl::getOperation ( )
inlinevirtual

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

Implements epics::pvAccess::BaseChannelRequester.

Definition at line 569 of file responseHandlers.h.

569 { return getChannelArray(); }
PVArray::shared_pointer epics::pvAccess::ServerChannelArrayRequesterImpl::getPVArray ( )

Definition at line 2339 of file responseHandlers.cpp.

2340 {
2341  //Lock guard(_mutex);
2342  return _pvArray;
2343 }
void epics::pvAccess::ServerChannelArrayRequesterImpl::putArrayDone ( const epics::pvData::Status status,
ChannelArray::shared_pointer const &  channelArray 
)
virtual

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

Ownership of PVArray passed to ChannelArray::putArray() returns to ChannelArrayRequester

Parameters
statusCompletion status.
channelArrayThe channelArray interface.

Implements epics::pvAccess::ChannelArrayRequester.

Definition at line 2279 of file responseHandlers.cpp.

2280 {
2281  {
2282  Lock guard(_mutex);
2283  _status = status;
2284  }
2285  TransportSender::shared_pointer thisSender = shared_from_this();
2286  _transport->enqueueSendRequest(thisSender);
2287 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport
void epics::pvAccess::ServerChannelArrayRequesterImpl::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 2345 of file responseHandlers.cpp.

2346 {
2347  const int32 request = getPendingRequest();
2348 
2349  ChannelArray::shared_pointer channelArray;
2350  {
2351  Lock guard(_mutex);
2352  channelArray = _channelArray;
2353  // we must respond to QOS_INIT (e.g. creation error)
2354  if (!channelArray && !(request & QOS_INIT))
2355  return;
2356  }
2357 
2358  control->startMessage((int32)CMD_ARRAY, sizeof(int32)/sizeof(int8) + 1);
2359  buffer->putInt(_ioid);
2360  buffer->putByte((int8)request);
2361  {
2362  Lock guard(_mutex);
2363  _status.serialize(buffer, control);
2364  }
2365 
2366  if (_status.isSuccess())
2367  {
2368  if ((QOS_GET & request) != 0)
2369  {
2370  //Lock guard(_mutex);
2371  ScopedLock lock(channelArray);
2372  _pvArray->serialize(buffer, control, 0, _pvArray->getLength());
2373  }
2374  else if ((QOS_PROCESS & request) != 0)
2375  {
2376  //Lock guard(_mutex);
2377  SerializeHelper::writeSize(_length, buffer, control);
2378  }
2379  else if ((QOS_INIT & request) != 0)
2380  {
2381  Lock guard(_mutex);
2382  control->cachedSerialize(_pvArray->getArray(), buffer);
2383  }
2384  }
2385 
2386  stopRequest();
2387 
2388  // lastRequest
2389  if ((QOS_DESTROY & request) != 0)
2390  destroy();
2391 }
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
static void writeSize(std::size_t s, ByteBuffer *buffer, SerializableControl *flusher)
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
void epics::pvAccess::ServerChannelArrayRequesterImpl::setLengthDone ( const epics::pvData::Status status,
ChannelArray::shared_pointer const &  channelArray 
)
virtual

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

Parameters
statusCompletion status.
channelArrayThe channelArray interface.

Implements epics::pvAccess::ChannelArrayRequester.

Definition at line 2289 of file responseHandlers.cpp.

2290 {
2291  {
2292  Lock guard(_mutex);
2293  _status = status;
2294  }
2295  TransportSender::shared_pointer thisSender = shared_from_this();
2296  _transport->enqueueSendRequest(thisSender);
2297 }
pvd::Status status
A lock for multithreading.
Definition: lock.h:36
const Transport::shared_pointer _transport

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