1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 /////////////////////////////////////////////////////////////////////////
16 // ALICE MODULE INFORMATION CLASS //
17 // Author: Mayeul ROUSSELET //
18 // e-mail: Mayeul.Rousselet@cern.ch //
19 // Last update:26/08/2003 //
20 /////////////////////////////////////////////////////////////////////////
24 #include "AliModuleInfo.h"
26 ClassImp(AliModuleInfo)
28 //_____________________________________________________________
29 AliModuleInfo::AliModuleInfo(int n)
34 fEnabled = new Bool_t[n];
38 //_____________________________________________________________
39 AliModuleInfo::AliModuleInfo(const AliModuleInfo& rh)
42 fName = new char*[rh.fNb];
43 fId = new Int_t[rh.fNb];
44 fEnabled = new Bool_t[rh.fNb];
47 for (Int_t i=0; i<fNb; i++) {
48 strcpy(fName[i],rh.fName[i]);
50 fEnabled[i] = rh.fEnabled[i];
54 //_____________________________________________________________
55 AliModuleInfo& AliModuleInfo::operator = (const AliModuleInfo& rh)
57 // Assignment operator
58 fName = new char*[rh.fNb];
59 fId = new Int_t[rh.fNb];
60 fEnabled = new Bool_t[rh.fNb];
63 for (Int_t i=0; i<fNb; i++) {
64 strcpy(fName[i],rh.fName[i]);
66 fEnabled[i] = rh.fEnabled[i];
71 //_____________________________________________________________
72 AliModuleInfo::~AliModuleInfo(){
79 //_____________________________________________________________
80 void AliModuleInfo::Add(const char *name,Int_t i)
82 // Adds new module to the list
83 fName[fNb]=new char[strlen(name)];
84 strcpy(fName[fNb],name);
90 //_____________________________________________________________
91 void AliModuleInfo::SetId(const char *name,Int_t id)
93 // Sets the Id of the module "name"
95 while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++;
96 if(strcmp(name,fName[i])==0) fId[i]=id;
99 //_____________________________________________________________
100 const char* AliModuleInfo::Name(Int_t id) const
102 // Sets the name of module id
104 while((fId[i]!=id)&&(i!=fNb)) i++;
105 if(fId[i]==id) return fName[i];
109 //_____________________________________________________________
110 Int_t AliModuleInfo::Id(const char *name) const
112 // Return the id of module "name"
114 while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++;
115 if(strcmp(name,fName[i])==0) return fId[i];
119 //_____________________________________________________________
120 Bool_t AliModuleInfo::IsEnabled(Int_t id) const
122 //return the current status of the detector
124 while((fId[i]!=id)&&(i!=fNb)) i++;
125 if(fId[i]==id) return fEnabled[i];
129 //_____________________________________________________________
130 void AliModuleInfo::Disable(Int_t id)
132 //Disable the detector
134 while((fId[i]!=id)&&(i!=fNb)) i++;
135 if(fId[i]==id) fEnabled[i]=kFALSE;
138 //_____________________________________________________________
139 void AliModuleInfo::Enable(Int_t id)
141 //Enable the detector
143 while((fId[i]!=id)&&(i!=fNb)) i++;
144 if(fId[i]==id) fEnabled[i]=kTRUE;
147 //_____________________________________________________________
148 void AliModuleInfo::Print() const
150 // Prints the content of all arrays
151 printf("\n***Modules***");
152 printf("\nName\tId\tEnabled");
153 for(Int_t i=0;i<fNb;i++){
154 printf("\n%s",fName[i]);
155 printf("\t%d",fId[i]);
156 printf("\t%d",fEnabled[i]);