ComponentFactory Class Reference

#include <ComponentFactory.h>

Inheritance diagram for ComponentFactory:

Inheritance graph
[legend]
Collaboration diagram for ComponentFactory:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void initPalette ()
void dumpFactory ()
void setDebug (bool tf)
std::vector< std::string > getPalette ()
ccafeopq::Component * instantiate (const char *deploymentClassAlias)
void readComponentDescription (const std::string &uri)
void setComponentPath (const std::vector< std::string > &p)
void setComponentPath (const char **pathDirArgv)
int searchComponentPath ()
std::vector< std::string > getLoadedComponents ()
std::vector< std::string > getUnloadedComponents ()
std::vector< std::string > getLoadedLibraries ()
std::vector< std::string > getParsedFiles ()
int loadPalette (const std::string &className, bool global, bool lazy)
int loadPalette (const char *className, bool global, bool lazy)
virtual std::vector< std::string > getComponentClassAliases ()
virtual std::vector
< ccafeopq::ComponentClassDescription_shared > 
getComponentClasses ()
virtual ccafeopq::Component * createComponentInstance (const std::string &className)
virtual ccafeopq::Component * createComponentInstance (const std::string &className, ccafeopq::TypeMap_shared &properties)
virtual void destroyComponentInstance (const std::string &componentClassName, ccafeopq::Component *component)
virtual std::vector< std::string > getComponentPath ()
virtual void loadComponentDescription (const std::string &uri)
virtual void indexComponentPath ()
virtual void loadClass (const std::string paletteClassAlias, bool global, bool lazy)
virtual int loadPorts (const std::string &libPathName)

Private Member Functions

int addClass (const char *className, void *(*create)())
int addClass (const char *className, void *(*create)(), bool required)
int addClassBabel (const char *className)
virtual int addStaticClass (const char *className, void *(*create)(), const char *classAlias)
virtual int addStaticClassBabel (const char *className, void *(*create)(), const char *classAlias)
int addStaticClassKind (const char *className, void *(*create)(), const char *classAlias, const char *classtype)
bool checkAlreadyLoaded (const char *fname)
int countUnloadedClasses ()
ComponentRecord_shared getRecordByPaletteClassName (const char *cname)
ComponentRecord_shared getRecordByLibraryClassName (char *lib, char *lcname)
void dump_babel_dl_info ()
int loadPalette (const char *libraryPath, const char *mapName, const char *cFuncName, bool global, bool lazy, const char *cmptType, const char *buildPath)

Private Attributes

std::vector< std::string > componentPathEntries
std::vector< std::string > parsedFiles
std::vector
< ComponentRecord_shared > 
repository
std::map< std::string, void * > loadedLibraries

Static Private Attributes

static bool debug


Detailed Description

There can sanely be only one instance of this per runtime. So there can be more than one Frame, but the dynamically opened libraries are the same across all frames -- that's life in unix.

This class should be better decomposed. Currently it is a combination of factory and wrappers for the DL stuff standing in lieu of a repository interface. One might want, for example, to show some component types in the palette of one frame but not another. For now we push that off to a UI to manage.


Member Function Documentation

int ComponentFactory::addClass ( const char *  className,
void *(*)()  create 
) [private]

register a classic component constructor

int ComponentFactory::addClassBabel ( const char *  className  )  [private]

register a babel class for dynamic loading.

virtual int ComponentFactory::addStaticClass ( const char *  className,
void *(*)()  create,
const char *  classAlias 
) [private, virtual]

register a classic constructor that is static linked.

Implements ComponentRegistrar.

virtual int ComponentFactory::addStaticClassBabel ( const char *  className,
void *(*)()  create,
const char *  classAlias 
) [private, virtual]

register a babel constructor that is static linked.

Implements ComponentRegistrar.

int ComponentFactory::addStaticClassKind ( const char *  className,
void *(*)()  create,
const char *  classAlias,
const char *  classtype 
) [private]

internal use only.

bool ComponentFactory::checkAlreadyLoaded ( const char *  fname  )  [private]

True if metadata file has already been parsed by the name fname

int ComponentFactory::countUnloadedClasses (  )  [private]

count the number of classes in the repository list that do not have constructors registered. This is approximate because all BABEL classes are considered loaded whether they have been dlopened or not (since babel hides dlopen from us).

ComponentRecord_shared ComponentFactory::getRecordByPaletteClassName ( const char *  cname  )  [private]

Look up a class description by UI alias.

ComponentRecord_shared ComponentFactory::getRecordByLibraryClassName ( char *  lib,
char *  lcname 
) [private]

Look up a class by babel class name or by classic create_ constructor?

Parameters:
lib library pathname
lcname real library class name.

void ComponentFactory::dump_babel_dl_info (  )  [private]

Dump helpful Babel DL path info in case we fail to instantiate a class

void ComponentFactory::initPalette (  ) 

Load any hard-coded types and set up palette data structures. Must be called before any loadPalette or instantiate is attempted.

void ComponentFactory::dumpFactory (  ) 

print the repository

void ComponentFactory::setDebug ( bool  tf  )  [inline]

enables some additional spew

00097 {debug = tf;}

std::vector< std::string > ComponentFactory::getPalette (  ) 

get the names of registered components. This method could be per-container.

ccafeopq::Component* ComponentFactory::instantiate ( const char *  deploymentClassAlias  ) 

build a component named in results of getPalette.

void ComponentFactory::readComponentDescription ( const std::string &  uri  ) 

Parse a file (or url when wget support is included) describing a component and attempt to add it to the runtime repository list.

void ComponentFactory::setComponentPath ( const std::vector< std::string > &  p  ) 

Parameters:
p a vector of path elements. Currently all elements must be names of directories searchable via glob(). An argv-style version of this function is also provided. When searchComponentPath is called, the directories given here are searched for metadata files matching the pattern *.cca and containing a class description. The search results become the repository class list. This call is not cumulative--that is, all previously set paths are removed and replaced with the arguments to this one.
Note for BABEL/SIDL: this call *is* cumulative for the babel class loader. The value passed here is *prepended* to the SIDL loader search path. If it is not cumulative, then the net effect is that SIDL_DLL_PATH is lost because SIDL Loader only consults env the first time to do an initial setSearchPath and thereafter ignores it. At least this is the apparent behavior october 2003.

void ComponentFactory::setComponentPath ( const char **  pathDirArgv  ) 

argv style support for legacy codes.

int ComponentFactory::searchComponentPath (  ) 

Searches the componentPath for files ending in .cca and builds a repository index of the classes. Returns the number of classes dynamically loadable, but not yet loaded.

This method could be per-container.

std::vector< std::string > ComponentFactory::getLoadedComponents (  ) 

Returns the list of tuples, library:component pairs, describing what is currently dynamically loaded and has a constructor registered. The list is hence of an even length since each pair is kept as successive elements, in {library, component} order. Due to possible syntax of urls and class names in namespaces, we do not try to combine these into a single string per component loaded, though this is surely doable by the thoughtful.

This method, unfortunately, must be global in scope since we don't want to be redundantly loading libraries. This is probably a function useful only to the outermost framework/container. GetPalette is what users want to see.

std::vector< std::string > ComponentFactory::getUnloadedComponents (  ) 

Return the list of known but not loaded component classNames. Will be empty unless searchComponentPath has been called.

std::vector< std::string > ComponentFactory::getLoadedLibraries (  ) 

list of the libraries which have been opened. Return may be empty but not null. libraries listed do not include those opened by SIDL loader or by the C runtime itself.

std::vector< std::string > ComponentFactory::getParsedFiles (  ) 

return the names of metadata files that were parsed.

int ComponentFactory::loadPalette ( const std::string &  className,
bool  global,
bool  lazy 
)

load a class to palette from the repository. className must be same as one returned from getUnloadedComponents. return is non-zero if there is an error.

This method could be "apparently" per-container, but it affects the global runtime. Some OS runtime linkers may ignore global and lazy. In dlopen terms, lazy=true -> RTLD_LAZY, false->RTLD_NOW; global=true ->RTLD_GLOBAL, false->RTLD_LOCAL.

Parameters:
global if true, add symbols to global link table, else keep private.
lazy if true, do not resolve undefined symbols in loaded component until an attempt to use them is made.

int ComponentFactory::loadPalette ( const char *  className,
bool  global,
bool  lazy 
)

legacy driver string support

virtual std::vector< std::string > ComponentFactory::getComponentPath (  )  [virtual]

Get the current component path. If you wish to edit the path list, you just get the current path and copy the elements you want to keep into a new vector and call setComponentPath again.

int ComponentFactory::loadPalette ( const char *  libraryPath,
const char *  mapName,
const char *  cFuncName,
bool  global,
bool  lazy,
const char *  cmptType,
const char *  buildPath 
) [private]

Handle the dlsym stuff. Return is non-zero if there is an error. This method could be "apparently" per-container, but it affects the global runtime linker if global==true. Some OS runtime linkers may ignore global and lazy. In dlopen terms, lazy=true -> RTLD_LAZY, false->RTLD_NOW; global=true ->RTLD_GLOBAL, false->RTLD_LOCAL.

Parameters:
global if true, add symbols to global link table, else keep private.
lazy if true, do not resolve undefined symbols in loaded component until an attempt to use them is made.


Member Data Documentation

std::vector< std::string > ComponentFactory::componentPathEntries [private]

dir names.

std::vector< std::string > ComponentFactory::parsedFiles [private]

file/uri that have been parsed.

std::vector< ComponentRecord_shared > ComponentFactory::repository [private]

metadata list

std::map< std::string, void *> ComponentFactory::loadedLibraries [private]

dlopened file handles by name.


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

Generated on Thu Sep 17 08:21:23 2009 for CCAFFEINE by  doxygen 1.5.9