remove new method for PVRecord

This commit is contained in:
mrkraimer
2019-05-22 10:41:55 -04:00
parent 898868d5f4
commit a004f7ea08
3 changed files with 55 additions and 1 deletions

View File

@ -99,6 +99,51 @@ PVRecord::~PVRecord()
notifyClients(); notifyClients();
} }
void PVRecord::remove()
{
#ifdef XXX
{
epicsGuard<epics::pvData::Mutex> guard(mutex);
if(traceLevel>0) {
cout << "PVRecord::remove() " << recordName
<< " isDestroyed " << (isDestroyed ? "true" : "false")
<< endl;
}
if(isDestroyed) {
return;
}
isDestroyed = true;
}
#endif
PVDatabasePtr pvDatabase(PVDatabase::getMaster());
if(pvDatabase) pvDatabase->removeRecord(shared_from_this());
pvTimeStamp.detach();
for(std::list<PVListenerWPtr>::iterator iter = pvListenerList.begin();
iter!=pvListenerList.end();
iter++ )
{
PVListenerPtr listener = iter->lock();
if(!listener) continue;
if(traceLevel>0) {
cout << "PVRecord::remove() calling listener->unlisten " << recordName << endl;
}
listener->unlisten(shared_from_this());
}
pvListenerList.clear();
for (std::list<PVRecordClientWPtr>::iterator iter = clientList.begin();
iter!=clientList.end();
iter++ )
{
PVRecordClientPtr client = iter->lock();
if(!client) continue;
if(traceLevel>0) {
cout << "PVRecord::remove() calling client->detach " << recordName << endl;
}
client->detach(shared_from_this());
}
clientList.clear();
}
void PVRecord::initPVRecord() void PVRecord::initPVRecord()
{ {
PVRecordStructurePtr parent; PVRecordStructurePtr parent;

View File

@ -101,6 +101,15 @@ public:
* @brief DEPRECATED * @brief DEPRECATED
*/ */
virtual void destroy() {} virtual void destroy() {}
/**
* @brief remove record from database.
*
* Remove the PVRecord. Release any resources used and
* get rid of listeners and requesters.
* If derived class overrides this then it must call PVRecord::remove()
* after it has destroyed any resorces it uses.
*/
virtual void remove();
/** /**
* @brief Optional method for derived class. * @brief Optional method for derived class.
* *

View File

@ -65,7 +65,7 @@ void RemoveRecord::process()
pvResult->put(name + " not found"); pvResult->put(name + " not found");
return; return;
} }
pvRecord->destroy(); pvRecord->remove();
pvResult->put("success"); pvResult->put("success");
} }