Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
nsGenericModule Class Reference

#include <nsGenericFactory.h>

Inheritance diagram for nsGenericModule:
Inheritance graph
[legend]
Collaboration diagram for nsGenericModule:
Collaboration graph
[legend]

List of all members.

Classes

struct  FactoryNode

Public Member Functions

 nsGenericModule (const char *moduleName, PRUint32 componentCount, const nsModuleComponentInfo *components, nsModuleConstructorProc ctor, nsModuleDestructorProc dtor)
void getClassObject (in nsIComponentManager aCompMgr, in nsCIDRef aClass, in nsIIDRef aIID,[retval, iid_is(aIID)] out nsQIResult aResult)
 Object Instance Creation.
void registerSelf (in nsIComponentManager aCompMgr, in nsIFile aLocation, in string aLoaderStr, in string aType)
 One time registration callback.
void unregisterSelf (in nsIComponentManager aCompMgr, in nsIFile aLocation, in string aLoaderStr)
 One time unregistration callback.
boolean canUnload (in nsIComponentManager aCompMgr)
 Module load management.

Protected Member Functions

nsresult Initialize (nsIComponentManager *compMgr)
void Shutdown ()
nsresult AddFactoryNode (nsIGenericFactory *fact)

Protected Attributes

PRBool mInitialized
const char * mModuleName
PRUint32 mComponentCount
const nsModuleComponentInfomComponents
FactoryNodemFactoriesNotToBeRegistered
nsModuleConstructorProc mCtor
nsModuleDestructorProc mDtor

Private Member Functions

 ~nsGenericModule ()

Detailed Description

Definition at line 78 of file nsGenericFactory.h.


Constructor & Destructor Documentation

nsGenericModule::nsGenericModule ( const char *  moduleName,
PRUint32  componentCount,
const nsModuleComponentInfo components,
nsModuleConstructorProc  ctor,
nsModuleDestructorProc  dtor 
)

Definition at line 220 of file nsGenericFactory.cpp.

Definition at line 234 of file nsGenericFactory.cpp.

{
    Shutdown();

#ifdef XPCOM_GLUE
   XPCOMGlueShutdown();
#endif

}

Here is the call graph for this function:


Member Function Documentation

Definition at line 247 of file nsGenericFactory.cpp.

{
    if (!fact)
        return NS_ERROR_FAILURE;

    FactoryNode *node = new FactoryNode(fact, mFactoriesNotToBeRegistered);
    if (!node)
        return NS_ERROR_OUT_OF_MEMORY;
    
    mFactoriesNotToBeRegistered = node;
    return NS_OK;
}

Here is the caller graph for this function:

Module load management.

Parameters:
aCompMgr: The global component manager
Returns:
indicates to the caller if the module can be unloaded. Returning PR_TRUE isn't a guarantee that the module will be unloaded. It constitues only willingness of the module to be unloaded. It is very important to ensure that no outstanding references to the module's code/data exist before returning PR_TRUE. Returning PR_FALSE guaratees that the module wont be unloaded.
void nsIModule::getClassObject ( in nsIComponentManager  aCompMgr,
in nsCIDRef  aClass,
in nsIIDRef  aIID,
[retval, iid_is(aIID)] out nsQIResult  aResult 
) [inherited]

Object Instance Creation.

Obtains a Class Object from a nsIModule for a given CID and IID pair. This class object can either be query to a nsIFactory or a may be query to a nsIClassInfo.

Parameters:
aCompMgr: The global component manager
aClass: ClassID of object instance requested
aIID: IID of interface requested

Definition at line 263 of file nsGenericFactory.cpp.

{
    nsresult rv;

    if (mInitialized) {
        return NS_OK;
    }

    if (mCtor) {
        rv = mCtor(this);
        if (NS_FAILED(rv))
            return rv;
    }


#ifdef XPCOM_GLUE
    rv = XPCOMGlueStartup(".");
    if (NS_FAILED(rv))
        return rv;
#endif

    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(compMgr, &rv);
    if (NS_FAILED(rv))
        return rv;

    // Eagerly populate factory/class object hash for entries
    // without constructors. If we didn't, the class object would
    // never get created. Also create the factory, which doubles
    // as the class object, if the EAGER_CLASSINFO flag was given.
    // This allows objects to be created (within their modules)
    // via operator new rather than CreateInstance, yet still be
    // QI'able to nsIClassInfo.
    const nsModuleComponentInfo* desc = mComponents;
    for (PRUint32 i = 0; i < mComponentCount; i++) {
        if (!desc->mConstructor ||
            (desc->mFlags & nsIClassInfo::EAGER_CLASSINFO)) {
            nsCOMPtr<nsIGenericFactory> fact;
            nsresult rv = NS_NewGenericFactory(getter_AddRefs(fact), desc);
            if (NS_FAILED(rv)) return rv;

            // if we don't have a mConstructor, then we should not populate
            // the component manager.
            if (!desc->mConstructor) {
                rv = AddFactoryNode(fact);
            } else {
                rv = registrar->RegisterFactory(desc->mCID, 
                                                desc->mDescription,
                                                desc->mContractID, 
                                                fact);
            }
            if (NS_FAILED(rv)) return rv;
        }
        desc++;
    }

    mInitialized = PR_TRUE;
    return NS_OK;
}

Here is the call graph for this function:

void nsIModule::registerSelf ( in nsIComponentManager  aCompMgr,
in nsIFile  aLocation,
in string  aLoaderStr,
in string  aType 
) [inherited]

One time registration callback.

When the nsIModule is discovered, this method will be called so that any setup registration can be preformed.

Parameters:
aCompMgr: The global component manager
aLocation: The location of the nsIModule on disk
aLoaderStr,:Opaque loader specific string
aType: Loader Type being used to load this module
void nsGenericModule::Shutdown ( void  ) [protected]

Definition at line 324 of file nsGenericFactory.cpp.

{
    // Free cached factories that were not registered.
    FactoryNode* node;
    while (mFactoriesNotToBeRegistered)
    {
        node = mFactoriesNotToBeRegistered->mNext;
        delete mFactoriesNotToBeRegistered;
        mFactoriesNotToBeRegistered = node;
    }

    if (mInitialized) {
        mInitialized = PR_FALSE;

        if (mDtor)
            mDtor(this);
    }
}

Here is the caller graph for this function:

void nsIModule::unregisterSelf ( in nsIComponentManager  aCompMgr,
in nsIFile  aLocation,
in string  aLoaderStr 
) [inherited]

One time unregistration callback.

When the nsIModule is being unregistered, this method will be called so that any unregistration can be preformed

Parameters:
aCompMgr: The global component manager
aLocation: The location of the nsIModule on disk
aLoaderStr: Opaque loader specific string

Member Data Documentation

Definition at line 119 of file nsGenericFactory.h.

Definition at line 120 of file nsGenericFactory.h.

nsModuleConstructorProc nsGenericModule::mCtor [protected]

Definition at line 122 of file nsGenericFactory.h.

nsModuleDestructorProc nsGenericModule::mDtor [protected]

Definition at line 123 of file nsGenericFactory.h.

Definition at line 121 of file nsGenericFactory.h.

Definition at line 117 of file nsGenericFactory.h.

Definition at line 118 of file nsGenericFactory.h.


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