]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Modifications of the activation scheme for module agents and
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 May 2009 10:36:05 +0000 (10:36 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 May 2009 10:36:05 +0000 (10:36 +0000)
the printout at component library loading

In order to activate only the agents of the library being loaded,
a check for library name and module id is applied. Works for
component libraries with agents following the naming scheme
libAliHLT<MOD>.so

Info messages have been adjusted to the needs in order to reduce
output. The full message is now only printed if the library
contains detailed build information from the HLT build system.

HLT/BASE/AliHLTComponentHandler.cxx
HLT/BASE/AliHLTComponentHandler.h
HLT/BASE/AliHLTModuleAgent.cxx
HLT/BASE/AliHLTModuleAgent.h

index 31711a878e715f472637de10dd31046cd9351b6a..06e09830e513e5c14775802ab0643dcf0a1c8cfd 100644 (file)
@@ -348,8 +348,12 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
   // see header file for class documentation
   int iResult=0;
   if (libraryPath) {
-    // first activate all agents which are already loaded
-    if (bActivateAgents) ActivateAgents();
+    TString libName=libraryPath;
+    int slash=-1;
+    while ((slash=libName.Index("/"))>=0) {
+      libName=libName.Remove(0, slash+1);
+    }
+    libName.ReplaceAll(".so","");
 
     // set the global component handler for static component registration
     AliHLTComponent::SetGlobalComponentHandler(this);
@@ -406,19 +410,18 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
       hLib.fMode=fLibraryMode;
       fLibraryList.insert(fLibraryList.begin(), hLib);
       if (!phSearch) {
-      HLTImportant("library %s loaded (%s%s)", libraryPath, hLib.fMode==kStatic?"persistent, ":"", loadtype);
       typedef void (*CompileInfo)(const char*& date, const char*& time);
       CompileInfo fctInfo=(CompileInfo)FindSymbol(libraryPath, "CompileInfo");
+      const char* date="";
+      const char* time="";
+      const char* buildOn="";
       if (fctInfo) {
-       const char* date="";
-       const char* time="";
+       buildOn=" build on ";
        (*fctInfo)(date, time);
        if (!date) date="unknown";
        if (!time) time="unknown";
-       HLTImportant("build on %s (%s)", date, time);
-      } else {
-       HLTImportant("no build info available (possible AliRoot embedded build)");
       }
+      HLTImportant("using %s plugin%s%s %s (%s%s)", libraryPath, buildOn, date, time, hLib.fMode==kStatic?"persistent, ":"", loadtype);
       }
 
       // static registration of components when library is loaded
@@ -440,7 +443,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
     if (iResult>=0) {
       // alternative dynamic registration by library agents
       // !!! has to be done after UnsetGlobalComponentHandler
-      if (bActivateAgents) ActivateAgents();
+      if (bActivateAgents) ActivateAgents(libName.Data());
     }
 
   } else {
@@ -603,28 +606,43 @@ int AliHLTComponentHandler::RegisterScheduledComponents()
   return iResult;
 }
 
-int AliHLTComponentHandler::ActivateAgents(const AliHLTModuleAgent** blackList, int size)
+int AliHLTComponentHandler::ActivateAgents(const char* library, const char* blackList)
 {
   // see header file for class documentation
   int iResult=0;
-  AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
-  while (pAgent && iResult>=0) {
-    if (blackList) {
-      int i=0;
-      for (; i<size; i++) {
-       if (blackList[i]==pAgent) break;
+  vector<AliHLTModuleAgent*> agents;
+  for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); 
+       pAgent && iResult>=0;
+       pAgent=AliHLTModuleAgent::GetNextAgent()) {
+
+    // check if we found the agent for the specified library
+    if (library) {
+      TString check="libAliHLT"; check+=pAgent->GetModuleId();
+      if (check.CompareTo(library)==0) {
+       agents.clear();
+       agents.push_back(pAgent);
+       break;
       }
-      if (i<size) {
-       // this agent was in the list
-       pAgent=AliHLTModuleAgent::GetNextAgent();
-       continue;
+    }
+
+    // check if the current agent is in the black list
+    if (blackList) {
+      char* found=strstr(blackList, pAgent->GetModuleId());
+      if (found) {
+       found+=strlen(pAgent->GetModuleId());
+       // skip this agent as it is in the blacklist
+       if (*found==0 or *found==' ') continue;
       }
     }
+    agents.push_back(pAgent);
+  }
 
-    pAgent->ActivateComponentHandler(this);
-    pAgent=AliHLTModuleAgent::GetNextAgent();
+  for (vector<AliHLTModuleAgent*>::iterator element=agents.begin();
+       element!=agents.end(); element++) {
+    (*element)->ActivateComponentHandler(this);
   }
-  return iResult;
+
+  return agents.size();
 }
 
 int AliHLTComponentHandler::DeleteOwnedComponents()
index 826ba585b7c468946cd3a54e120b08d84fa510f4..7cc7722ef9a2823a9b7b4aaa1941b9ac72a28da3 100644 (file)
@@ -295,10 +295,15 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * each agent with this component handler. During activation, the
    * dynamic component registration is carried out by the agents version
    * of @ref AliHLTModuleAgent::RegisterComponents
-   * @param blackList     array of agents which should be excluded
-   * @param size          array size
-   */
-  int ActivateAgents(const AliHLTModuleAgent** blackList=NULL, int size=0);
+   *
+   * Agents are identified by an id which is a string containing the
+   * module name. Libraries follow the naming scheme libAliHLT<MOD>.so
+   * If the library name is provided and the specific agent found in the
+   * list, only that one is activated. All pending agents otherwize.
+   * @param library       library to activate the agent for
+   * @param blackList     blank separated list of module ids
+   */
+  int ActivateAgents(const char* library=NULL, const char* blackList=NULL);
 
   /**
    * Compound descriptor for component libraries
index 64505145e9d93961f432550336fcddc2668f16c8..9bbc3f81e8d972b9ba8ac3f5a57631f3d8dec7b5 100644 (file)
@@ -202,6 +202,21 @@ AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
   return fgCurrent;
 }
 
+string AliHLTModuleAgent::GetAgentIds()
+{
+  // see header file for function documentation
+  string ids;
+  ids.clear();
+  for (AliHLTModuleAgent* pCurrent=fgAnchor;
+       pCurrent;
+       pCurrent=pCurrent->fpNext) {
+    if (ids.size()>0) ids+=" ";
+    ids+=pCurrent->GetModuleId();
+  }
+
+  return ids;
+}
+
 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
 {
   // see header file for function documentation
index 0b74fca461bd4f736f450ef9927b484c2935a267..a711275e41f217e76290992b44291d563978b574 100644 (file)
@@ -20,6 +20,7 @@
 // or
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
 
+#include <string>
 #include <TObject.h>
 #include <TList.h>
 #include <TString.h>
@@ -141,6 +142,11 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
    */
   static AliHLTModuleAgent* GetNextAgent();
 
+  /**
+   * Get string of blank separated Module Ids
+   */
+  static string GetAgentIds();
+
   /**
    * Activate a component handler for this agent.
    * The @ref RegisterComponents method will be called in order to allow