This is Unofficial EPICS BASE Doxygen Site
netIO.h
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  *
19  * Author Jeffrey O. Hill
20  * johill@lanl.gov
21  * 505 665 1831
22  */
23 
24 #ifndef INC_netIO_H
25 #define INC_netIO_H
26 
27 #include "nciu.h"
28 #include "compilerDependencies.h"
29 
30 // SUN PRO generates multiply defined symbols if the baseNMIU
31 // destructor is virtual (therefore it is protected).
32 // I assume that SUNPRO will fix this in future versions.
33 // With other compilers we get warnings (and
34 // potential problems) if we dont make the baseNMIU
35 // destructor virtual.
36 #if defined ( __SUNPRO_CC ) && ( __SUNPRO_CC <= 0x540 )
37 # define NETIO_VIRTUAL_DESTRUCTOR
38 #else
39 # define NETIO_VIRTUAL_DESTRUCTOR virtual
40 #endif
41 
43 
44 class baseNMIU : public tsDLNode < baseNMIU >,
45  public chronIntIdRes < baseNMIU > {
46 public:
47  virtual void destroy (
48  epicsGuard < epicsMutex > &, class cacRecycle & ) = 0; // only called by cac
49  virtual void completion (
51  virtual void exception (
53  int status, const char * pContext ) = 0;
54  virtual void exception (
56  int status, const char * pContext, unsigned type,
58  virtual void completion (
60  unsigned type, arrayElementCount count,
61  const void * pData ) = 0;
62  virtual void forceSubscriptionUpdate (
63  epicsGuard < epicsMutex > & guard, nciu & chan ) = 0;
64  virtual class netSubscription * isSubscription () = 0;
65  virtual void show (
66  unsigned level ) const = 0;
67  virtual void show (
69  unsigned level ) const = 0;
70 protected:
72 };
73 
74 class netSubscription : public baseNMIU {
75 public:
76  static netSubscription * factory (
79  unsigned mask, cacStateNotify & );
80  void show (
81  unsigned level ) const;
82  void show (
83  epicsGuard < epicsMutex > &, unsigned level ) const;
84  arrayElementCount getCount (
85  epicsGuard < epicsMutex > &, bool allow_zero ) const;
86  unsigned getType (
87  epicsGuard < epicsMutex > & ) const;
88  unsigned getMask (
89  epicsGuard < epicsMutex > & ) const;
90  void subscribeIfRequired (
91  epicsGuard < epicsMutex > & guard, nciu & chan );
92  void unsubscribeIfRequired (
93  epicsGuard < epicsMutex > & guard, nciu & chan );
94 protected:
96  class privateInterfaceForIO &, unsigned type,
97  arrayElementCount count,
98  unsigned mask, cacStateNotify & );
99  ~netSubscription ();
100 private:
101  const arrayElementCount count;
102  class privateInterfaceForIO & privateChanForIO;
103  cacStateNotify & notify;
104  const unsigned type;
105  const unsigned mask;
106  bool subscribed;
107  class netSubscription * isSubscription ();
108  void operator delete ( void * );
109  void * operator new ( size_t,
111  epicsPlacementDeleteOperator (( void *,
113  void destroy (
115  void completion (
117  void exception (
119  int status, const char * pContext );
120  void completion (
122  unsigned type, arrayElementCount count, const void * pData );
123  void exception (
125  int status, const char * pContext, unsigned type,
126  arrayElementCount count );
128  epicsGuard < epicsMutex > & guard, nciu & chan );
129  netSubscription ( const netSubscription & );
131 };
132 
133 class netReadNotifyIO : public baseNMIU {
134 public:
135  static netReadNotifyIO * factory (
138  void show (
139  unsigned level ) const;
140  void show (
141  epicsGuard < epicsMutex > &, unsigned level ) const;
142 protected:
144  ~netReadNotifyIO ();
145 private:
146  cacReadNotify & notify;
147  class privateInterfaceForIO & privateChanForIO;
148  void operator delete ( void * );
149  void * operator new ( size_t,
151  epicsPlacementDeleteOperator (( void *,
153  void destroy (
155  void completion (
157  void exception (
159  int status, const char * pContext );
160  void completion (
162  unsigned type, arrayElementCount count,
163  const void * pData );
164  void exception (
166  int status, const char * pContext,
167  unsigned type, arrayElementCount count );
168  class netSubscription * isSubscription ();
170  epicsGuard < epicsMutex > & guard, nciu & chan );
171  netReadNotifyIO ( const netReadNotifyIO & );
173 };
174 
175 class netWriteNotifyIO : public baseNMIU {
176 public:
177  static netWriteNotifyIO * factory (
180  void show (
181  unsigned level ) const;
182  void show (
183  epicsGuard < epicsMutex > &, unsigned level ) const;
184 protected:
186  ~netWriteNotifyIO ();
187 private:
188  cacWriteNotify & notify;
189  privateInterfaceForIO & privateChanForIO;
190  void operator delete ( void * );
191  void * operator new ( size_t,
193  epicsPlacementDeleteOperator (( void *,
195  class netSubscription * isSubscription ();
196  void destroy (
198  void completion (
200  void exception (
202  int status, const char * pContext );
203  void completion (
205  unsigned type, arrayElementCount count,
206  const void * pData );
207  void exception (
209  int status, const char * pContext, unsigned type,
210  arrayElementCount count );
212  epicsGuard < epicsMutex > & guard, nciu & chan );
215 };
216 
217 inline void * netSubscription::operator new ( size_t size,
219 {
220  return freeList.allocate ( size );
221 }
222 
223 #if defined ( CXX_PLACEMENT_DELETE )
224  inline void netSubscription::operator delete ( void *pCadaver,
226  {
227  freeList.release ( pCadaver );
228  }
229 #endif
230 
233  class privateInterfaceForIO & chan, unsigned type, arrayElementCount count,
234  unsigned mask, cacStateNotify &notify )
235 {
236  return new ( freeList ) netSubscription ( chan, type,
237  count, mask, notify );
238 }
239 
241  epicsGuard < epicsMutex > & guard, bool allow_zero ) const
242 {
243  //guard.assertIdenticalMutex ( this->mutex );
244  arrayElementCount nativeCount = this->privateChanForIO.nativeElementCount ( guard );
245  if ( (this->count == 0u && !allow_zero) || this->count > nativeCount ) {
246  return nativeCount;
247  }
248  else {
249  return this->count;
250  }
251 }
252 
254 {
255  return this->type;
256 }
257 
259 {
260  return this->mask;
261 }
262 
265  privateInterfaceForIO & ioComplNotifIntf, cacReadNotify & notify )
266 {
267  return new ( freeList ) netReadNotifyIO ( ioComplNotifIntf, notify );
268 }
269 
270 inline void * netReadNotifyIO::operator new ( size_t size,
272 {
273  return freeList.allocate ( size );
274 }
275 
276 #if defined ( CXX_PLACEMENT_DELETE )
277  inline void netReadNotifyIO::operator delete ( void *pCadaver,
279  {
280  freeList.release ( pCadaver );
281  }
282 #endif
283 
286  privateInterfaceForIO & ioComplNotifyIntf, cacWriteNotify & notify )
287 {
288  return new ( freeList ) netWriteNotifyIO ( ioComplNotifyIntf, notify );
289 }
290 
291 inline void * netWriteNotifyIO::operator new ( size_t size,
293 {
294  return freeList.allocate ( size );
295 }
296 
297 #if defined ( CXX_PLACEMENT_DELETE )
298  inline void netWriteNotifyIO::operator delete ( void *pCadaver,
300  {
301  freeList.release ( pCadaver );
302  }
303 #endif
304 
305 #endif // ifdef INC_netIO_H
virtual void show(unsigned level) const =0
virtual void exception epicsGuard< epicsMutex > cacRecycle int const char unsigned type
Definition: netIO.h:54
static netWriteNotifyIO * factory(tsFreeList< class netWriteNotifyIO, 1024, epicsMutexNOOP > &, privateInterfaceForIO &, cacWriteNotify &)
Definition: netIO.h:284
unsigned getMask(epicsGuard< epicsMutex > &) const
Definition: netIO.h:258
Definition: netIO.h:44
static netSubscription * factory(tsFreeList< class netSubscription, 1024, epicsMutexNOOP > &, class privateInterfaceForIO &, unsigned type, arrayElementCount count, unsigned mask, cacStateNotify &)
Definition: netIO.h:231
const tsDLNode< baseNMIU > & operator=(const tsDLNode< baseNMIU > &)
virtual void forceSubscriptionUpdate(epicsGuard< epicsMutex > &guard, nciu &chan)=0
Definition: baseNMIU.cpp:31
netSubscription(class privateInterfaceForIO &, unsigned type, arrayElementCount count, unsigned mask, cacStateNotify &)
Definition: cac.h:50
virtual void exception epicsGuard< epicsMutex > cacRecycle int status
Definition: netIO.h:51
virtual void destroy(epicsGuard< epicsMutex > &, class cacRecycle &)=0
arrayElementCount getCount(epicsGuard< epicsMutex > &, bool allow_zero) const
Definition: netIO.h:240
virtual class netSubscription * isSubscription()=0
unsigned long arrayElementCount
Definition: cacIO.h:57
virtual void completion(epicsGuard< epicsMutex > &, cacRecycle &)=0
#define NETIO_VIRTUAL_DESTRUCTOR
Definition: netIO.h:39
Compiler specific declarations.
virtual void exception epicsGuard< epicsMutex > cacRecycle int const char unsigned arrayElementCount count
Definition: netIO.h:57
static netReadNotifyIO * factory(tsFreeList< class netReadNotifyIO, 1024, epicsMutexNOOP > &, privateInterfaceForIO &, cacReadNotify &)
Definition: netIO.h:263
virtual void exception epicsGuard< epicsMutex > cacRecycle int const char * pContext
Definition: netIO.h:53
unsigned getType(epicsGuard< epicsMutex > &) const
Definition: netIO.h:253
NETIO_VIRTUAL_DESTRUCTOR ~baseNMIU()
Definition: baseNMIU.cpp:27
Definition: nciu.h:127