00001 #ifndef __COMPONENTFACTORY_H__
00002 #define __COMPONENTFACTORY_H__
00003
00004 #define BUFLEN 1024
00005
00006 namespace ccafe {
00007 class ComponentRecord_Impl;
00008 } ENDSEMI
00009 typedef ::boost::shared_ptr< ccafe::ComponentRecord_Impl > ComponentRecord_shared;
00010
00024 class ComponentFactory : public virtual ccafeopq::ComponentFactory, public virtual KernelPort , public virtual ComponentRegistrar
00025 {
00026
00027 private:
00028
00029 static bool debug;
00030
00032 std::vector< std::string > componentPathEntries;
00034 std::vector< std::string > parsedFiles;
00036 std::vector< ComponentRecord_shared > repository;
00038 std::map< std::string, void *> loadedLibraries;
00039
00041 int addClass(const char *className, void * (*create)());
00042
00043 int addClass(const char *className, void * (*create)(), bool required);
00044
00046 int addClassBabel(const char *className);
00047
00049 virtual int addStaticClass(const char *className, void *(*create)(), const char * classAlias);
00050
00052 virtual int addStaticClassBabel(const char *className, void *(*create)(), const char * classAlias);
00053
00055 int addStaticClassKind(const char *className, void *(*create)(), const char * classAlias, const char *classtype);
00056
00060 bool checkAlreadyLoaded(const char *fname);
00061
00068 int countUnloadedClasses();
00069
00071 ComponentRecord_shared getRecordByPaletteClassName( const char *cname);
00072
00078 ComponentRecord_shared getRecordByLibraryClassName( char *lib, char *lcname);
00079
00081 void dump_babel_dl_info();
00082
00083 public:
00084
00085 ComponentFactory();
00086 virtual ~ComponentFactory();
00091 void initPalette();
00092
00094 void dumpFactory();
00095
00097 void setDebug(bool tf){debug = tf;}
00098
00102 std::vector< std::string > getPalette();
00103
00106 ccafeopq::Component * instantiate(const char *deploymentClassAlias);
00107
00108
00109
00114 void readComponentDescription( const std::string & uri);
00115
00137 void setComponentPath(const std::vector< std::string > & p);
00138
00142 void setComponentPath(const char **pathDirArgv);
00143
00144
00152 int searchComponentPath();
00153
00168 std::vector< std::string > getLoadedComponents();
00169
00173 std::vector< std::string > getUnloadedComponents();
00174
00180 std::vector< std::string > getLoadedLibraries();
00181
00183 std::vector< std::string > getParsedFiles();
00184
00198 int loadPalette(const std::string& className, bool global, bool lazy);
00199
00201 int loadPalette(const char *className, bool global, bool lazy);
00202
00204
00205
00206 virtual std::vector< std::string> getComponentClassAliases();
00207
00208 virtual std::vector< ccafeopq::ComponentClassDescription_shared > getComponentClasses();
00209
00210 virtual ccafeopq::Component * createComponentInstance(const std::string & className);
00211
00212 virtual ccafeopq::Component * createComponentInstance(const std::string & className, ccafeopq::TypeMap_shared & properties);
00213
00214 virtual void destroyComponentInstance(const std::string & componentClassName, ccafeopq::Component * component);
00215
00216
00217
00223 virtual std::vector< std::string > getComponentPath();
00224
00225 virtual void loadComponentDescription(const std::string & uri);
00226
00227 virtual void indexComponentPath( );
00228
00229 virtual void loadClass( const std::string paletteClassAlias , bool global, bool lazy);
00230
00231 virtual int loadPorts(const std::string & libPathName);
00232
00234
00235 private:
00236
00237
00249 int loadPalette(const char *libraryPath, const char *mapName, const char *cFuncName, bool global, bool lazy, const char * cmptType, const char * buildPath);
00250
00251
00252
00253 #if 0 //argv
00254
00256 static char **copyArgv(char **argv);
00257
00259 static void destroyArgv(char **&argv);
00260
00263 static char **appendArgv(char **&argv, char *string);
00264
00266 static int sizeofArgv(char **);
00267 #endif // 0
00268
00269 };
00270 #endif //__COMPONENTFACTORY_H__