Free Electron
|
Interface into a dynamic library to access its factories. More...
#include <Library.h>
Classes | |
class | BaseFactory |
Type-nonspecific base class for factories. More... | |
class | Factory |
Type-specific factory template. More... | |
Public Member Functions | |
template<typename T > | |
void | add (const String &name) |
Create a named factory for the given type and add it to the library's collection. More... | |
template<typename T > | |
void | addSingleton (const String &name) |
Create a named factory for the given type, but treat it as a singleton. More... | |
const String & | name (void) const |
Return the library name. More... | |
void | populateManifest (Array< String > &names) const |
Append the names of the available factories to the given array. More... | |
U32 | adjustedReferences (void) const |
Return number of references adjusted for singletons. More... | |
void | releaseSingletons (void) |
Release all instantiated singletons. More... | |
I32 | strayCount (void) |
I32 | adjustStrayCount (I32 inc) |
sp< Component > | create (U32 factoryIndex) |
Create component using the known index. More... | |
String | factoryName (U32 factoryIndex) |
hp< Registry > | registry (void) const |
void | setRegistry (sp< Registry > spRegistry) |
sp< Library > | getChainLibrary (void) const |
void | setChainLibrary (sp< Library > &rspLibrary) |
Enforce FIFO by referencing prev lib on stack. More... | |
void | setName (const char *a_name) |
for use in static lib scenario More... | |
DL_Loader * | getLoader (void) const |
void | setLoader (DL_Loader *pLoader) |
Public Member Functions inherited from fe::Counted | |
virtual void | acquire (void) |
Increment the reference count. More... | |
virtual void | acquire (int &rCount) |
Increment the reference count (and get the count) More... | |
virtual void | release (void) |
Decrement the reference count. More... | |
virtual void | abandon (void) |
Decrement the reference count. More... | |
int | count (void) const |
Return the count of references. More... | |
void | setName (const String &) |
void | trackReference (void *pReference, String what) |
void | untrackReference (void *pReference) |
void | registerRegion (void *pT, U32 bytes) |
Static Public Member Functions | |
template<typename T > | |
static sp< Component > | create (String name, Library *pLibrary=NULL, I32 a_factoryIndex=-1) |
Instantiate and initialize a component without using a factory. More... | |
Static Public Member Functions inherited from fe::Counted | |
static String | reportTracker (void) |
static U32 | trackerCount (void) |
Private Member Functions | |
void | addFactory (BaseFactory *pFactory, BWORD singleton) |
Static Private Member Functions | |
static void | initComponent (sp< Component > &rspComponent, void *ptr, U32 size, String name, Library *pLibrary, I32 a_factoryIndex) |
Private Attributes | |
Array< FactoryData > | m_factories |
sp< Library > | m_spChainLibrary |
DL_Loader * | m_pLoader |
I32 | m_strayCount |
Registry * | m_pRegistry |
String | m_name |
Additional Inherited Members | |
Protected Member Functions inherited from fe::Counted | |
int | releaseInternal (void) |
Decrement the reference count. More... | |
void | suppressReport (void) |
Interface into a dynamic library to access its factories.
Each dynamic library should contain a single code block exposing component implementations it can create. For example,
This code block will create the neccessary factories. It is not optional since omitting it makes the library useless (you can set up automatic dynamic linking in your build).
Another code block can be optionally used to automatically load any number of other libraries prior to the given library. For example,
If this block is omitted, no dependency preloading is performed.
By convention, these two blocks are provided together in a file named like moduleDL.cc, one for each module.
|
inline |
Create a named factory for the given type and add it to the library's collection.
|
inline |
Create a named factory for the given type, but treat it as a singleton.
U32 fe::Library::adjustedReferences | ( | void | ) | const |
Return number of references adjusted for singletons.
Once this drops to 1 plus the number of factories, there are no outstanding references outside of the Library and the singletons it has instantiated.
|
inlinestatic |
Instantiate and initialize a component without using a factory.
This is useful for unit tests that don't want to utilize a proper library. It is not intended for general use.
You have to explicitly provide the class type as the template argument.
String fe::Library::factoryName | ( | U32 | factoryIndex | ) |
References fe::Component::factoryIndex().
|
inline |
|
inline |
Return the library name.
Append the names of the available factories to the given array.
References fe::Handled< T >::getHandle().
void fe::Library::releaseSingletons | ( | void | ) |
Release all instantiated singletons.
This command is intended to be part of an internal shutdown procedure. If any of the singletons was still otherwise referenced and an attempt is made to create the singleton again, a new independent instance of the singleton will be created.
Enforce FIFO by referencing prev lib on stack.
|
inline |
References fe::String::basename(), fe::String::chop(), fe::DL_Loader::name(), and fe::String::prechop().
|
inline |
for use in static lib scenario