|
reSIProcate/DialogUsageManager
9694
|
#include <HandleManager.hxx>


Public Member Functions | |
| HandleManager () | |
| virtual | ~HandleManager () |
| bool | isValidHandle (Handled::Id) const |
| Handled * | getHandled (Handled::Id) const |
| virtual void | shutdownWhenEmpty () |
| HandleMap::size_type | handleCount (void) const |
| Returns the number of handles in use. | |
Protected Types | |
| typedef HashMap< Handled::Id, Handled * > | HandleMap |
Protected Member Functions | |
| virtual void | onAllHandlesDestroyed ()=0 |
| virtual void | dumpHandles () const |
| Handled::Id | create (Handled *handled) |
| void | remove (Handled::Id id) |
Protected Attributes | |
| HandleMap | mHandleMap |
| bool | mShuttingDown |
| Handled::Id | mLastId |
Friends | |
| class | Handled |
Definition at line 12 of file HandleManager.hxx.
typedef HashMap<Handled::Id, Handled*> resip::HandleManager::HandleMap [protected] |
Definition at line 33 of file HandleManager.hxx.
| HandleManager::HandleManager | ( | ) |
Definition at line 10 of file HandleManager.cxx.
: mShuttingDown(false), mLastId(Handled::npos) { }
| HandleManager::~HandleManager | ( | ) | [virtual] |
Definition at line 16 of file HandleManager.cxx.
References DebugLog, resip::InserterP(), and mHandleMap.
{
// !jf! do nothing?
// !dcm! -- this is the best we can do w/out a back-ptr to each handle
// DUM currently cleans up properly, so not an issue unless users make their
// own handled objects, could clean up memeory, but the app will crash first
// handle deference regardless.
if (!mHandleMap.empty())
{
DebugLog ( << "&&&&&& HandleManager::~HandleManager: Deleting handlemanager that still has Handled objects: " );
DebugLog ( << InserterP(mHandleMap));
//throw HandleException("Deleting handlemanager that still has Handled objects", __FILE__, __LINE__);
}
}

| Handled::Id HandleManager::create | ( | Handled * | handled | ) | [protected] |
Definition at line 32 of file HandleManager.cxx.
References mHandleMap, and mLastId.
Referenced by resip::Handled::Handled().
{
mHandleMap[++mLastId] = handled;
return mLastId;
}
| void HandleManager::dumpHandles | ( | ) | const [protected, virtual] |
Definition at line 91 of file HandleManager.cxx.
References DebugLog, and mHandleMap.
Referenced by resip::DialogUsageManager::forceShutdown().
{
DebugLog (<< "Waiting for usages to be deleted (" << mHandleMap.size() << ")");
for (HandleMap::const_iterator i=mHandleMap.begin() ; i != mHandleMap.end(); ++i)
{
DebugLog (<< i->first << " -> " << *(i->second));
}
}
| Handled * HandleManager::getHandled | ( | Handled::Id | id | ) | const |
Definition at line 108 of file HandleManager.cxx.
References InfoLog, and mHandleMap.
Referenced by resip::Handle< ClientSubscription >::get().
{
HandleMap::const_iterator i = mHandleMap.find(id);
if (i == mHandleMap.end())
{
InfoLog (<< "Reference to stale handle: " << id);
assert(0);
throw HandleException("Stale handle", __FILE__, __LINE__);
}
else
{
assert(i->second);
return i->second;
}
}
| HandleMap::size_type resip::HandleManager::handleCount | ( | void | ) | const [inline] |
Returns the number of handles in use.
Definition at line 40 of file HandleManager.hxx.
References mHandleMap.
{
return mHandleMap.size();
}
| bool HandleManager::isValidHandle | ( | Handled::Id | id | ) | const |
dcm! -- fix; use find
Definition at line 101 of file HandleManager.cxx.
References mHandleMap.
Referenced by resip::Handle< ClientSubscription >::isValid().
{
return mHandleMap.count(id) != 0;
}
| virtual void resip::HandleManager::onAllHandlesDestroyed | ( | ) | [protected, pure virtual] |
Implemented in resip::DialogUsageManager.
Referenced by remove(), and shutdownWhenEmpty().
| void HandleManager::remove | ( | Handled::Id | id | ) | [protected] |
Definition at line 72 of file HandleManager.cxx.
References DebugLog, mHandleMap, mShuttingDown, and onAllHandlesDestroyed().
Referenced by resip::Handled::~Handled().
{
HandleMap::iterator i = mHandleMap.find(id);
assert (i != mHandleMap.end());
mHandleMap.erase(i);
if (mShuttingDown)
{
if(mHandleMap.empty())
{
onAllHandlesDestroyed();
}
else
{
DebugLog (<< "Waiting for usages to be deleted (" << mHandleMap.size() << ")");
}
}
}

| void HandleManager::shutdownWhenEmpty | ( | ) | [virtual] |
Definition at line 38 of file HandleManager.cxx.
References DebugLog, mHandleMap, mShuttingDown, and onAllHandlesDestroyed().
Referenced by resip::DialogUsageManager::shutdown().
{
mShuttingDown = true;
if (mHandleMap.empty())
{
onAllHandlesDestroyed();
}
else
{
DebugLog (<< "Shutdown waiting for all usages to be deleted (" << mHandleMap.size() << ")");
#if 1
for (HandleMap::iterator i=mHandleMap.begin() ; i != mHandleMap.end(); ++i)
{
DebugLog (<< i->first << " -> " << *(i->second));
}
#endif
}
}

friend class Handled [friend] |
Definition at line 28 of file HandleManager.hxx.
HandleMap resip::HandleManager::mHandleMap [protected] |
Definition at line 34 of file HandleManager.hxx.
Referenced by create(), dumpHandles(), getHandled(), handleCount(), isValidHandle(), remove(), shutdownWhenEmpty(), and ~HandleManager().
Handled::Id resip::HandleManager::mLastId [protected] |
Definition at line 36 of file HandleManager.hxx.
Referenced by create().
bool resip::HandleManager::mShuttingDown [protected] |
Definition at line 35 of file HandleManager.hxx.
Referenced by remove(), and shutdownWhenEmpty().
1.7.5.1