remove new method for PVRecord
This commit is contained in:
@ -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;
|
||||||
|
@ -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.
|
||||||
*
|
*
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user