AliHLTConfigurationHandler::AliHLTConfigurationHandler()
: AliHLTLogging()
, fgListConfigurations()
+ , fgListScheduledRegistrations()
, fFlags(0)
{
// see header file for class documentation
fgListConfigurations.Remove(lnk);
delete pConf;
}
+ fgListScheduledRegistrations.Delete();
}
AliHLTConfigurationHandler* AliHLTConfigurationHandler::fgpInstance=NULL;
// see header file for function documentation
int iResult=0;
if (pConf) {
- AliHLTConfiguration* pExisting=NULL;
- if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
- AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
- fgListConfigurations.Add(pClone);
- HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
-
- // mark all configurations with unresolved dependencies for re-evaluation
- TObjLink* lnk=fgListConfigurations.FirstLink();
- while (lnk) {
- AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
- if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
- pSrc->InvalidateSources();
- }
- lnk=lnk->Next();
- }
- } else {
- if ((*pExisting)!=(*pConf)) {
- iResult=-EEXIST;
- HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+ AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
+ if (IsActive()) {
+ AliHLTConfiguration* pExisting=NULL;
+ if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
+ fgListConfigurations.Add(pClone);
+ HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
+
+ // mark all configurations with unresolved dependencies for re-evaluation
+ TObjLink* lnk=fgListConfigurations.FirstLink();
+ while (lnk) {
+ AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
+ if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
+ pSrc->InvalidateSources();
+ }
+ lnk=lnk->Next();
+ }
+ } else {
+ if ((*pExisting)!=(*pConf)) {
+ iResult=-EEXIST;
+ HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+ }
}
+ } else if (IsScheduling()) {
+ fgListScheduledRegistrations.Add(pClone);
}
} else {
iResult=-EINVAL;
return pConf;
}
+int AliHLTConfigurationHandler::Deactivate(bool schedule) {
+ // see header file for function documentation
+ fFlags|=kInactive;
+ if (schedule)
+ fFlags|=kScheduling;
+ return 0;
+}
+
+int AliHLTConfigurationHandler::Activate() {
+ // see header file for function documentation
+ fFlags&=~kInactive;
+ if (IsScheduling()) {
+ fFlags&=~kScheduling;
+ TObjLink *lnk = fgListScheduledRegistrations.FirstLink();
+ while (lnk) {
+ RegisterConfiguration((AliHLTConfiguration*)lnk->GetObject());
+ lnk = lnk->Next();
+ }
+ ClearScheduledRegistrations();
+ }
+ return 0;
+}
+
int AliHLTConfigurationHandler::MissedRegistration(const char* name)
{
/// indicate a failed attempt to register because of unavailable global instance
* @brief Global Handling of HLT configurations.
*
* This class implements the global handling of @ref AliHLTConfiguration objects.
- * It is a list of all configuartion descriptor currently available in the system.
- * Each @ref AliHLTConfiguration object is registerd automatically with the
+ * It is a list of all configuration descriptors currently available in the system.
+ * Each @ref AliHLTConfiguration object is registered automatically with the
* handler and put into the list.
*
* @note This class is only used for the @ref alihlt_system.
/**
* Get the instance of the global singleton.
- * Does not create the global instance. Returns NULL if status of the global
- * instance is 'inactive'.
+ * Does not create the global instance.
*/
static AliHLTConfigurationHandler* Instance() {
- if (!fgpInstance || !fgpInstance->IsActive()) return NULL;
+ if (!fgpInstance) return NULL;
return fgpInstance;
}
/*****************************************************************************
- * activation, effects the availability of the global singleton via
- * AliHLTConfigurationHandler::Instance()
+ * activation, affects if the handler will accept new registrations
*/
- /// deactivate the handler, AliHLTConfiguration objects will not register
- int Deactivate() {fFlags|=kInactive; return 0;}
+ /**
+ * Deactivate the handler, AliHLTConfiguration objects will not register
+ * @param schedule Store and schedule registrations pending reactivation
+ */
+ int Deactivate(bool schedule=false);
- /// activate the handler, AliHLTConfiguration objects will register again
- int Activate() {fFlags&=~kInactive; return 0;}
+ /**
+ * Activate the handler, AliHLTConfiguration objects will register again
+ */
+ int Activate();
/// check if active
bool IsActive() const {return (fFlags&kInactive)==0;}
+
+ /// check if scheduling
+ bool IsScheduling() const {return (fFlags&kScheduling)>0;}
+
+ /// clear scheduled registrations
+ void ClearScheduledRegistrations() {fgListScheduledRegistrations.Delete();}
/// signal a missed registration
static int MissedRegistration(const char* name=NULL);
private:
enum {
- kInactive = 0x1
+ kInactive = 0x1,
+ kScheduling = 0x2
};
/** the list of registered configurations */
TList fgListConfigurations; // see above
+
+ /** list of configurations scheduled to be registered */
+ TList fgListScheduledRegistrations; // see above
/** status of the handler */
unsigned fFlags; //! transient