cleaned up resid to object conversion

This commit is contained in:
Jeff Hill
2003-01-07 17:12:07 +00:00
parent c9a2188752
commit ae7a9ebfa2
8 changed files with 62 additions and 105 deletions

View File

@@ -179,6 +179,44 @@ void caServerI::generateBeaconAnomaly ()
this->beaconAnomalyGov.start ();
}
//
// caServerI::lookupMonitor ()
//
casMonitor * caServerI::lookupMonitor ( const caResId &idIn )
{
chronIntId tmpId ( idIn );
epicsGuard < epicsMutex > locker ( this->mutex );
casRes * pRes = this->chronIntIdResTable<casRes>::lookup ( tmpId );
if ( pRes ) {
if ( pRes->resourceType() == casMonitorT ) {
// ok to avoid overhead of dynamic cast here because
// type code was checked above
return static_cast < casMonitor * > ( pRes );
}
}
return 0;
}
//
// caServerI::lookupChannel ()
//
casChannelI * caServerI::lookupChannel ( const caResId &idIn )
{
chronIntId tmpId ( idIn );
epicsGuard < epicsMutex > locker ( this->mutex );
casRes * pRes = this->chronIntIdResTable<casRes>::lookup ( tmpId );
if ( pRes ) {
if ( pRes->resourceType() == casChanT ) {
// ok to avoid overhead of dynamic cast here because
// type code was checked above
return static_cast < casChannelI * > ( pRes );
}
}
return 0;
}
//
// caServerI::show()
//

View File

@@ -46,39 +46,6 @@ inline caServer * caServerI::operator -> ()
return this->getAdapter();
}
//
// caServerI::lookupRes()
//
inline casRes *caServerI::lookupRes(const caResId &idIn, casResType type)
{
chronIntId tmpId (idIn);
epicsGuard < epicsMutex > locker ( this->mutex );
casRes *pRes = this->chronIntIdResTable<casRes>::lookup ( tmpId );
if ( pRes ) {
if ( pRes->resourceType() != type ) {
pRes = NULL;
}
}
return pRes;
}
//
// find the channel associated with a resource id
//
inline casChannelI *caServerI::resIdToChannel(const caResId &idIn)
{
casRes *pRes;
pRes = this->lookupRes(idIn, casChanT);
//
// safe to cast because we have checked the type code above
// (and we know that casChannelI derived from casRes)
//
return (casChannelI *) pRes;
}
//
// caServerI::installItem()
//

View File

@@ -54,20 +54,19 @@ casClient::casClient ( caServerI & serverInternal,
//
// find the channel associated with a resource id
//
casChannelI *casClient::resIdToChannel(const caResId &idIn)
casChannelI * casClient::lookupChannel ( const caResId & idIn )
{
casChannelI *pChan;
//
// look up the id in a hash table
//
pChan = this->ctx.getServer()->resIdToChannel(idIn);
casChannelI * pChan =
this->ctx.getServer()->lookupChannel ( idIn );
//
// update the context
//
this->ctx.setChannel(pChan);
if (!pChan) {
this->ctx.setChannel ( pChan );
if ( ! pChan ) {
return NULL;
}
@@ -75,14 +74,14 @@ casChannelI *casClient::resIdToChannel(const caResId &idIn)
// If the channel isnt attached to this client then
// something has gone wrong
//
if (&pChan->getClient()!=this) {
if ( &pChan->getClient() != this ) {
return NULL;
}
//
// update the context
//
this->ctx.setPV(&pChan->getPVI());
this->ctx.setPV ( &pChan->getPVI() );
return pChan;
}
@@ -468,7 +467,7 @@ caStatus casClient::sendErr ( const caHdrLargeArray *curp, const int reportedSta
/*
* Verify the channel
*/
casChannelI * pciu = this->resIdToChannel ( curp->m_cid );
casChannelI * pciu = this->lookupChannel ( curp->m_cid );
if ( pciu ) {
cid = pciu->getCID();
}
@@ -596,7 +595,7 @@ void casClient::dumpMsg ( const caHdrLargeArray *mp,
char pName[64u];
this->hostName (pName, sizeof (pName));
casChannelI * pciu = this->resIdToChannel(mp->m_cid);
casChannelI * pciu = this->lookupChannel ( mp->m_cid );
char pPVName[64u];
if (pciu) {

View File

@@ -182,14 +182,6 @@ ca_uint16_t casCoreClient::protocolRevision() const
return 0;
}
//
// casCoreClient::lookupRes()
//
casRes * casCoreClient::lookupRes (const caResId &idIn, casResType type)
{
return this->ctx.getServer()->lookupRes(idIn, type);
}
// this is a pure virtual function, but we nevertheless need a
// noop to be called if they post events when a channel is being
// destroyed when we are in the casStrmClient destructor
@@ -215,13 +207,13 @@ casMonitor & casCoreClient::monitorFactory (
type, mask,
this->mutex,
*this );
this->installMonitor ();
this->eventSys.installMonitor ();
return mon;
}
void casCoreClient::destroyMonitor ( casMonitor & mon )
{
this->removeMonitor ();
this->eventSys.removeMonitor ();
this->ctx.getServer()->casMonitorDestroy ( mon );
}

View File

@@ -121,14 +121,9 @@ inline bool casCoreClient::eventSysIsFull ()
return this->eventSys.full ();
}
inline void casCoreClient::installMonitor ()
inline casMonitor * casCoreClient::lookupMonitor ( const caResId & idIn )
{
this->eventSys.installMonitor ();
}
inline void casCoreClient::removeMonitor ()
{
this->eventSys.removeMonitor ();
return this->ctx.getServer()->lookupMonitor ( idIn );
}
#endif // casCoreClientIL_h

View File

@@ -34,10 +34,7 @@ caStatus casMonEvent::cbFunc ( casCoreClient & client )
// ignore this event if it is stale and there is
// no call back object associated with it
//
// safe to cast because we have checked the type code
//
casMonitor * pMon = static_cast < casMonitor * >
( client.lookupRes ( this->id, casMonitorT ) );
casMonitor * pMon = client.lookupMonitor ( this->id );
if ( ! pMon ) {
// we know this isnt an overflow event because those are
// removed from the queue when the casMonitor object is

View File

@@ -119,8 +119,8 @@ caStatus casStrmClient::verifyRequest (casChannelI *&pChan)
//
// channel exists for this resource id ?
//
pChan = this->resIdToChannel(mp->m_cid);
if (!pChan) {
pChan = this->lookupChannel ( mp->m_cid );
if ( ! pChan ) {
return ECA_BADCHID;
}
@@ -1324,7 +1324,7 @@ caStatus casStrmClient::clearChannelAction ()
/*
* Verify the channel
*/
pciu = this->resIdToChannel ( mp->m_cid );
pciu = this->lookupChannel ( mp->m_cid );
if ( pciu == NULL ) {
/*
* it is possible that the channel delete arrives just
@@ -1376,7 +1376,7 @@ caStatus casStrmClient::eventCancelAction ()
/*
* Verify the channel
*/
casChannelI *pciu = this->resIdToChannel ( mp->m_cid );
casChannelI * pciu = this->lookupChannel ( mp->m_cid );
if ( ! pciu ) {
/*
* it is possible that the event delete arrives just

View File

@@ -431,8 +431,6 @@ public:
void removeAsyncIO ( casAsyncIOI & ioIn );
casRes * lookupRes ( const caResId &idIn, casResType type );
caServerI & getCAS () const;
void lock ();
@@ -487,8 +485,6 @@ public:
void enableEvents ();
void disableEvents ();
bool eventSysIsFull ();
void installMonitor ();
void removeMonitor ();
void setDestroyPending ();
@@ -499,9 +495,9 @@ public:
const unsigned type,
const casEventMask & );
void destroyMonitor ( casMonitor & );
caStatus casMonitorCallBack ( casMonitor &,
const smartConstGDDPointer & );
casMonitor * lookupMonitor ( const caResId &idIn );
protected:
epicsMutex mutex;
@@ -532,10 +528,7 @@ public:
ca_uint16_t protocolRevision() const {return this->minor_version_number;}
//
// find the channel associated with a resource id
//
casChannelI * resIdToChannel (const caResId &id);
casChannelI * lookupChannel ( const caResId &id );
virtual void hostName ( char *pBuf, unsigned bufSize ) const = 0;
@@ -879,49 +872,28 @@ public:
caServerI ( caServer &tool );
~caServerI ();
//
// find the channel associated with a resource id
//
casChannelI *resIdToChannel (const caResId &id);
//
// find the PV associated with a resource id
//
casPVI *resIdToPV (const caResId &id);
void installClient (casStrmClient *pClient);
void removeClient (casStrmClient *pClient);
//
// is there space for a new channel
//
bool roomForNewChannel() const;
unsigned getDebugLevel() const { return debugLevel; }
inline void setDebugLevel (unsigned debugLevelIn);
inline void setDebugLevel ( unsigned debugLevelIn );
void show (unsigned level) const;
void show ( unsigned level ) const;
casRes *lookupRes (const caResId &idIn, casResType type);
casMonitor * lookupMonitor ( const caResId &idIn );
casChannelI * lookupChannel ( const caResId &idIn );
caServer *getAdapter ();
void installItem ( casRes & res );
casRes * removeItem ( casRes & res );
//
// call virtual function in the interface class
//
caServer * operator -> ();
void connectCB (casIntfOS &);
//
// common event masks
// (what is currently used by the CA clients)
//
casEventMask valueEventMask() const; // DBE_VALUE registerEvent("value")
casEventMask logEventMask() const; // DBE_LOG registerEvent("log")
casEventMask alarmEventMask() const; // DBE_ALARM registerEvent("alarm")
@@ -961,9 +933,6 @@ private:
unsigned nEventsProcessed;
unsigned nEventsPosted;
//
// predefined event types
//
casEventMask valueEvent; // DBE_VALUE registerEvent("value")
casEventMask logEvent; // DBE_LOG registerEvent("log")
casEventMask alarmEvent; // DBE_ALARM registerEvent("alarm")