]>
Commit | Line | Data |
---|---|---|
7bb7ac14 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | ///////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | #include <string.h> | |
23 | ||
24 | #include "AliModuleInfo.h" | |
25 | ||
26 | ClassImp(AliModuleInfo); | |
27 | ||
28 | //_____________________________________________________________ | |
29 | AliModuleInfo::AliModuleInfo(int n) | |
30 | { | |
31 | // Constructor | |
32 | fName = new char*[n]; | |
33 | fId = new Int_t[n]; | |
34 | fEnabled = new Bool_t[n]; | |
35 | fNb = 0; | |
36 | } | |
37 | ||
38 | //_____________________________________________________________ | |
39 | AliModuleInfo::AliModuleInfo(const AliModuleInfo& rh) | |
40 | { | |
41 | // Copy constructor | |
42 | fName = new char*[rh.fNb]; | |
43 | fId = new Int_t[rh.fNb]; | |
44 | fEnabled = new Bool_t[rh.fNb]; | |
45 | fNb = rh.fNb; | |
46 | ||
47 | for (Int_t i=0; i<fNb; i++) { | |
48 | strcpy(fName[i],rh.fName[i]); | |
49 | fId[i] = rh.fId[i]; | |
50 | fEnabled[i] = rh.fEnabled[i]; | |
51 | } | |
52 | } | |
53 | ||
54 | //_____________________________________________________________ | |
55 | AliModuleInfo& AliModuleInfo::operator = (const AliModuleInfo& rh) | |
56 | { | |
57 | // Assignment operator | |
58 | fName = new char*[rh.fNb]; | |
59 | fId = new Int_t[rh.fNb]; | |
60 | fEnabled = new Bool_t[rh.fNb]; | |
61 | fNb = rh.fNb; | |
62 | ||
63 | for (Int_t i=0; i<fNb; i++) { | |
64 | strcpy(fName[i],rh.fName[i]); | |
65 | fId[i] = rh.fId[i]; | |
66 | fEnabled[i] = rh.fEnabled[i]; | |
67 | } | |
68 | return *this; | |
69 | } | |
70 | ||
71 | //_____________________________________________________________ | |
72 | AliModuleInfo::~AliModuleInfo(){ | |
73 | // Destructor | |
74 | delete [] fName; | |
75 | delete [] fId; | |
76 | delete [] fEnabled; | |
77 | } | |
78 | ||
79 | //_____________________________________________________________ | |
80 | void AliModuleInfo::Add(const char *name,Int_t i) | |
81 | { | |
82 | // Adds new module to the list | |
83 | fName[fNb]=new char[strlen(name)]; | |
84 | strcpy(fName[fNb],name); | |
85 | fId[fNb]=i; | |
86 | fEnabled[fNb]=kTRUE; | |
87 | fNb++; | |
88 | } | |
89 | ||
90 | //_____________________________________________________________ | |
91 | void AliModuleInfo::SetId(const char *name,Int_t id) | |
92 | { | |
93 | // Sets the Id of the module "name" | |
94 | Int_t i=0; | |
95 | while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++; | |
96 | if(strcmp(name,fName[i])==0) fId[i]=id; | |
97 | } | |
98 | ||
99 | //_____________________________________________________________ | |
100 | const char* AliModuleInfo::Name(Int_t id) const | |
101 | { | |
102 | // Sets the name of module id | |
103 | Int_t i=0; | |
104 | while((fId[i]!=id)&&(i!=fNb)) i++; | |
105 | if(fId[i]==id) return fName[i]; | |
106 | return 0; | |
107 | } | |
108 | ||
109 | //_____________________________________________________________ | |
110 | Int_t AliModuleInfo::Id(const char *name) const | |
111 | { | |
112 | // Return the id of module "name" | |
113 | Int_t i=0; | |
114 | while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++; | |
115 | if(strcmp(name,fName[i])==0) return fId[i]; | |
116 | return -1; | |
117 | } | |
118 | ||
119 | //_____________________________________________________________ | |
120 | Bool_t AliModuleInfo::IsEnabled(Int_t id) const | |
121 | { | |
122 | //return the current status of the detector | |
123 | Int_t i=0; | |
124 | while((fId[i]!=id)&&(i!=fNb)) i++; | |
125 | if(fId[i]==id) return fEnabled[i]; | |
126 | return kFALSE; | |
127 | } | |
128 | ||
129 | //_____________________________________________________________ | |
130 | void AliModuleInfo::Disable(Int_t id) | |
131 | { | |
132 | //Disable the detector | |
133 | Int_t i=0; | |
134 | while((fId[i]!=id)&&(i!=fNb)) i++; | |
135 | if(fId[i]==id) fEnabled[i]=kFALSE; | |
136 | } | |
137 | ||
138 | //_____________________________________________________________ | |
139 | void AliModuleInfo::Enable(Int_t id) | |
140 | { | |
141 | //Enable the detector | |
142 | Int_t i=0; | |
143 | while((fId[i]!=id)&&(i!=fNb)) i++; | |
144 | if(fId[i]==id) fEnabled[i]=kTRUE; | |
145 | } | |
146 | ||
147 | //_____________________________________________________________ | |
148 | void AliModuleInfo::Print() const | |
149 | { | |
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]); | |
157 | } | |
158 | } | |
159 | ||
160 |