This is Unofficial EPICS BASE Doxygen Site
oldSubscription.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 /*
11  *
12  * L O S A L A M O S
13  * Los Alamos National Laboratory
14  * Los Alamos, New Mexico 87545
15  *
16  * Copyright, 1986, The Regents of the University of California.
17  *
18  * Author: Jeff Hill
19  */
20 
21 #include <stdexcept>
22 
23 #include "errlog.h"
24 
25 #include "iocinf.h"
26 #include "oldAccess.h"
27 
30  oldChannelNotify & chanIn, cacChannel & io,
31  unsigned type, arrayElementCount nElem, unsigned mask,
32  caEventCallBackFunc * pFuncIn, void * pPrivateIn,
33  evid * pEventId ) :
34  chan ( chanIn ), id ( UINT_MAX ), pFunc ( pFuncIn ),
35  pPrivate ( pPrivateIn )
36 {
37  // The users event id *must* be set prior to potentially
38  // calling his callback from within subscribe.
39  if ( pEventId ) {
40  *pEventId = this;
41  }
42  io.subscribe ( guard, type, nElem, mask, *this, &this->id );
43  // Dont touch this pointer after this point because the
44  // 1st update callback might cancel the subscription and
45  // thereby destroy this object.
46 }
47 
49 {
50 }
51 
54  unsigned type, arrayElementCount count, const void * pData )
55 {
56  struct event_handler_args args;
57  args.usr = this->pPrivate;
58  args.chid = & this->chan;
59  args.type = static_cast < long > ( type );
60  args.count = static_cast < long > ( count );
61  args.status = ECA_NORMAL;
62  args.dbr = pData;
63  caEventCallBackFunc * pFuncTmp = this->pFunc;
64  {
65  epicsGuardRelease < epicsMutex > unguard ( guard );
66  ( *pFuncTmp ) ( args );
67  }
68 }
69 
70 void oldSubscription::exception (
72  int status, const char * /* pContext */,
73  unsigned type, arrayElementCount count )
74 {
75  if ( status == ECA_CHANDESTROY ) {
76  ca_client_context & cac = this->chan.getClientCtx ();
77  cac.destroySubscription ( guard, *this );
78  }
79  else if ( status != ECA_DISCONN ) {
80  struct event_handler_args args;
81  args.usr = this->pPrivate;
82  args.chid = & this->chan;
83  args.type = type;
84  args.count = count;
85  args.status = status;
86  args.dbr = 0;
87  caEventCallBackFunc * pFuncTmp = this->pFunc;
88  {
89  epicsGuardRelease < epicsMutex > unguard ( guard );
90  ( *pFuncTmp ) ( args );
91  }
92  }
93 }
94 
95 void oldSubscription::operator delete ( void * )
96 {
97  // Visual C++ .net appears to require operator delete if
98  // placement operator delete is defined? I smell a ms rat
99  // because if I declare placement new and delete, but
100  // comment out the placement delete definition there are
101  // no undefined symbols.
102  errlogPrintf ( "%s:%d this compiler is confused about placement delete - memory was probably leaked",
103  __FILE__, __LINE__ );
104 }
105 
void destroySubscription(epicsGuard< epicsMutex > &, oldSubscription &)
Definition: cac.h:97
const void * dbr
Definition: cadef.h:89
void caEventCallBackFunc(struct event_handler_args)
Definition: cadef.h:92
pvd::StructureConstPtr type
void exception epicsGuard< epicsMutex > int const char unsigned type
Definition: oldAccess.h:273
void * pPrivate
Definition: oldAccess.h:269
caEventCallBackFunc * pFunc
Definition: oldAccess.h:268
#define ECA_DISCONN
Definition: caerr.h:101
void exception epicsGuard< epicsMutex > int const char unsigned arrayElementCount count
Definition: oldAccess.h:273
#define ECA_NORMAL
Definition: caerr.h:77
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
unsigned long arrayElementCount
Definition: cacIO.h:57
chanId chid
Definition: cadef.h:86
#define ECA_CHANDESTROY
Definition: caerr.h:132
virtual void subscribe(epicsGuard< epicsMutex > &, unsigned type, arrayElementCount count, unsigned mask, cacStateNotify &, ioid *=0)=0
void current(epicsGuard< epicsMutex > &, unsigned type, arrayElementCount count, const void *pData)
void exception epicsGuard< epicsMutex > int status
Definition: oldAccess.h:273
oldSubscription(epicsGuard< epicsMutex > &guard, oldChannelNotify &chanIn, cacChannel &io, unsigned type, arrayElementCount nElem, unsigned mask, caEventCallBackFunc *pFuncIn, void *pPrivateIn, evid *)
void * usr
Definition: cadef.h:85