reSIProcate/DialogUsageManager  9694
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
resip::HandleManager Class Reference

#include <HandleManager.hxx>

Inheritance diagram for resip::HandleManager:
Inheritance graph
[legend]
Collaboration diagram for resip::HandleManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 HandleManager ()
virtual ~HandleManager ()
bool isValidHandle (Handled::Id) const
HandledgetHandled (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

Detailed Description

Definition at line 12 of file HandleManager.hxx.


Member Typedef Documentation

Definition at line 33 of file HandleManager.hxx.


Constructor & Destructor Documentation

HandleManager::HandleManager ( )

Definition at line 10 of file HandleManager.cxx.

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__);
   }
}

Here is the call graph for this function:


Member Function Documentation

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() << ")");      
      }
   }
}

Here is the call graph for this function:

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
   }
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Handled [friend]

Definition at line 28 of file HandleManager.hxx.


Member Data Documentation

Definition at line 36 of file HandleManager.hxx.

Referenced by create().

Definition at line 35 of file HandleManager.hxx.

Referenced by remove(), and shutdownWhenEmpty().


The documentation for this class was generated from the following files: