Merged Michael's cxxcleanup branch
This commit is contained in:
@@ -69,7 +69,6 @@ LIBSRCS += comQueSend.cpp
|
||||
LIBSRCS += comBuf.cpp
|
||||
LIBSRCS += hostNameCache.cpp
|
||||
LIBSRCS += msgForMultiplyDefinedPV.cpp
|
||||
LIBSRCS_vxWorks += templateInstances.cpp
|
||||
|
||||
LIBRARY=ca
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* L O S A L A M O S
|
||||
* Los Alamos National Laboratory
|
||||
* Los Alamos, New Mexico 87545
|
||||
*
|
||||
* Copyright, The Regents of the University of California.
|
||||
*
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#ifndef autoPtrDestroyh
|
||||
#define autoPtrDestroyh
|
||||
|
||||
template < class T >
|
||||
class autoPtrDestroy {
|
||||
public:
|
||||
autoPtrDestroy ( T * );
|
||||
~autoPtrDestroy ();
|
||||
T & operator * () const;
|
||||
T * operator -> () const;
|
||||
autoPtrDestroy<T> & operator = ( T * );
|
||||
T * get () const;
|
||||
T * release ();
|
||||
private:
|
||||
T * p;
|
||||
// not implemented
|
||||
autoPtrDestroy<T> & operator = ( const autoPtrDestroy<T> & );
|
||||
autoPtrDestroy ( const autoPtrDestroy<T> & );
|
||||
};
|
||||
|
||||
template < class T >
|
||||
inline autoPtrDestroy<T>::autoPtrDestroy ( T *pIn ) :
|
||||
p ( pIn ) {}
|
||||
|
||||
template < class T >
|
||||
inline autoPtrDestroy<T>::~autoPtrDestroy ()
|
||||
{
|
||||
if ( this->p ) {
|
||||
this->p->destroy ();
|
||||
}
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline T & autoPtrDestroy<T>::operator * () const
|
||||
{
|
||||
return * this->p;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline T * autoPtrDestroy<T>::operator -> () const
|
||||
{
|
||||
return this->p;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline autoPtrDestroy<T> & autoPtrDestroy<T>::operator = ( T * pIn )
|
||||
{
|
||||
if ( this->p ) {
|
||||
this->p->destroy ();
|
||||
}
|
||||
this->p = pIn;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline T * autoPtrDestroy<T>::get () const
|
||||
{
|
||||
return this->p;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline T * autoPtrDestroy<T>::release ()
|
||||
{
|
||||
T *pTmp = this->p;
|
||||
this->p = 0;
|
||||
return pTmp;
|
||||
}
|
||||
|
||||
#endif // #ifdef autoPtrDestroyh
|
||||
@@ -159,13 +159,13 @@ ca_client_context::ca_client_context ( bool enablePreemptiveCallback ) :
|
||||
this->localPort = htons ( tmpAddr.ia.sin_port );
|
||||
}
|
||||
|
||||
epics_auto_ptr < CallbackGuard > pCBGuard;
|
||||
std::auto_ptr < CallbackGuard > pCBGuard;
|
||||
if ( ! enablePreemptiveCallback ) {
|
||||
pCBGuard.reset ( new CallbackGuard ( this->cbMutex ) );
|
||||
}
|
||||
|
||||
// multiple steps ensure exception safety
|
||||
this->pCallbackGuard = pCBGuard;
|
||||
std::swap(this->pCallbackGuard, pCBGuard);
|
||||
}
|
||||
|
||||
ca_client_context::~ca_client_context ()
|
||||
|
||||
@@ -58,6 +58,7 @@ protected:
|
||||
channelNode ();
|
||||
bool isInstalledInServer ( epicsGuard < epicsMutex > & ) const;
|
||||
bool isConnected ( epicsGuard < epicsMutex > & ) const;
|
||||
public:
|
||||
static unsigned getMaxSearchTimerCount ();
|
||||
private:
|
||||
enum channelState {
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
#ifndef oldAccessh
|
||||
#define oldAccessh
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define oldAccessh_restore_epicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
#endif
|
||||
|
||||
#include "tsFreeList.h"
|
||||
#include "epicsMemory.h"
|
||||
#include "compilerDependencies.h"
|
||||
#include "osiSock.h"
|
||||
|
||||
@@ -402,8 +403,8 @@ private:
|
||||
epicsEvent ioDone;
|
||||
epicsEvent callbackThreadActivityComplete;
|
||||
epicsThreadId createdByThread;
|
||||
epics_auto_ptr < CallbackGuard > pCallbackGuard;
|
||||
epics_auto_ptr < cacContext > pServiceContext;
|
||||
std::auto_ptr < CallbackGuard > pCallbackGuard;
|
||||
std::auto_ptr < cacContext > pServiceContext;
|
||||
caExceptionHandler * ca_exception_func;
|
||||
void * ca_exception_arg;
|
||||
caPrintfFunc * pVPrintfFunc;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
|
||||
|
||||
#include "tsMinMax.h"
|
||||
#include "envDefs.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* L O S A L A M O S
|
||||
* Los Alamos National Laboratory
|
||||
* Los Alamos, New Mexico 87545
|
||||
*
|
||||
* Copyright, 1986, The Regents of the University of California.
|
||||
*
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "virtualCircuit.h"
|
||||
#include "bhe.h"
|
||||
#include "cac.h"
|
||||
#include "syncGroup.h"
|
||||
#include "nciu.h"
|
||||
#include "udpiiu.h"
|
||||
#include "oldAccess.h"
|
||||
#include "msgForMultiplyDefinedPV.h"
|
||||
#include "repeaterClient.h"
|
||||
#include "hostNameCache.h"
|
||||
#include "comBuf.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( push )
|
||||
# pragma warning ( disable:4660 )
|
||||
#endif
|
||||
|
||||
template class resTable < nciu, chronIntId >;
|
||||
template class chronIntIdResTable < nciu >;
|
||||
template class resTable < baseNMIU, chronIntId >;
|
||||
template class chronIntIdResTable < baseNMIU >;
|
||||
template class resTable < CASG, chronIntId >;
|
||||
template class chronIntIdResTable < CASG >;
|
||||
template class resTable < bhe, inetAddrID >;
|
||||
template class resTable < tcpiiu, caServerID >;
|
||||
template class tsFreeList < bhe, 0x100 >;
|
||||
template class tsFreeList < tcpiiu, 32, epicsMutexNOOP >;
|
||||
template class tsFreeList < netReadNotifyIO, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < netWriteNotifyIO, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < netSubscription, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < CASG, 128, epicsMutexNOOP >;
|
||||
template class tsFreeList < syncGroupReadNotify, 128, epicsMutexNOOP >;
|
||||
template class tsFreeList < syncGroupWriteNotify, 128, epicsMutexNOOP >;
|
||||
template class tsFreeList < comBuf, 0x20 >;
|
||||
template class tsFreeList < getCallback, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < getCopy, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < msgForMultiplyDefinedPV, 16 >;
|
||||
template class tsFreeList < nciu, 1024, epicsMutexNOOP>;
|
||||
template class tsFreeList < oldChannelNotify, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < oldSubscription, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < putCallback, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < repeaterClient, 0x20 >;
|
||||
template class epicsSingleton < localHostName >;
|
||||
template class epics_auto_ptr < epics_auto_ptr < class searchTimer >, eapt_array >;
|
||||
template unsigned comBuf :: push ( const double * pValue, unsigned nElem );
|
||||
template unsigned comBuf :: push ( const float * pValue, unsigned nElem );
|
||||
template unsigned comBuf :: push ( const int * pValue, unsigned nElem );
|
||||
template unsigned comBuf :: push ( const short * pValue, unsigned nElem );
|
||||
template comBuf :: popStatus comBuf :: pop ( unsigned int & returnVal );
|
||||
template comBuf :: popStatus comBuf :: pop ( unsigned short & returnVal );
|
||||
template comBuf :: popStatus comBuf :: pop ( unsigned char & returnVal );
|
||||
template void WireSet ( float const &, unsigned char * );
|
||||
template void WireSet ( int const &, unsigned char * );
|
||||
template void WireSet ( short const &, unsigned char * );
|
||||
template void ca_client_context :: whenThereIsAnExceptionDestroySyncGroupIO
|
||||
(epicsGuard < epicsMutex > &, syncGroupWriteNotify & );
|
||||
template void ca_client_context :: whenThereIsAnExceptionDestroySyncGroupIO
|
||||
( epicsGuard < epicsMutex > &, syncGroupReadNotify & );
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( pop )
|
||||
#endif
|
||||
@@ -64,6 +64,52 @@ const udpiiu::pProtoStubUDP udpiiu::udpJumpTableCAC [] =
|
||||
&udpiiu::repeaterAckAction,
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
double getMaxPeriod()
|
||||
{
|
||||
double maxPeriod = maxSearchPeriodDefault;
|
||||
|
||||
if ( envGetConfigParamPtr ( & EPICS_CA_MAX_SEARCH_PERIOD ) ) {
|
||||
long longStatus = envGetDoubleConfigParam (
|
||||
& EPICS_CA_MAX_SEARCH_PERIOD, & maxPeriod );
|
||||
if ( ! longStatus ) {
|
||||
if ( maxPeriod < maxSearchPeriodLowerLimit ) {
|
||||
epicsPrintf ( "\"%s\" out of range (low)\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
maxPeriod = maxSearchPeriodLowerLimit;
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name, maxPeriod );
|
||||
}
|
||||
}
|
||||
else {
|
||||
epicsPrintf ( "EPICS \"%s\" wasnt a real number\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name, maxPeriod );
|
||||
}
|
||||
}
|
||||
|
||||
return maxPeriod;
|
||||
}
|
||||
|
||||
static
|
||||
unsigned getNTimers(double maxPeriod)
|
||||
{
|
||||
unsigned nTimers = static_cast < unsigned > ( 1.0 + log ( maxPeriod / minRoundTripEstimate ) / log ( 2.0 ) );
|
||||
|
||||
if ( nTimers > channelNode::getMaxSearchTimerCount () ) {
|
||||
nTimers = channelNode::getMaxSearchTimerCount ();
|
||||
epicsPrintf ( "\"%s\" out of range (high)\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name,
|
||||
(1<<(nTimers-1)) * minRoundTripEstimate );
|
||||
}
|
||||
|
||||
return nTimers;
|
||||
}
|
||||
|
||||
//
|
||||
// udpiiu::udpiiu ()
|
||||
//
|
||||
@@ -85,14 +131,15 @@ udpiiu::udpiiu (
|
||||
repeaterSubscribeTmr (
|
||||
m_repeaterTimerNotify, timerQueue, cbMutexIn, ctxNotifyIn ),
|
||||
govTmr ( *this, timerQueue, cacMutexIn ),
|
||||
maxPeriod ( maxSearchPeriodDefault ),
|
||||
maxPeriod ( getMaxPeriod() ),
|
||||
rtteMean ( minRoundTripEstimate ),
|
||||
rtteMeanDev ( 0 ),
|
||||
cacRef ( cac ),
|
||||
cbMutex ( cbMutexIn ),
|
||||
cacMutex ( cacMutexIn ),
|
||||
nTimers ( getNTimers(maxPeriod) ),
|
||||
ppSearchTmr ( nTimers ),
|
||||
nBytesInXmitBuf ( 0 ),
|
||||
nTimers ( 0 ),
|
||||
beaconAnomalyTimerIndex ( 0 ),
|
||||
sequenceNumber ( 0 ),
|
||||
lastReceivedSeqNo ( 0 ),
|
||||
@@ -104,45 +151,13 @@ udpiiu::udpiiu (
|
||||
lastReceivedSeqNoIsValid ( false )
|
||||
{
|
||||
cacGuard.assertIdenticalMutex ( cacMutex );
|
||||
|
||||
if ( envGetConfigParamPtr ( & EPICS_CA_MAX_SEARCH_PERIOD ) ) {
|
||||
long longStatus = envGetDoubleConfigParam (
|
||||
& EPICS_CA_MAX_SEARCH_PERIOD, & this->maxPeriod );
|
||||
if ( ! longStatus ) {
|
||||
if ( this->maxPeriod < maxSearchPeriodLowerLimit ) {
|
||||
epicsPrintf ( "\"%s\" out of range (low)\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
this->maxPeriod = maxSearchPeriodLowerLimit;
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name, this->maxPeriod );
|
||||
}
|
||||
}
|
||||
else {
|
||||
epicsPrintf ( "EPICS \"%s\" wasnt a real number\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name, this->maxPeriod );
|
||||
}
|
||||
}
|
||||
|
||||
double powerOfTwo = log ( this->maxPeriod / minRoundTripEstimate ) / log ( 2.0 );
|
||||
this->nTimers = static_cast < unsigned > ( powerOfTwo + 1.0 );
|
||||
if ( this->nTimers > channelNode::getMaxSearchTimerCount () ) {
|
||||
this->nTimers = channelNode::getMaxSearchTimerCount ();
|
||||
epicsPrintf ( "\"%s\" out of range (high)\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name );
|
||||
epicsPrintf ( "Setting \"%s\" = %f seconds\n",
|
||||
EPICS_CA_MAX_SEARCH_PERIOD.name,
|
||||
(1<<(this->nTimers-1)) * minRoundTripEstimate );
|
||||
}
|
||||
|
||||
powerOfTwo = log ( beaconAnomalySearchPeriod / minRoundTripEstimate ) / log ( 2.0 );
|
||||
double powerOfTwo = log ( beaconAnomalySearchPeriod / minRoundTripEstimate ) / log ( 2.0 );
|
||||
this->beaconAnomalyTimerIndex = static_cast < unsigned > ( powerOfTwo + 1.0 );
|
||||
if ( this->beaconAnomalyTimerIndex >= this->nTimers ) {
|
||||
this->beaconAnomalyTimerIndex = this->nTimers - 1;
|
||||
}
|
||||
|
||||
this->ppSearchTmr.reset ( new epics_auto_ptr < class searchTimer > [ this->nTimers ] );
|
||||
for ( unsigned i = 0; i < this->nTimers; i++ ) {
|
||||
this->ppSearchTmr[i].reset (
|
||||
new searchTimer ( *this, timerQueue, i, cacMutexIn,
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef udpiiuh
|
||||
#define udpiiuh
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifdef epicsExportSharedSymbols
|
||||
# define udpiiuh_accessh_epicsExportSharedSymbols
|
||||
# undef epicsExportSharedSymbols
|
||||
@@ -32,9 +34,7 @@
|
||||
|
||||
#include "osiSock.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsMemory.h"
|
||||
#include "epicsTime.h"
|
||||
#include "tsMinMax.h"
|
||||
#include "tsDLList.h"
|
||||
|
||||
#ifdef udpiiuh_accessh_epicsExportSharedSymbols
|
||||
@@ -160,15 +160,24 @@ private:
|
||||
repeaterSubscribeTimer repeaterSubscribeTmr;
|
||||
disconnectGovernorTimer govTmr;
|
||||
tsDLList < SearchDest > _searchDestList;
|
||||
double maxPeriod;
|
||||
const double maxPeriod;
|
||||
double rtteMean;
|
||||
double rtteMeanDev;
|
||||
cac & cacRef;
|
||||
epicsMutex & cbMutex;
|
||||
epicsMutex & cacMutex;
|
||||
epics_auto_ptr < epics_auto_ptr < class searchTimer >, eapt_array > ppSearchTmr;
|
||||
const unsigned nTimers;
|
||||
struct SearchArray {
|
||||
typedef std::auto_ptr <searchTimer> value_type;
|
||||
value_type *arr;
|
||||
SearchArray(size_t n) : arr(new value_type[n]) {}
|
||||
~SearchArray() { delete[] arr; }
|
||||
value_type& operator[](size_t i) const { return arr[i]; }
|
||||
private:
|
||||
SearchArray(const SearchArray&);
|
||||
SearchArray& operator=(const SearchArray&);
|
||||
} ppSearchTmr;
|
||||
unsigned nBytesInXmitBuf;
|
||||
unsigned nTimers;
|
||||
unsigned beaconAnomalyTimerIndex;
|
||||
ca_uint32_t sequenceNumber;
|
||||
ca_uint32_t lastReceivedSeqNo;
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
#ifndef virtualCircuith
|
||||
#define virtualCircuith
|
||||
|
||||
#include "epicsMemory.h"
|
||||
#include "tsDLList.h"
|
||||
#include "tsMinMax.h"
|
||||
|
||||
#include "comBuf.h"
|
||||
#include "caServerID.h"
|
||||
|
||||
@@ -80,8 +80,6 @@ ifeq ($(VX_GNU_VERSION), 4.1.2)
|
||||
casStreamOS_CXXFLAGS_vxWorks-ppc604 = -O0
|
||||
endif
|
||||
|
||||
LIBSRCS_vxWorks += templateInstances.cpp
|
||||
|
||||
LIBRARY = cas
|
||||
cas_LIBS = ca gdd Com
|
||||
cas_SYS_LIBS_WIN32 = ws2_32
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
//
|
||||
|
||||
#include "directoryServer.h"
|
||||
#include "tsMinMax.h"
|
||||
#include "epicsAlgorithm.h"
|
||||
|
||||
const pvInfo *pvInfo::pFirst;
|
||||
|
||||
@@ -128,7 +128,7 @@ pvExistReturn directoryServer::pvExistTest
|
||||
}
|
||||
else {
|
||||
size_t diff = pLastStr-pPVName;
|
||||
diff = tsMin (diff, sizeof(pvNameBuf)-1);
|
||||
diff = epicsMin (diff, sizeof(pvNameBuf)-1);
|
||||
memcpy (pvNameBuf, pPVName, diff);
|
||||
pvNameBuf[diff] = '\0';
|
||||
pLastStr = pvNameBuf;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "ipIgnoreEntry.h"
|
||||
#include "casChannelI.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( push )
|
||||
# pragma warning ( disable:4660 )
|
||||
#endif
|
||||
|
||||
template class resTable < ipIgnoreEntry, ipIgnoreEntry >;
|
||||
template class resTable < casChannelI, chronIntId >;
|
||||
template class resTable < casEventMaskEntry, stringId >;
|
||||
template class chronIntIdResTable < casChannelI >;
|
||||
template class tsFreeList < casMonEvent, 1024, epicsMutexNOOP >;
|
||||
template class tsFreeList < casMonitor, 1024, epicsMutex >;
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( pop )
|
||||
#endif
|
||||
@@ -85,7 +85,6 @@ dbCore_SRCS += dbChannelIO.cpp
|
||||
dbCore_SRCS += dbSubscriptionIO.cpp
|
||||
dbCore_SRCS += dbPutNotifyBlocker.cpp
|
||||
dbCore_SRCS += dbContextReadNotifyCache.cpp
|
||||
dbCore_SRCS += templateInstances.cpp
|
||||
dbCore_SRCS += dbIocRegister.c
|
||||
dbCore_SRCS += chfPlugin.c
|
||||
dbCore_SRCS += dbState.c
|
||||
|
||||
@@ -36,12 +36,13 @@
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#include <memory> // std::auto_ptr
|
||||
|
||||
#include "tsDLList.h"
|
||||
#include "tsFreeList.h"
|
||||
#include "resourceLib.h"
|
||||
#include "cacIO.h"
|
||||
#include "compilerDependencies.h"
|
||||
#include "epicsMemory.h"
|
||||
|
||||
#ifdef dbCACh_restore_epicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
@@ -203,7 +204,7 @@ private:
|
||||
epicsMutex & mutex;
|
||||
epicsMutex & cbMutex;
|
||||
cacContextNotify & notify;
|
||||
epics_auto_ptr < cacContext > pNetContext;
|
||||
std::auto_ptr < cacContext > pNetContext;
|
||||
char * pStateNotifyCache;
|
||||
bool isolated;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#endif
|
||||
|
||||
#include "compilerDependencies.h"
|
||||
#include "epicsMemory.h"
|
||||
|
||||
#ifdef dbChannelIOh_restore_epicsExportSharedSymbols
|
||||
# define epicsExportSharedSymbols
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* $Revision-Id$
|
||||
*
|
||||
*
|
||||
* L O S A L A M O S
|
||||
* Los Alamos National Laboratory
|
||||
* Los Alamos, New Mexico 87545
|
||||
*
|
||||
* Copyright, 1986, The Regents of the University of California.
|
||||
*
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
|
||||
#include "dbCAC.h"
|
||||
#include "dbChannelIO.h"
|
||||
#include "dbPutNotifyBlocker.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( push )
|
||||
# pragma warning ( disable:4660 )
|
||||
#endif
|
||||
|
||||
template class tsFreeList < dbChannelIO, 256, epicsMutexNOOP >;
|
||||
template class tsFreeList < dbPutNotifyBlocker, 64, epicsMutexNOOP >;
|
||||
template class tsFreeList < dbSubscriptionIO, 256, epicsMutexNOOP >;
|
||||
template class resTable < dbBaseIO, chronIntId >;
|
||||
template class chronIntIdResTable < dbBaseIO >;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( pop )
|
||||
#endif
|
||||
@@ -10,5 +10,4 @@
|
||||
SRC_DIRS += $(LIBCOM)/cppStd
|
||||
INC += epicsAlgorithm.h
|
||||
INC += epicsExcept.h
|
||||
INC += epicsMemory.h
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
// epicsMemoryH.h
|
||||
// Author: Jeff Hill
|
||||
// Date: March 2001
|
||||
|
||||
#ifndef epicsMemoryH
|
||||
#define epicsMemoryH
|
||||
|
||||
enum epics_auto_ptr_type {
|
||||
eapt_scalar, eapt_array };
|
||||
|
||||
template < class T, epics_auto_ptr_type PT = eapt_scalar >
|
||||
class epics_auto_ptr {
|
||||
public:
|
||||
typedef T element_type;
|
||||
explicit epics_auto_ptr ( T * p = 0 ) throw ();
|
||||
epics_auto_ptr ( epics_auto_ptr<T,PT> & rhs ) throw ();
|
||||
~epics_auto_ptr() throw ();
|
||||
epics_auto_ptr<T,PT> & operator = ( epics_auto_ptr<T,PT> & rhs ) throw ();
|
||||
T & operator * () const throw ();
|
||||
T * operator -> () const throw ();
|
||||
T & operator [] ( unsigned index ) const throw ();
|
||||
T * get () const throw ();
|
||||
T * release () throw ();
|
||||
void reset ( T * p = 0 ) throw ();
|
||||
private:
|
||||
T * p;
|
||||
void destroyTarget () throw ();
|
||||
};
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline epics_auto_ptr<T,PT>::epics_auto_ptr ( T *pIn ) throw () :
|
||||
p ( pIn ) {}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline epics_auto_ptr<T,PT>::
|
||||
epics_auto_ptr ( epics_auto_ptr<T,PT> & ap ) throw () :
|
||||
p ( ap.release() ) {}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline void epics_auto_ptr<T,PT>::destroyTarget () throw ()
|
||||
{
|
||||
if ( PT == eapt_scalar ) {
|
||||
delete this->p;
|
||||
}
|
||||
else {
|
||||
delete [] this->p;
|
||||
}
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline epics_auto_ptr<T,PT>::~epics_auto_ptr () throw ()
|
||||
{
|
||||
this->destroyTarget ();
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline epics_auto_ptr<T,PT> & epics_auto_ptr<T,PT>::operator =
|
||||
( epics_auto_ptr<T,PT> & rhs ) throw ()
|
||||
{
|
||||
if ( &rhs != this) {
|
||||
this->destroyTarget ();
|
||||
this->p = rhs.release ();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline T & epics_auto_ptr<T,PT>::operator * () const throw()
|
||||
{
|
||||
return * this->p;
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline T * epics_auto_ptr<T,PT>::operator -> () const throw ()
|
||||
{
|
||||
return this->p;
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
T & epics_auto_ptr<T,PT>::operator [] ( unsigned index ) const throw ()
|
||||
{
|
||||
return this->p [ index ];
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline T * epics_auto_ptr<T,PT>::get () const throw ()
|
||||
{
|
||||
return this->p;
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline T * epics_auto_ptr<T,PT>::release () throw ()
|
||||
{
|
||||
T *pTmp = this->p;
|
||||
this->p = 0;
|
||||
return pTmp;
|
||||
}
|
||||
|
||||
template < class T, epics_auto_ptr_type PT >
|
||||
inline void epics_auto_ptr<T,PT>::reset ( T * pIn ) throw ()
|
||||
{
|
||||
this->destroyTarget ();
|
||||
this->p = pIn;
|
||||
}
|
||||
|
||||
#endif // ifndef epicsMemoryH
|
||||
@@ -12,12 +12,9 @@ INC += resourceLib.h
|
||||
INC += tsDLList.h
|
||||
INC += tsSLList.h
|
||||
INC += tsMinMax.h
|
||||
INC += tsBTree.h
|
||||
INC += tsFreeList.h
|
||||
INC += epicsSingleton.h
|
||||
INC += epicsGuard.h
|
||||
INC += epicsOnce.h
|
||||
Com_SRCS += resourceLib.cpp
|
||||
Com_SRCS += epicsOnce.cpp
|
||||
Com_SRCS += epicsSingletonMutex.cpp
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ template < class T > class epicsGuardRelease;
|
||||
template < class T >
|
||||
class epicsGuard {
|
||||
public:
|
||||
typedef epicsGuardRelease<T> release_t;
|
||||
epicsGuard ( T & );
|
||||
void assertIdenticalMutex ( const T & ) const;
|
||||
~epicsGuard ();
|
||||
@@ -46,6 +47,7 @@ private:
|
||||
template < class T >
|
||||
class epicsGuardRelease {
|
||||
public:
|
||||
typedef epicsGuard<T> guard_t;
|
||||
epicsGuardRelease ( epicsGuard < T > & );
|
||||
~epicsGuardRelease ();
|
||||
private:
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
/*
|
||||
* $Revision-Id$
|
||||
*
|
||||
*
|
||||
* L O S A L A M O S
|
||||
* Los Alamos National Laboratory
|
||||
* Los Alamos, New Mexico 87545
|
||||
*
|
||||
* Copyright, 1986, The Regents of the University of California.
|
||||
*
|
||||
*
|
||||
* Author Jeff Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsSingleton.h"
|
||||
#include "epicsGuard.h"
|
||||
#include "epicsOnce.h"
|
||||
#include "tsFreeList.h"
|
||||
|
||||
class epicsOnceImpl : public epicsOnce {
|
||||
public:
|
||||
epicsOnceImpl ( epicsOnceNotify & notifyIn );
|
||||
void * operator new ( size_t size );
|
||||
void operator delete ( void * pCadaver, size_t size );
|
||||
private:
|
||||
epicsSingleton < epicsMutex > :: reference mutexRef;
|
||||
epicsOnceNotify & notify;
|
||||
bool onceFlag;
|
||||
void destroy ();
|
||||
void once ();
|
||||
epicsOnceImpl ( epicsOnceImpl & ); // disabled
|
||||
epicsOnceImpl & operator = ( epicsOnceImpl & ); // disabled
|
||||
static epicsSingleton < epicsMutex > mutex;
|
||||
static epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > freeList;
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( push )
|
||||
# pragma warning ( disable:4660 )
|
||||
#endif
|
||||
|
||||
template class epicsSingleton < epicsMutex >;
|
||||
template class tsFreeList < class epicsOnceImpl, 16 >;
|
||||
template class epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > >;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning ( pop )
|
||||
#endif
|
||||
|
||||
epicsSingleton < epicsMutex > epicsOnceImpl::mutex;
|
||||
epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > epicsOnceImpl::freeList;
|
||||
|
||||
inline void * epicsOnceImpl::operator new ( size_t size )
|
||||
{
|
||||
epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > :: reference ref =
|
||||
epicsOnceImpl::freeList.getReference ();
|
||||
return ref->allocate ( size );
|
||||
}
|
||||
|
||||
inline void epicsOnceImpl::operator delete ( void *pCadaver, size_t size )
|
||||
{
|
||||
epicsSingleton < tsFreeList < class epicsOnceImpl, 16 > > :: reference ref =
|
||||
epicsOnceImpl::freeList.getReference ();
|
||||
ref->release ( pCadaver, size );
|
||||
}
|
||||
|
||||
inline epicsOnceImpl::epicsOnceImpl ( epicsOnceNotify & notifyIn ) :
|
||||
mutexRef ( epicsOnceImpl::mutex.getReference() ), notify ( notifyIn ), onceFlag ( false )
|
||||
{
|
||||
}
|
||||
|
||||
void epicsOnceImpl::once ()
|
||||
{
|
||||
epicsGuard < epicsMutex > guard ( *this->mutexRef );
|
||||
if ( ! this->onceFlag ) {
|
||||
this->notify.initialize ();
|
||||
this->onceFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
void epicsOnceImpl::destroy ()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
epicsOnce & epicsOnce::create ( epicsOnceNotify & notifyIn )
|
||||
{
|
||||
// free list throws exception in no memory situation
|
||||
return * new epicsOnceImpl ( notifyIn );
|
||||
}
|
||||
|
||||
epicsOnce::~epicsOnce ()
|
||||
{
|
||||
}
|
||||
|
||||
epicsOnceNotify::~epicsOnceNotify ()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/*
|
||||
* $Revision-Id$
|
||||
*
|
||||
*
|
||||
* L O S A L A M O S
|
||||
* Los Alamos National Laboratory
|
||||
* Los Alamos, New Mexico 87545
|
||||
*
|
||||
* Copyright, 1986, The Regents of the University of California.
|
||||
*
|
||||
*
|
||||
* Author Jeff Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*/
|
||||
|
||||
#ifndef epicsOnceh
|
||||
#define epicsOnceh
|
||||
|
||||
#include "shareLib.h"
|
||||
|
||||
class epicsOnceNotify {
|
||||
public:
|
||||
epicsShareFunc virtual ~epicsOnceNotify ();
|
||||
virtual void initialize () = 0;
|
||||
};
|
||||
|
||||
class epicsOnce {
|
||||
public:
|
||||
epicsShareFunc static epicsOnce & create ( epicsOnceNotify & notifyIn );
|
||||
virtual ~epicsOnce (); // use destroy
|
||||
virtual void once () = 0; // run notifyIn.initialize() once only
|
||||
virtual void destroy () = 0; // destroy this object
|
||||
};
|
||||
|
||||
#endif // epicsOnceh
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
# National Laboratory.
|
||||
# Copyright (c) 2002 The Regents of the University of California, as
|
||||
# Operator of Los Alamos National Laboratory.
|
||||
# EPICS BASE Versions 3.13.7
|
||||
# and higher are distributed subject to a Software License Agreement found
|
||||
# EPICS BASE is distributed subject to a Software License Agreement found
|
||||
# in file LICENSE that is included with this distribution.
|
||||
#*************************************************************************
|
||||
|
||||
@@ -13,36 +12,22 @@ TOP=../../../..
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
resourceLibTest_SRCS += resourceLibTest.cc
|
||||
PROD_HOST += resourceLibTest
|
||||
OBJS_IOC += resourceLibTest
|
||||
TESTPROD_HOST += resourceLibTest
|
||||
|
||||
tsDLListBench_SRCS += tsDLListBench.cc
|
||||
PROD_HOST += tsDLListBench
|
||||
OBJS_IOC += tsDLListBench
|
||||
TESTPROD_HOST += tsDLListBench
|
||||
|
||||
tsDLListTest_SRCS += tsDLListTest.cc
|
||||
PROD_HOST += tsDLListTest
|
||||
OBJS_IOC += tsDLListTest
|
||||
TESTPROD_HOST += tsDLListTest
|
||||
|
||||
tsSLListBench_SRCS += tsSLListBench.cc
|
||||
PROD_HOST += tsSLListBench
|
||||
OBJS_IOC += tsSLListBench
|
||||
TESTPROD_HOST += tsSLListBench
|
||||
|
||||
tsSLListTest_SRCS += tsSLListTest.cc
|
||||
PROD_HOST += tsSLListTest
|
||||
OBJS_IOC += tsSLListTest
|
||||
TESTPROD_HOST += tsSLListTest
|
||||
|
||||
minmaxTest_SRCS += minmaxTest.cc
|
||||
PROD_HOST += minmaxTest
|
||||
OBJS_IOC += minmaxTest
|
||||
|
||||
tsBTreeTest_SRCS += tsBTreeTest.cc
|
||||
PROD_HOST += tsBTreeTest
|
||||
OBJS_IOC += tsBTreeTest
|
||||
|
||||
tsBTreeBench_SRCS += tsBTreeBench.cc
|
||||
PROD_HOST += tsBTreeBench
|
||||
OBJS_IOC += tsBTreeBench
|
||||
TESTPROD_HOST += minmaxTest
|
||||
|
||||
PROD_LIBS = Com
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "tsBTree.h"
|
||||
#include "tsSLList.h"
|
||||
|
||||
class A : public tsBTreeNode<A>, public tsSLNode<A> {
|
||||
public:
|
||||
A()
|
||||
{
|
||||
key = (unsigned) rand();
|
||||
}
|
||||
|
||||
btCmp tsBTreeCompare(const A &item) const
|
||||
{
|
||||
if (this->key<=item.key) {
|
||||
return btLessOrEqual;
|
||||
}
|
||||
else {
|
||||
return btGreater;
|
||||
}
|
||||
}
|
||||
|
||||
void show()
|
||||
{
|
||||
printf("A: %u\n", key);
|
||||
}
|
||||
private:
|
||||
unsigned key;
|
||||
};
|
||||
|
||||
#define LOOPCOUNT 10000u
|
||||
|
||||
int main ()
|
||||
{
|
||||
unsigned i;
|
||||
tsBTree<A> tree;
|
||||
tsSLList<A> list;
|
||||
A *pA;
|
||||
A a;
|
||||
clock_t clk;
|
||||
clock_t diff;
|
||||
double delay;
|
||||
|
||||
tree.insert (a);
|
||||
list.add (a);
|
||||
|
||||
for (i=0u; i<LOOPCOUNT; i++) {
|
||||
pA = new A;
|
||||
assert (pA);
|
||||
tree.insert (*pA);
|
||||
list.add (*pA);
|
||||
}
|
||||
|
||||
clk = clock ();
|
||||
for (i=0u; i<LOOPCOUNT; i++) {
|
||||
bool success = tree.verify(a);
|
||||
assert ( success );
|
||||
}
|
||||
diff = clock () - clk;
|
||||
delay = diff;
|
||||
delay = delay/CLOCKS_PER_SEC;
|
||||
delay = delay/LOOPCOUNT;
|
||||
printf ("delay = %15.10f\n", delay);
|
||||
|
||||
clk = clock ();
|
||||
while ( ( pA = list.get () ) ) {
|
||||
bool success = tree.remove(*pA);
|
||||
assert ( success );
|
||||
}
|
||||
diff = clock () - clk;
|
||||
delay = diff;
|
||||
delay = delay/CLOCKS_PER_SEC;
|
||||
delay = delay/LOOPCOUNT;
|
||||
printf ("delay = %15.10f\n", delay);
|
||||
|
||||
tree.traverse (&A::show);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "tsBTree.h"
|
||||
|
||||
#define verify(exp) ((exp) ? (void)0 : \
|
||||
epicsAssert(__FILE__, __LINE__, #exp, epicsAssertAuthor))
|
||||
|
||||
class A : public tsBTreeNode<A> {
|
||||
public:
|
||||
A(const char *pNameIn) : pName(pNameIn) {}
|
||||
|
||||
btCmp tsBTreeCompare(const A &item) const
|
||||
{
|
||||
int cmp = strcmp(this->pName, item.pName);
|
||||
if (cmp<=0) {
|
||||
return btLessOrEqual;
|
||||
}
|
||||
else {
|
||||
return btGreater;
|
||||
}
|
||||
}
|
||||
|
||||
void show()
|
||||
{
|
||||
printf("A: %s\n", pName);
|
||||
}
|
||||
private:
|
||||
const char *pName;
|
||||
};
|
||||
|
||||
int main ()
|
||||
{
|
||||
tsBTree<A> tree;
|
||||
A a0 ("fred");
|
||||
A a1 ("jane");
|
||||
A a2 ("jane0");
|
||||
A a3 ("bill");
|
||||
A a4 ("jane");
|
||||
A a5 ("dan");
|
||||
A a6 ("joe");
|
||||
|
||||
tree.insert (a0);
|
||||
tree.insert (a1);
|
||||
tree.insert (a2);
|
||||
tree.insert (a3);
|
||||
tree.insert (a4);
|
||||
tree.insert (a5);
|
||||
|
||||
tree.traverse (&A::show);
|
||||
|
||||
verify (tree.remove(a6)==tsbtrrNotFound);
|
||||
tree.insert (a6);
|
||||
verify (tree.remove(a6)==tsbtrrFound);
|
||||
verify (tree.remove(a5)==tsbtrrFound);
|
||||
verify (tree.remove(a5)==tsbtrrNotFound);
|
||||
verify (!tree.verify(a5));
|
||||
verify (tree.verify(a4));
|
||||
verify (tree.remove(a0)==tsbtrrFound);
|
||||
verify (!tree.verify(a0));
|
||||
verify (tree.remove(a0)==tsbtrrNotFound);
|
||||
tree.insert (a5);
|
||||
verify (tree.verify(a5));
|
||||
verify (tree.verify(a2));
|
||||
verify (tree.remove(a2)==tsbtrrFound);
|
||||
verify (!tree.verify(a2));
|
||||
verify (tree.remove(a2)==tsbtrrNotFound);
|
||||
verify (tree.verify(a5));
|
||||
verify (tree.remove(a5)==tsbtrrFound);
|
||||
verify (tree.remove(a5)==tsbtrrNotFound);
|
||||
verify (tree.remove(a0)==tsbtrrNotFound);
|
||||
verify (tree.remove(a4)==tsbtrrFound);
|
||||
verify (tree.remove(a3)==tsbtrrFound);
|
||||
verify (tree.remove(a4)==tsbtrrNotFound);
|
||||
verify (tree.remove(a1)==tsbtrrFound);
|
||||
|
||||
tree.traverse (&A::show);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#ifndef assert // allow use of epicsAssert.h
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include "locationException.h"
|
||||
|
||||
//
|
||||
// tsBTreeRMRet
|
||||
//
|
||||
enum tsbtRR {tsbtrrNotFound, tsbtrrFound};
|
||||
template <class T>
|
||||
class tsBTreeRMRet {
|
||||
public:
|
||||
tsBTreeRMRet (tsbtRR foundItIn, T *pNewSegIn) :
|
||||
foundIt(foundItIn), pNewSeg(pNewSegIn) {}
|
||||
|
||||
operator tsbtRR ()
|
||||
{
|
||||
return this->foundIt;
|
||||
}
|
||||
|
||||
const tsbtRR foundIt;
|
||||
T * const pNewSeg;
|
||||
};
|
||||
|
||||
template <class T> class tsBTree;
|
||||
|
||||
//
|
||||
// tsBTreeNode
|
||||
//
|
||||
template <class T>
|
||||
class tsBTreeNode
|
||||
{
|
||||
friend class tsBTree<T>;
|
||||
public:
|
||||
//
|
||||
// exceptions
|
||||
//
|
||||
class invalid_btCmp {};
|
||||
|
||||
|
||||
//
|
||||
// when someone copies into a class deriving from this
|
||||
// do _not_ change the node pointers
|
||||
//
|
||||
void operator = (tsBTreeNode<T> &) {}
|
||||
|
||||
enum btCmp {btGreater, btLessOrEqual};
|
||||
|
||||
//
|
||||
// class T must supply this member function which
|
||||
// comapres *this with item
|
||||
//
|
||||
// returns:
|
||||
// btGreater *this is greater than item
|
||||
// btLessOrEqual *this is less than or equal to item
|
||||
//
|
||||
// btCmp tsBTreeCompare(const T &item) const;
|
||||
//
|
||||
|
||||
private:
|
||||
T *pLeft;
|
||||
T *pRight;
|
||||
|
||||
//
|
||||
// run callback for evey item in the B-Treee in sort order
|
||||
//
|
||||
static void traverse (T &item, void (T::*pCallBack)())
|
||||
{
|
||||
tsBTreeNode<T> &node = item;
|
||||
if (node.pLeft) {
|
||||
tsBTreeNode<T>::traverse (*node.pLeft, pCallBack);
|
||||
}
|
||||
(item.*pCallBack)();
|
||||
if (node.pRight) {
|
||||
tsBTreeNode<T>::traverse (*node.pRight, pCallBack);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE:
|
||||
// no change to item.pLeft and item.pRight here
|
||||
// so that an segment of a tree can be inserted
|
||||
//
|
||||
static void insert(T &self, T &item)
|
||||
{
|
||||
tsBTreeNode<T> &node = self;
|
||||
btCmp result = item.tsBTreeCompare(self);
|
||||
if (result==btLessOrEqual) {
|
||||
if (node.pLeft) {
|
||||
tsBTreeNode<T>::insert (*node.pLeft, item);
|
||||
}
|
||||
else {
|
||||
node.pLeft = &item;
|
||||
}
|
||||
}
|
||||
else if(result==btGreater) {
|
||||
if (node.pRight) {
|
||||
tsBTreeNode<T>::insert (*node.pRight, item);
|
||||
}
|
||||
else {
|
||||
node.pRight = &item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throwWithLocation ( invalid_btCmp () );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// remove()
|
||||
// returns pointer to modified tree and found/not found
|
||||
// (NULL if this portion of the tree is empty)
|
||||
//
|
||||
static tsBTreeRMRet<T> remove(T &self, T &item)
|
||||
{
|
||||
tsBTreeNode<T> &node = self;
|
||||
if (&self == &item) {
|
||||
if (node.pLeft) {
|
||||
if (node.pRight) {
|
||||
tsBTreeNode<T> *pLeftNode = node.pLeft;
|
||||
T *pR = pLeftNode->pRight;
|
||||
if (pR) {
|
||||
tsBTreeNode<T>::insert (*pR, *node.pRight);
|
||||
}
|
||||
else {
|
||||
pLeftNode->pRight = node.pRight;
|
||||
}
|
||||
}
|
||||
return tsBTreeRMRet<T>(tsbtrrFound, node.pLeft); // found it
|
||||
}
|
||||
else {
|
||||
return tsBTreeRMRet<T>(tsbtrrFound, node.pRight); // found it
|
||||
}
|
||||
}
|
||||
|
||||
btCmp result = item.tsBTreeCompare(self);
|
||||
if (result==btLessOrEqual) {
|
||||
if (node.pLeft) {
|
||||
tsBTreeRMRet<T> ret = tsBTreeNode<T>::remove(*node.pLeft, item);
|
||||
if (ret.foundIt==tsbtrrFound) {
|
||||
node.pLeft= ret.pNewSeg;
|
||||
return tsBTreeRMRet<T> (tsbtrrFound, &self); // TRUE - found it
|
||||
}
|
||||
}
|
||||
return tsBTreeRMRet<T>(tsbtrrNotFound, 0u); // not found
|
||||
}
|
||||
else if(result==btGreater) {
|
||||
if (node.pRight) {
|
||||
tsBTreeRMRet<T> ret = tsBTreeNode<T>::remove(*node.pRight, item);
|
||||
if (ret.foundIt==tsbtrrFound) {
|
||||
node.pRight = ret.pNewSeg;
|
||||
return tsBTreeRMRet<T>(tsbtrrFound,&self); // TRUE - found it
|
||||
}
|
||||
}
|
||||
return tsBTreeRMRet<T>(tsbtrrNotFound, 0u); // not found
|
||||
}
|
||||
else {
|
||||
return tsBTreeRMRet<T>(tsbtrrNotFound, 0u); // not found
|
||||
}
|
||||
}
|
||||
//
|
||||
// verify
|
||||
//
|
||||
static unsigned verify(const T &self, const T &item)
|
||||
{
|
||||
const tsBTreeNode<T> &node = self;
|
||||
|
||||
if (&self == &item) {
|
||||
return 1u; // TRUE -item is present
|
||||
}
|
||||
btCmp result = item.tsBTreeCompare(self);
|
||||
if (result==btLessOrEqual) {
|
||||
if (node.pLeft) {
|
||||
return tsBTreeNode<T>::verify (*node.pLeft, item);
|
||||
}
|
||||
else {
|
||||
return 0u; // FALSE - not found
|
||||
}
|
||||
}
|
||||
else if(result==btGreater) {
|
||||
if (node.pRight) {
|
||||
return tsBTreeNode<T>::verify (*node.pRight, item);
|
||||
}
|
||||
else {
|
||||
return 0u; // FALSE - not found
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0u; // FALSE - not found
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// tsBTree
|
||||
//
|
||||
template <class T>
|
||||
class tsBTree
|
||||
{
|
||||
public:
|
||||
tsBTree() : pRoot(0u) {}
|
||||
|
||||
// ~tsBTree()
|
||||
// {
|
||||
// this->traverse(T::~T);
|
||||
// }
|
||||
|
||||
void insert(T &item)
|
||||
{
|
||||
tsBTreeNode<T> &node = item;
|
||||
node.pLeft = 0;
|
||||
node.pRight = 0;
|
||||
if (this->pRoot) {
|
||||
tsBTreeNode<T>::insert(*this->pRoot, item);
|
||||
}
|
||||
else {
|
||||
this->pRoot = &item;
|
||||
}
|
||||
}
|
||||
//
|
||||
// remove item from the tree
|
||||
//
|
||||
// returns true if item was in the tree
|
||||
// (otherwise FALSE)
|
||||
//
|
||||
unsigned remove(T &item)
|
||||
{
|
||||
if (this->pRoot) {
|
||||
tsBTreeRMRet<T> ret =
|
||||
tsBTreeNode<T>::remove(*this->pRoot, item);
|
||||
if (ret.foundIt) {
|
||||
this->pRoot = ret.pNewSeg;
|
||||
return 1u; // TRUE - found it
|
||||
}
|
||||
}
|
||||
return 0u; // FALSE - not found
|
||||
}
|
||||
//
|
||||
// verify that item is in the tree
|
||||
//
|
||||
// returns true if item is in the tree
|
||||
// (otherwise FALSE)
|
||||
//
|
||||
unsigned verify(T &item) const
|
||||
{
|
||||
if (this->pRoot) {
|
||||
return tsBTreeNode<T>::verify(*this->pRoot, item);
|
||||
}
|
||||
else {
|
||||
return 0u; // FALSE - not found
|
||||
}
|
||||
}
|
||||
//
|
||||
// Call (pT->*pCB) () for each item in the table
|
||||
//
|
||||
// where pT is a pointer to type T and pCB is
|
||||
// a pointer to a memmber function of T with
|
||||
// no parameters and returning void
|
||||
//
|
||||
void traverse(void (T::*pCB)())
|
||||
{
|
||||
if (this->pRoot) {
|
||||
tsBTreeNode<T>::traverse(*this->pRoot, pCB);
|
||||
}
|
||||
}
|
||||
private:
|
||||
T *pRoot;
|
||||
};
|
||||
|
||||
@@ -28,8 +28,6 @@ typedef struct epicsMessageQueueOSD *epicsMessageQueueId;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "locationException.h"
|
||||
|
||||
class epicsShareClass epicsMessageQueue {
|
||||
public:
|
||||
epicsMessageQueue ( unsigned int capacity,
|
||||
|
||||
@@ -22,11 +22,14 @@ typedef enum {
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "compilerDependencies.h"
|
||||
#include "epicsGuard.h"
|
||||
|
||||
#define newEpicsMutex new epicsMutex(__FILE__,__LINE__)
|
||||
|
||||
class epicsShareClass epicsMutex {
|
||||
public:
|
||||
typedef epicsGuard<epicsMutex> guard_t;
|
||||
typedef epicsGuard<epicsMutex> release_t;
|
||||
class mutexCreateFailed; /* exception payload */
|
||||
class invalidMutex; /* exception payload */
|
||||
epicsMutex ();
|
||||
@@ -44,6 +47,8 @@ private:
|
||||
|
||||
class epicsShareClass epicsDeadlockDetectMutex {
|
||||
public:
|
||||
typedef epicsGuard<epicsDeadlockDetectMutex> guard_t;
|
||||
typedef epicsGuard<epicsDeadlockDetectMutex> release_t;
|
||||
typedef unsigned hierarchyLevel_t;
|
||||
epicsDeadlockDetectMutex ( unsigned hierarchyLevel_t );
|
||||
~epicsDeadlockDetectMutex ();
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsMessageQueue.h"
|
||||
#include <ellLib.h>
|
||||
|
||||
@@ -71,9 +71,9 @@ void exScalarPV::scan()
|
||||
}
|
||||
newValue += (float) ( sin (radians) / 10.0 );
|
||||
limit = (float) this->info.getHopr ();
|
||||
newValue = tsMin ( newValue, limit );
|
||||
newValue = epicsMin ( newValue, limit );
|
||||
limit = (float) this->info.getLopr ();
|
||||
newValue = tsMax ( newValue, limit );
|
||||
newValue = epicsMax ( newValue, limit );
|
||||
*pDD = newValue;
|
||||
aitTimeStamp gddts ( this->currentTime );
|
||||
pDD->setTimeStamp ( & gddts );
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "casdef.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "resourceLib.h"
|
||||
#include "tsMinMax.h"
|
||||
#include "epicsAlgorithm.h"
|
||||
|
||||
#ifndef NELEMENTS
|
||||
# define NELEMENTS(A) (sizeof(A)/sizeof(A[0]))
|
||||
|
||||
@@ -135,9 +135,9 @@ void exVectorPV::scan()
|
||||
}
|
||||
newValue += (float) (sin (radians) / 10.0);
|
||||
limit = (float) this->info.getHopr();
|
||||
newValue = tsMin (newValue, limit);
|
||||
newValue = epicsMin (newValue, limit);
|
||||
limit = (float) this->info.getLopr();
|
||||
newValue = tsMax (newValue, limit);
|
||||
newValue = epicsMax (newValue, limit);
|
||||
*(pF++) = newValue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user