This is Unofficial EPICS BASE Doxygen Site
cacChannel.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  *
13  * L O S A L A M O S
14  * Los Alamos National Laboratory
15  * Los Alamos, New Mexico 87545
16  *
17  * Copyright, 1986, The Regents of the University of California.
18  *
19  * Author: Jeff Hill
20  */
21 
22 #include <stdexcept>
23 #include <float.h>
24 
25 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
26 
27 #include "errlog.h"
28 
29 #include "iocinf.h"
30 #include "localHostName.h"
31 #include "cacIO.h"
32 
34 public:
36  unsigned getHostName ( char * pBuf, unsigned bufLength );
37  const char * pHostName ();
38 private:
40  _refLocalHostName;
41 };
42 
43 static epicsThreadOnceId cacChannelIdOnce = EPICS_THREAD_ONCE_INIT;
44 
49 const cacChannel::priLev cacChannel::priorityArchive = ( priorityMax - priorityMin ) / 2;
51 
53 {
54 }
55 
58 {
59  static caAccessRights ar ( true, true );
60  return ar;
61 }
62 
65 {
66  return 0u;
67 }
68 
71 {
72  return - DBL_MAX;
73 }
74 
77 {
78  return - DBL_MAX;
79 }
80 
83 {
84  return true;
85 }
86 
89 {
90  return true;
91 }
92 
95  _refLocalHostName ( localHostNameCache.getReference () )
96 {
97 }
98 
99 inline unsigned CACChannelPrivate ::
100  getHostName ( char * pBuf, unsigned bufLength )
101 {
102  return _refLocalHostName->getName ( pBuf, bufLength );
103 }
104 
105 inline const char * CACChannelPrivate ::
107 {
108  return _refLocalHostName->pointer ();
109 }
110 
111 static CACChannelPrivate * pCACChannelPrivate = 0;
112 
113 // runs once only for each process
114 extern "C" void cacChannelSetup ( void * )
115 {
116  pCACChannelPrivate = new CACChannelPrivate ();
117 }
118 
119 // the default is to assume that it is a locally hosted channel
122  char * pBuf, unsigned bufLength ) const throw ()
123 {
124  if ( bufLength ) {
125  epicsThreadOnce ( & cacChannelIdOnce, cacChannelSetup, 0);
126  return pCACChannelPrivate->getHostName ( pBuf, bufLength );
127  }
128  return 0u;
129 }
130 
131 // the default is to assume that it is a locally hosted channel
132 const char * cacChannel::pHostName (
133  epicsGuard < epicsMutex > & ) const throw ()
134 {
135  epicsThreadOnce ( & cacChannelIdOnce, cacChannelSetup, 0);
136  return pCACChannelPrivate->pHostName ();
137 }
138 
140 
142 
143 
epicsSingleton< localHostName > localHostNameCache
virtual ~cacChannel()=0
Definition: cacChannel.cpp:52
virtual double beaconPeriod(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:69
unsigned getHostName(char *pBuf, unsigned bufLength)
Definition: cacChannel.cpp:100
void cacChannelSetup(void *)
Definition: cacChannel.cpp:114
static const priLev priorityMin
Definition: cacIO.h:167
virtual double receiveWatchdogDelay(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:75
static const priLev priorityMax
Definition: cacIO.h:166
static const priLev priorityOPI
Definition: cacIO.h:171
virtual unsigned getHostName(epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLength) const
Definition: cacChannel.cpp:120
unsigned priLev
Definition: cacIO.h:165
virtual ~cacService()=0
Definition: cacChannel.cpp:141
const char * pHostName()
Definition: cacChannel.cpp:106
virtual const char * pHostName(epicsGuard< epicsMutex > &guard) const
Definition: cacChannel.cpp:132
#define EPICS_THREAD_ONCE_INIT
Definition: epicsThread.h:109
static const priLev priorityLinksDB
Definition: cacIO.h:169
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
virtual caAccessRights accessRights(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:56
virtual bool connected(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:87
virtual bool ca_v42_ok(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:81
virtual unsigned searchAttempts(epicsGuard< epicsMutex > &) const
Definition: cacChannel.cpp:63
static const priLev priorityArchive
Definition: cacIO.h:170
static const priLev priorityDefault
Definition: cacIO.h:168
virtual ~cacContext()
Definition: cacChannel.cpp:139