<commit_before>// @(#)root/base:$Id$
// Author: <NAME>   02/09/2000

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//______________________________________________________________________________
//
// TTask is a base class that can be used to build a complex tree of Tasks.
// Each TTask derived class may contain other TTasks that can be executed
// recursively, such that a complex program can be dynamically built and executed
// by invoking the services of the top level Task or one of its subtasks.
//
// Use the TTask::Add function to add a subtask to an existing TTask.
// To execute a TTask, one calls the ExecuteTask function. ExecuteTask will
// call recursively:
//     - the TTask::Exec function of the derived class
//     - TTask::ExecuteTasks to execute for each task the list of its subtasks.
// If the top level task (see example below) is added to the list of Root
// browsable objects, the tree of tasks can be visualized by the Root browser.
// The browser can be used to start a task, set break points at the beginning
// of a task or when the task has completed. At a breakpoint, data structures
// generated by the execution up this point may be inspected asyncronously
// and then the execution can be resumed by selecting the "Continue" function
// of a task.
//
// A Task may be active or inactive (controlled by TTask::SetActive).
// When a task is not active, its sub tasks are not executed.
//
// A TTask tree may be made persistent, saving the status of all the tasks.
//
// The picture in the Root browser below has been generated by executing
// the following script:
//
//{ //------------------script tasks.C---------------------------
//   TTask *aliroot  = new TTask("aliroot","ALICE reconstruction main task");
//   TTask *geominit = new TTask("geomInit","Initialize ALICE geometry");
//   TTask *matinit  = new TTask("matInit","Initialize ALICE materials");
//   TTask *physinit = new TTask("physInit","Initialize Physics processes");
//   TTask *tracker  = new TTask("tracker","Track reconstruction manager");
//   TTask *tpcrec   = new TTask("tpcrec","TPC reconstruction");
//   TTask *itsrec   = new TTask("itsrec","ITS reconstruction");
//   TTask *muonrec  = new TTask("muonRec","Muon Reconstruction");
//   TTask *phosrec  = new TTask("phosRec","Phos Reconstruction");
//   TTask *richrec  = new TTask("richRec","Rich Reconstruction");
//   TTask *trdrec   = new TTask("trdRec","TRD Reconstruction");
//   TTask *globrec  = new TTask("globRec","Global Track Reconstruction");
//   TTask *pstats   = new TTask("printStats","Print Run Statistics");
//   TTask *run      = new TTask("run","Process one run");
//   TTask *event    = new TTask("event","Process one event");
//   aliroot->Add(geominit);
//   aliroot->Add(matinit);
//   aliroot->Add(physinit);
//   aliroot->Add(run);
//   run->Add(event);
//   event->Add(tracker);
//   event->Add(muonrec);
//   event->Add(phosrec);
//   event->Add(richrec);
//   event->Add(trdrec);
//   event->Add(globrec);
//   tracker->Add(tpcrec);
//   tracker->Add(itsrec);
//   run->Add(pstats);
//
//   gROOT->GetListOfBrowsables()->Add(aliroot,"aliroot");
//   new TBrowser;
//} //-------------------------------------------------------------
//
//Begin_Html
/*
<img src="gif/tasks.gif">
*/
//End_Html

#include "Riostream.h"
#include "TTask.h"
#include "TBrowser.h"
#include "TROOT.h"
#include "TRegexp.h"

TTask *TTask::fgBeginTask  = 0;
TTask *TTask::fgBreakPoint = 0;

ClassImp(TTask)

//______________________________________________________________________________
TTask::TTask()
{
   // Default constructor invoked when reading a TTask object from a file.

   fHasExecuted = kFALSE;
   fActive      = kTRUE;
   fBreakin     = 0;
   fBreakout    = 0;
   fTasks       = 0;
}

//______________________________________________________________________________
TTask::TTask(const char* name, const char *title)
      : TNamed(name,title)
{
   // Standard constructor.

   fHasExecuted = kFALSE;
   fActive      = kTRUE;
   fBreakin     = 0;
   fBreakout    = 0;
   fTasks       = new TList();
}
//______________________________________________________________________________

TTask& TTask::operator=(const TTask& tt)	 
{	 
   //assignment operator (PLEASE DO NOT USE THIS IS WRONG)	 
   if(this!=&tt) {	 
      TNamed::operator=(tt);	 
      fTasks= 0; //<===tobe fixed	 
      fOption=tt.fOption;	 
      fBreakin=tt.fBreakin;	 
      fBreakout=tt.fBreakout;	 
      fHasExecuted=tt.fHasExecuted;	 
      fActive=tt.fActive;	 
   }	 
   return *this;	 
}	 

//______________________________________________________________________________	 //______________________________________________________________________________
TTask::TTask(const TTask &task) : TNamed(task)	 
{	 
   // Copy constructors.	 (PLEASE DO NOT USE THIS IS WRONG) 
   fTasks = new TList();	 
}	 

//______________________________________________________________________________
TTask::~TTask()
{
   // Delete a task and its subtasks.

   if (!fTasks) return;
   fTasks->Delete();
   delete fTasks;
}

//______________________________________________________________________________
void TTask::Abort()
{
   // Abort current tree of tasks.
   // After this call, the tree of tasks is ready to be executed again.
   // The application must take care of cleaning data structures created
   // by previous executions.
<commit_msg>Correct implementation of the copy constructor and assignment operator<commit_after>// @(#)root/base:$Id$
// Author: <NAME>   02/09/2000

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//______________________________________________________________________________
//
// TTask is a base class that can be used to build a complex tree of Tasks.
// Each TTask derived class may contain other TTasks that can be executed
// recursively, such that a complex program can be dynamically built and executed
// by invoking the services of the top level Task or one of its subtasks.
//
// Use the TTask::Add function to add a subtask to an existing TTask.
// To execute a TTask, one calls the ExecuteTask function. ExecuteTask will
// call recursively:
//     - the TTask::Exec function of the derived class
//     - TTask::ExecuteTasks to execute for each task the list of its subtasks.
// If the top level task (see example below) is added to the list of Root
// browsable objects, the tree of tasks can be visualized by the Root browser.
// The browser can be used to start a task, set break points at the beginning
// of a task or when the task has completed. At a breakpoint, data structures
// generated by the execution up this point may be inspected asyncronously
// and then the execution can be resumed by selecting the "Continue" function
// of a task.
//
// A Task may be active or inactive (controlled by TTask::SetActive).
// When a task is not active, its sub tasks are not executed.
//
// A TTask tree may be made persistent, saving the status of all the tasks.
//
// The picture in the Root browser below has been generated by executing
// the following script:
//
//{ //------------------script tasks.C---------------------------
//   TTask *aliroot  = new TTask("aliroot","ALICE reconstruction main task");
//   TTask *geominit = new TTask("geomInit","Initialize ALICE geometry");
//   TTask *matinit  = new TTask("matInit","Initialize ALICE materials");
//   TTask *physinit = new TTask("physInit","Initialize Physics processes");
//   TTask *tracker  = new TTask("tracker","Track reconstruction manager");
//   TTask *tpcrec   = new TTask("tpcrec","TPC reconstruction");
//   TTask *itsrec   = new TTask("itsrec","ITS reconstruction");
//   TTask *muonrec  = new TTask("muonRec","Muon Reconstruction");
//   TTask *phosrec  = new TTask("phosRec","Phos Reconstruction");
//   TTask *richrec  = new TTask("richRec","Rich Reconstruction");
//   TTask *trdrec   = new TTask("trdRec","TRD Reconstruction");
//   TTask *globrec  = new TTask("globRec","Global Track Reconstruction");
//   TTask *pstats   = new TTask("printStats","Print Run Statistics");
//   TTask *run      = new TTask("run","Process one run");
//   TTask *event    = new TTask("event","Process one event");
//   aliroot->Add(geominit);
//   aliroot->Add(matinit);
//   aliroot->Add(physinit);
//   aliroot->Add(run);
//   run->Add(event);
//   event->Add(tracker);
//   event->Add(muonrec);
//   event->Add(phosrec);
//   event->Add(richrec);
//   event->Add(trdrec);
//   event->Add(globrec);
//   tracker->Add(tpcrec);
//   tracker->Add(itsrec);
//   run->Add(pstats);
//
//   gROOT->GetListOfBrowsables()->Add(aliroot,"aliroot");
//   new TBrowser;
//} //-------------------------------------------------------------
//
//Begin_Html
/*
<img src="gif/tasks.gif">
*/
//End_Html

#include "Riostream.h"
#include "TTask.h"
#include "TBrowser.h"
#include "TROOT.h"
#include "TRegexp.h"

TTask *TTask::fgBeginTask  = 0;
TTask *TTask::fgBreakPoint = 0;

ClassImp(TTask)

//______________________________________________________________________________
TTask::TTask()
{
   // Default constructor invoked when reading a TTask object from a file.

   fHasExecuted = kFALSE;
   fActive      = kTRUE;
   fBreakin     = 0;
   fBreakout    = 0;
   fTasks       = 0;
}

//______________________________________________________________________________
TTask::TTask(const char* name, const char *title)
      : TNamed(name,title)
{
   // Standard constructor.

   fHasExecuted = kFALSE;
   fActive      = kTRUE;
   fBreakin     = 0;
   fBreakout    = 0;
   fTasks       = new TList();
}
//______________________________________________________________________________

TTask& TTask::operator=(const TTask& tt)	 
{	 
   //assignment operator (PLEASE DO NOT USE THIS IS WRONG)	 
   if(this!=&tt) {	 
      TNamed::operator=(tt);	 
      fTasks->Delete();
      TIter next(tt.fTasks);
      TTask *task;
      while ((task = (TTask*)next())) {
         fTasks->Add(new TTask(*task));
      }      
      fOption=tt.fOption;	 
      fBreakin=tt.fBreakin;	 
      fBreakout=tt.fBreakout;	 
      fHasExecuted=tt.fHasExecuted;	 
      fActive=tt.fActive;	 
   }	 
   return *this;	 
}	 

//______________________________________________________________________________	 //______________________________________________________________________________
TTask::TTask(const TTask &other) : TNamed(other)	 
{	 
   // Copy constructor. 
   fTasks = new TList();	 
   TIter next(other.fTasks);
   TTask *task;
   while ((task = (TTask*)next())) {
      fTasks->Add(new TTask(*task));
   }
   fOption = other.fOption;
   fBreakin = other.fBreakin;
   fBreakout = other.fBreakout;
   fHasExecuted = kFALSE;
   fActive = other.fActive;   
}	 

//______________________________________________________________________________
TTask::~TTask()
{
   // Delete a task and its subtasks.
   if (!fTasks) return;
   fTasks->Delete();
   delete fTasks;
}

//______________________________________________________________________________
void TTask::Abort()
{
   // Abort current tree of tasks.
   // After this call, the tree of tasks is ready to be executed again.
   // The application must take care of cleaning data structures created
   // by previous executions.

{'fraction_non_alphanumeric': 0.1564536082474227, 'fraction_numerical': 0.0038762886597938145, 'mean_word_length': 2.939571150097466, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5488537', 'n_tokens_mistral': 3423, 'n_tokens_neox': 3313, 'n_words': 1052}