Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends
nsCategoryCache< T > Class Template Reference

This is a helper class that caches services that are registered in a certain category. More...

#include <nsCategoryCache.h>

Inheritance diagram for nsCategoryCache< T >:
Inheritance graph
[legend]
Collaboration diagram for nsCategoryCache< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsCategoryCache (const char *aCategory)
 ~nsCategoryCache ()
const nsCOMArray< T > & GetEntries ()

Protected Member Functions

virtual void EntryAdded (const nsCString &aValue)
virtual void EntryRemoved (const nsCString &aValue)
virtual void CategoryCleared ()

Private Member Functions

 nsCategoryCache (const nsCategoryCache< T > &)

Private Attributes

nsCString mCategoryName
nsCOMArray< TmEntries
nsRefPtr< nsCategoryObserver > mObserver

Friends

class CategoryObserver

Detailed Description

template<class T>
class nsCategoryCache< T >

This is a helper class that caches services that are registered in a certain category.

The intended usage is that a service stores a variable of type nsCategoryCache<nsIFoo> in a member variable, where nsIFoo is the interface that these services should implement. The constructor of this class should then get the name of the category.

Definition at line 89 of file nsCategoryCache.h.


Constructor & Destructor Documentation

template<class T >
nsCategoryCache< T >::nsCategoryCache ( const char *  aCategory) [explicit]

Definition at line 120 of file nsCategoryCache.h.

: mCategoryName(aCategory)
{
}
template<class T>
nsCategoryCache< T >::~nsCategoryCache ( ) [inline]

Definition at line 92 of file nsCategoryCache.h.

{ if (mObserver) mObserver->ListenerDied(); }
template<class T>
nsCategoryCache< T >::nsCategoryCache ( const nsCategoryCache< T > &  ) [private]

Member Function Documentation

template<class T >
void nsCategoryCache< T >::CategoryCleared ( ) [protected, virtual]

Definition at line 140 of file nsCategoryCache.h.

                                         {
  mEntries.Clear();
}
template<class T >
void nsCategoryCache< T >::EntryAdded ( const nsCString aValue) [protected, virtual]

Definition at line 126 of file nsCategoryCache.h.

                                                           {
  nsCOMPtr<T> catEntry = do_GetService(aValue.get());
  if (catEntry)
    mEntries.AppendObject(catEntry);
}

Here is the call graph for this function:

template<class T >
void nsCategoryCache< T >::EntryRemoved ( const nsCString aValue) [protected, virtual]

Definition at line 133 of file nsCategoryCache.h.

                                                             {
  nsCOMPtr<T> catEntry = do_GetService(aValue.get());
  if (catEntry)
    mEntries.RemoveObject(catEntry);
}

Here is the call graph for this function:

template<class T>
const nsCOMArray<T>& nsCategoryCache< T >::GetEntries ( ) [inline]

Definition at line 94 of file nsCategoryCache.h.

                                      {
      // Lazy initialization, so that services in this category can't
      // cause reentrant getService (bug 386376)
      if (!mObserver)
        mObserver = new nsCategoryObserver(mCategoryName.get(), this);
      return mEntries;
    }

Here is the caller graph for this function:


Friends And Related Function Documentation

template<class T>
friend class CategoryObserver [friend]

Definition at line 106 of file nsCategoryCache.h.


Member Data Documentation

template<class T>
nsCString nsCategoryCache< T >::mCategoryName [private]

Definition at line 111 of file nsCategoryCache.h.

template<class T>
nsCOMArray<T> nsCategoryCache< T >::mEntries [private]

Definition at line 112 of file nsCategoryCache.h.

template<class T>
nsRefPtr<nsCategoryObserver> nsCategoryCache< T >::mObserver [private]

Definition at line 113 of file nsCategoryCache.h.


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