]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRIGGER/AliTrigConnector.cxx
Coverity 18358 solved by non-implemented private copy constructor and assignment...
[u/mrichter/AliRoot.git] / TRIGGER / AliTrigConnector.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 /* $Id$ */
17 // Author: Andrei Gheata, 28/07/2009
18
19 //==============================================================================
20 //   AliTrigConnector - General connector class. A connector links a feeder
21 // device output to a number of other device inputs (clients). It transmits the 
22 // signal to all clients and calls their SetInput() method.
23 //==============================================================================
24
25 #include "AliTrigConnector.h"
26
27 #include <TObjArray.h>
28 #include <TClass.h>
29
30 #include "AliTrigDevice.h"
31 #include "AliTrigEvent.h"
32
33
34 ClassImp(AliTrigConnector)
35
36 //______________________________________________________________________________
37 AliTrigConnector::AliTrigConnector(const AliTrigConnector &other)
38                  :TNamed(other),
39                   fFeeder(other.fFeeder),
40                   fOutput(other.fOutput),
41                   fNclients(other.fNclients),
42                   fArraySize(other.fArraySize),
43                   fInputs(0),
44                   fDevices(0)
45 {
46 // Copy ctor.
47   if (fArraySize && other.fInputs) {
48     fInputs = new Int_t[fArraySize];
49     memcpy(fInputs, other.fInputs, fNclients*sizeof(Int_t));
50     fDevices = new TObjArray(fArraySize);
51     for (Int_t i=0; i<fNclients; i++) fDevices->Add(other.fDevices->At(i));
52   }   
53 }                        
54
55 //______________________________________________________________________________
56 AliTrigConnector::~AliTrigConnector()
57 {
58 // Destructor.
59   if (fInputs) delete [] fInputs;
60   if (fDevices) delete fDevices;
61 }
62
63 //______________________________________________________________________________
64 void AliTrigConnector::Connect(AliTrigDevice *client, Int_t input)
65 {
66 // Adds the device and its input to the list of clients.
67   // Loop array of inputs to check if this input is already connected.
68   for (Int_t i=0; i<fNclients; i++) {
69     if (fInputs[i]==input && fDevices->At(i)==client) {
70       Info("Connect", "Output #%d of device %s already connected to input #%d of device%s",
71            fOutput, fFeeder->GetName(), input, client->GetName());
72       return;
73     } 
74   }
75 //  if (strcmp(client->GetInputType(fFeeder->GetOutputType(fOutput))) {
76 //    Fatal("Cannot connect output slot #%d (type %s) of device %s to input slot #%d of device %s. Aborting",
77 //            fOutput, fFeeder->GetInputType(fOutput), fFeeder->GetName(), input, client->GetName());
78 //  }          
79   if (!fArraySize) {
80     fArraySize = 8;
81     fInputs = new Int_t[fArraySize];
82     fDevices = new TObjArray(fArraySize);
83   }
84   if (fNclients >= fArraySize) {
85     fArraySize *= 2;
86     Int_t *array = new Int_t[fArraySize];
87     memcpy(array, fInputs, fNclients*sizeof(Int_t));
88     delete [] fInputs;
89     fInputs = array;
90   }
91   fInputs[fNclients] = input;
92   fDevices->Add(client);
93   fNclients++;
94 }    
95
96 //______________________________________________________________________________
97 void AliTrigConnector::Print(Option_t */*option*/) const
98 {
99 // Print info about this connector.
100   Printf("   feeder: output #%d of device %s\n", fOutput, fFeeder->GetName());
101   Printf("   client devices:\n");
102   for (Int_t i=0; i<fNclients; i++) Printf("      #%d %s\n", fInputs[i], fDevices->At(i)->GetName());
103 }
104
105 //______________________________________________________________________________
106 Bool_t AliTrigConnector::Transmit(Bool_t value)
107 {
108 // Transmit Boolean signal from feeder to all clients.
109   AliTrigDevice *nextclient;
110   Bool_t transmit = kTRUE;
111   for (Int_t i=0; i<fNclients; i++) {
112     nextclient = (AliTrigDevice*)fDevices->At(i);
113     Bool_t done = nextclient->SetInputValue(fInputs[i], value);
114     if (!done) {
115       Error("Transmit", "Connector %s: Boolean value cannot be transmitted to input %d of device %s",
116             GetName(), i,  nextclient->GetName());
117       transmit = kFALSE;      
118     }
119   }
120   return transmit;
121 }
122
123 //______________________________________________________________________________
124 Bool_t AliTrigConnector::Transmit(AliTrigEvent *event)
125 {
126 // Transmit Boolean signal from feeder to all clients.
127   AliTrigDevice *nextclient;
128   Bool_t transmit = kTRUE;
129   for (Int_t i=0; i<fNclients; i++) {
130     nextclient = (AliTrigDevice*)fDevices->At(i);
131     Bool_t done = nextclient->SetInputValue(fInputs[i], event);
132     if (!done) {
133       Error("Transmit", "Connector %s: Event cannot be transmitted to input %d of device %s",
134             GetName(), i,  nextclient->GetName());
135       transmit = kFALSE;      
136     }
137   }
138   return transmit;    
139 }