From fa760045323e6b3a2e9f09e20dcbf3919aa2cf41 Mon Sep 17 00:00:00 2001 From: richterm Date: Wed, 23 Aug 2006 09:20:30 +0000 Subject: [PATCH] - added version announcement to base library - documentation added for ComponentHandler --- HLT/BASE/AliHLTComponentHandler.cxx | 25 ++- HLT/BASE/AliHLTComponentHandler.h | 161 ++++++++++++++---- .../AliHLT_C_Component_WrapperInterface.cxx | 1 + HLT/BASE/Makefile.am | 24 ++- HLT/make.dict | 2 +- 5 files changed, 170 insertions(+), 43 deletions(-) diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index fa93e7040b3..bf63982f80c 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -50,6 +50,23 @@ AliHLTComponentHandler::~AliHLTComponentHandler() UnloadLibraries(); } +int AliHLTComponentHandler::AnnounceVersion() +{ + int iResult=0; +#ifdef PACKAGE_STRING + void HLTbaseCompileInfo( char*& date, char*& time); + char* date=""; + char* time=""; + HLTbaseCompileInfo(date, time); + if (!date) date="unknown"; + if (!time) time="unknown"; + HLTInfo("%s build on %s (%s)", PACKAGE_STRING, date, time); +#else + HLTInfo("ALICE High Level Trigger (embedded AliRoot build)"); +#endif + return iResult; +} + Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample) { Int_t iResult=0; @@ -61,7 +78,7 @@ Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample) } } else { // component already registered - HLTInfo("component %s already registered, skipped", pSample->GetComponentID()); + HLTDebug("component %s already registered, skipped", pSample->GetComponentID()); iResult=-EEXIST; } } else { @@ -86,7 +103,7 @@ Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample) return iResult; } -int AliHLTComponentHandler::CreateComponent(const char* componentID, void* environ_param, int argc, const char** argv, AliHLTComponent*& component ) +int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv, int argc, const char** argv, AliHLTComponent*& component ) { int iResult=0; if (componentID) { @@ -95,7 +112,7 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* envir component=pSample->Spawn(); if (component) { HLTDebug("component \"%s\" created (%p)", componentID, component); - component->Init(&fEnvironment, environ_param, argc, argv); + component->Init(&fEnvironment, pEnv, argc, argv); } else { HLTError("can not spawn component \"%s\"", componentID); iResult=-ENOENT; @@ -173,7 +190,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) AliHLTLibHandle hLib=dlopen(libraryPath, RTLD_NOW); if (hLib) { AliHLTComponent::UnsetGlobalComponentHandler(); - HLTDebug("library %s loaded", libraryPath); + HLTInfo("library %s loaded", libraryPath); fLibraryList.push_back(hLib); vector::iterator element=fScheduleList.begin(); int iSize=fScheduleList.size(); diff --git a/HLT/BASE/AliHLTComponentHandler.h b/HLT/BASE/AliHLTComponentHandler.h index 05e4d84f947..638164d9adf 100644 --- a/HLT/BASE/AliHLTComponentHandler.h +++ b/HLT/BASE/AliHLTComponentHandler.h @@ -24,76 +24,165 @@ struct AliHLTComponent_DataType; typedef void* AliHLTLibHandle; +/** + * @class AliHLTComponentHandler + * The component handler controls all the processing components available in + * the system. It also controls the component shared libraries. + * @ingroup alihlt_component + */ class AliHLTComponentHandler : public AliHLTLogging { public: + /** standard constructor */ AliHLTComponentHandler(); + /** destructor */ virtual ~AliHLTComponentHandler(); + /** + * Set the environment for the HLT framework. + * The environment mainly consists of function pointers for the integration + * of the HLT framework into a system like the PubSub online system or + * AliRoot offline system. + * @param pEnv pointer to @ref AliHLTComponentEnvironment structure + * @return none + */ void SetEnvironment(AliHLTComponentEnvironment* pEnv); - // Load a component shared library + /** + * Load a component shared library. + * The component library needs to be loaded from the ComponentHanler in order + * to automatically register all components in the library. + * Registration is done by passing a sample object of the component to the + * handler. The object has to be valid during the whole runtime and should + * thus be a global object which is ONLY used for the purpose of registration. + * This also ensures automatically registration at library load time. + * @param libraryPath const char string containing the library name/path + * @return 0 if succeeded, neg. error code if failed + */ int LoadLibrary( const char* libraryPath ); + + /** + * Unload a component shared library. + * All components will be de-registered. + * @param libraryPath library name as specified to @ref LoadLibrary + * @return 0 if succeeded, neg. error code if failed + */ int UnloadLibrary( const char* libraryPath ); - /* Component registration funcions - * registration is done by passing a sample object of the component to the handler - * the object has to be valid during the whole runtime and should thus be a global object + /** + * Schedule a component for registration. + * Full registration will be done after successfull loading of the shared + * library. + * @param pSample a sample object of the component + * @return neg. error code if failed */ - // Schedule a component for registration, full registration will be done - // after successfull loading of the shared library int ScheduleRegister(AliHLTComponent* pSample ); - // Register a component with the list of available components + /** + * Register a component. + * Registration is done by passing a sample object of the component to the + * handler. The object has to be valid during the whole runtime and should + * thus be a global object which is ONLY used for the purpose of registration. + * @param pSample a sample object of the component + * @return neg. error code if failed + */ int RegisterComponent(AliHLTComponent* pSample ); - int DeregisterComponent( const char* componentID ); - - // Find the ID of a component with the given output data - // prevType can be used to iterate if there are multiple components with the same output data type. - const char* FindComponentType( AliHLTComponent_DataType, const char* prevType = NULL ) { return NULL;} - // Create a component of the given name - int CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponent*& component ); - int CreateComponent( const char* componentType, void* environ_param, AliHLTComponent*& component ) { - return CreateComponent( componentType, environ_param, 0, NULL, component ); - } + /** + * Deregister a component. + * @param componentID ID of the component + * @return neg. error code if failed + */ + int DeregisterComponent( const char* componentID ); - /* print registered components to stdout + /** + * Find the ID of a component with the given output data. + * @param dtype data type descriptor + * @param prevType can be used to iterate if there are multiple components + * with the same output data type. + * @return component id + */ + //const char* FindComponentType( AliHLTComponent_DataType dtype, + // const char* prevType = NULL ) + // { return NULL;} + + /** + * Create a component of the given name (ID). + * @param componentID ID of the component to create + * @param pEnv environment for the component + * @param argc number of arguments in @ref argv + * @param argv argument array like in main() + * @param component reference to receive the create component instance + * @return component pointer in @ref component, neg. error code if failed + */ + int CreateComponent( const char* componentID, void* pEnv, + int argc, const char** argv, AliHLTComponent*& component ); + + /** + * Create a component of the given name (ID). + * Introduced for backward compatibility. + * @param componentID ID of the component to create + * @param pEnv environment for the component + * @param component reference to receive the create component instance + * @return component pointer in @ref component, neg. error code if failed + */ + int CreateComponent( const char* componentID, void* pEnv, + AliHLTComponent*& component ) + { + return CreateComponent( componentID, pEnv, 0, NULL, component ); + } + + /** + * Print registered components to stdout. + * @return none */ void List(); + + /** + * Announce version and compilation info of the base library. + */ + int AnnounceVersion(); + protected: private: - /* find a component - return index - */ + /** + * Find a component. + * @param componentID ID of the component to find + * @return index, neg. error code if failed + */ int FindComponentIndex(const char* componentID); - /* find a component - return descriptor - */ + /** + * Find a component. + * @param componentID ID of the component to find + * @return descriptor + */ AliHLTComponent* FindComponent(const char* componentID); + /** + * Insert component to the list + * @param pSample sample object of the component + * @return neg. error code if failed + */ int InsertComponent(AliHLTComponent* pSample); - // close all libraries + /** + * Close all libraries. + * @return neg. error code if failed + */ int UnloadLibraries(); - /* list of registered components - */ + /** list of registered components */ vector fComponentList; - - /* list of scheduled components - */ + /** list of scheduled components */ vector fScheduleList; - - /* list of libraries - */ + /** list of libraries */ vector fLibraryList; - + /** running environment for the component */ AliHLTComponentEnvironment fEnvironment; - ClassDef(AliHLTComponentHandler, 0) + ClassDef(AliHLTComponentHandler, 0); - }; +}; #endif diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index f8d477dca94..14a5191298d 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -44,6 +44,7 @@ int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ ) if ( !gComponentHandler_C ) return EFAULT; gComponentHandler_C->SetEnvironment( environ ); + gComponentHandler_C->AnnounceVersion(); return 0; } diff --git a/HLT/BASE/Makefile.am b/HLT/BASE/Makefile.am index 4653e2b53a2..dc9c950e41e 100644 --- a/HLT/BASE/Makefile.am +++ b/HLT/BASE/Makefile.am @@ -3,7 +3,7 @@ MODULE = HLTbase -AM_CPPFLAGS = +AM_CPPFLAGS = -DMODULE=$(MODULE) # library definition lib_LTLIBRARIES = libHLTbase.la @@ -43,10 +43,30 @@ noinst_HEADERS = AliHLTStdIncludes.h # version info for the library libHLTbase_la_LDFLAGS = -version-info 1:0:0 +# automatic generation of data and time of library build +COMPILE_INFO = HLTBaseCompileInfo.cxx + # set the file name for the generated root dictionary DICTCPP = HLTbase-DICT.cxx -nodist_libHLTbase_la_SOURCES = $(DICTCPP) +nodist_libHLTbase_la_SOURCES = $(COMPILE_INFO) \ + $(DICTCPP) CLEANFILES = include $(top_srcdir)/make.dict + +$(COMPILE_INFO): $(libHLTbase_la_SOURCES) $(pkginclude_HEADERS) $(noinst_HEADERS) Makefile.am + @echo '//automatically generated compilation info' > $@ + @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ + @echo '//add changes in Makefile.am' >> $@ + @echo 'void $(MODULE)CompileInfo( char*& date, char*& time)' >> $@ + @echo '{date=__DATE__; time=__TIME__; return;}' >> $@ + +# @echo '//automatically generated compilation info' > $@ +# @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ +# @echo '//add changes in Makefile.am' >> $@ +# @echo 'void __$(MODULE)_compile_info(const char** pDate, const char** pDate)' >> $@ +# @echo '{' >> $@ +# @echo 'if (pDate) *pDate=__DATE__;' >> $@ +# @echo 'if (pTime) *pTime=__TIME__;' >> $@ +# @echo '}' >> $@ diff --git a/HLT/make.dict b/HLT/make.dict index edfb90cb3e8..f3161b442b7 100644 --- a/HLT/make.dict +++ b/HLT/make.dict @@ -26,7 +26,7 @@ $(DICTCPP): $(DICTHEADERS:%=$(srcdir)/%) $(DICTDEF) $(DICTDEF): Makefile.am @echo '//automatically generated ROOT DICT definition' > $@ @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ - @echo '//add further class definitions to the DICTHEADERS variable in Makefile.am' >> $@ + @echo '//add further class definitions to the CLASS_HDRS variable in Makefile.am' >> $@ @echo '#ifdef __CINT__' >> $@ @echo '#pragma link off all globals;' >> $@ @echo '#pragma link off all classes;' >> $@ -- 2.39.3