]>
Commit | Line | Data |
---|---|---|
9e1ceb13 | 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 | ///////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // class AliCDBRunRange // | |
19 | // defines the run validity range of the object: // | |
20 | // [fFirstRun, fLastRun] // | |
21 | // // | |
22 | ///////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliCDBRunRange.h" | |
25 | ||
26 | #include "AliLog.h" | |
27 | ||
28 | ClassImp(AliCDBRunRange) | |
29 | ||
30 | //___________________________________________________________________________ | |
31 | AliCDBRunRange::AliCDBRunRange(): | |
5078a13f | 32 | fFirstRun(-1), |
33 | fLastRun(-1) | |
9e1ceb13 | 34 | { |
5078a13f | 35 | // constructor |
9e1ceb13 | 36 | |
37 | } | |
38 | ||
39 | //___________________________________________________________________________ | |
40 | AliCDBRunRange::AliCDBRunRange(Int_t firstRun, Int_t lastRun): | |
5078a13f | 41 | fFirstRun(firstRun), |
42 | fLastRun(lastRun) | |
9e1ceb13 | 43 | { |
5078a13f | 44 | // constructor |
9e1ceb13 | 45 | |
46 | } | |
47 | ||
48 | //___________________________________________________________________________ | |
49 | AliCDBRunRange::~AliCDBRunRange() { | |
5078a13f | 50 | // destructor |
9e1ceb13 | 51 | |
52 | } | |
53 | ||
54 | //___________________________________________________________________________ | |
55 | Bool_t AliCDBRunRange::Overlaps(const AliCDBRunRange& other) const { | |
5078a13f | 56 | // check if this runRange overlaps other runRange |
57 | ||
58 | if (!(IsValid() && other.IsValid())) { | |
59 | AliError("Comparing invalid run ranges!"); | |
60 | return kFALSE; | |
61 | } | |
62 | ||
63 | if (IsAnyRange() || other.IsAnyRange()) { | |
64 | AliError("Comparing unspecified ranges!"); | |
65 | return kFALSE; | |
66 | } | |
67 | ||
68 | return ((fFirstRun < other.fFirstRun && other.fFirstRun <= fLastRun) | |
69 | || (other.fFirstRun <= fFirstRun && fFirstRun <= other.fLastRun)); | |
9e1ceb13 | 70 | } |
71 | ||
72 | //___________________________________________________________________________ | |
73 | Bool_t AliCDBRunRange::Comprises(const AliCDBRunRange& other) const { | |
5078a13f | 74 | // check if this runRange contains other runRange |
75 | ||
76 | if (!(IsValid() && other.IsValid())) { | |
77 | AliError("Comparing invalid run ranges!"); | |
78 | return kFALSE; | |
79 | } | |
80 | ||
81 | if (IsAnyRange()) { | |
82 | return kTRUE; | |
83 | } | |
84 | ||
85 | return fFirstRun <= other.fFirstRun && other.fFirstRun <= fLastRun | |
86 | && fFirstRun <= other.fLastRun && other.fLastRun <= fLastRun; | |
9e1ceb13 | 87 | } |
88 | ||
89 | //___________________________________________________________________________ | |
90 | Bool_t AliCDBRunRange::IsEqual(const TObject* obj) const { | |
5078a13f | 91 | // check if this runRange is equal to other runRange |
92 | ||
93 | if (this == obj) { | |
94 | return kTRUE; | |
95 | } | |
96 | ||
97 | if (AliCDBRunRange::Class() != obj->IsA()) { | |
98 | return kFALSE; | |
99 | } | |
100 | AliCDBRunRange* other = (AliCDBRunRange*) obj; | |
101 | return fFirstRun == other->fFirstRun && fLastRun == other->fLastRun; | |
9e1ceb13 | 102 | } |
103 | ||
104 | //___________________________________________________________________________ | |
105 | Bool_t AliCDBRunRange::IsValid() const { | |
5078a13f | 106 | // validity check |
9e1ceb13 | 107 | |
5078a13f | 108 | if (fFirstRun < 0 && fLastRun < 0) { |
109 | return kTRUE; | |
110 | } | |
9e1ceb13 | 111 | |
5078a13f | 112 | if (fFirstRun >= 0 && fLastRun >= fFirstRun) { |
113 | return kTRUE; | |
114 | } | |
9e1ceb13 | 115 | |
5078a13f | 116 | return kFALSE; |
9e1ceb13 | 117 | } |
118 | ||
119 |