1 | // -*- C++ -*-
|
---|
2 | ///////////////////////////////////////////////////////////////////////////////
|
---|
3 | // File: reference.h //
|
---|
4 | // Description: header file for checkxor management (Creference class) //
|
---|
5 | // This file is part of the SISCone project. //
|
---|
6 | // For more details, see http://projects.hepforge.org/siscone //
|
---|
7 | // //
|
---|
8 | // Copyright (c) 2006 Gavin Salam and Gregory Soyez //
|
---|
9 | // //
|
---|
10 | // This program is free software; you can redistribute it and/or modify //
|
---|
11 | // it under the terms of the GNU General Public License as published by //
|
---|
12 | // the Free Software Foundation; either version 2 of the License, or //
|
---|
13 | // (at your option) any later version. //
|
---|
14 | // //
|
---|
15 | // This program is distributed in the hope that it will be useful, //
|
---|
16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
---|
17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
---|
18 | // GNU General Public License for more details. //
|
---|
19 | // //
|
---|
20 | // You should have received a copy of the GNU General Public License //
|
---|
21 | // along with this program; if not, write to the Free Software //
|
---|
22 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
|
---|
23 | // //
|
---|
24 | // $Revision: 1.1 $//
|
---|
25 | // $Date: 2008-10-02 15:20:28 $//
|
---|
26 | ///////////////////////////////////////////////////////////////////////////////
|
---|
27 |
|
---|
28 | #ifndef __REFERENCE_H__
|
---|
29 | #define __REFERENCE_H__
|
---|
30 |
|
---|
31 | namespace siscone{
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * \class Creference
|
---|
35 | * \brief references used for checksums.
|
---|
36 | *
|
---|
37 | * This class implements some reference variable
|
---|
38 | * that can be used for checksums. Those checksums
|
---|
39 | * are useful to disentengle between contents of two
|
---|
40 | * cones without looking into their explicit particle
|
---|
41 | * contents.
|
---|
42 | */
|
---|
43 | class Creference{
|
---|
44 | public:
|
---|
45 | /// default constructor
|
---|
46 | Creference();
|
---|
47 |
|
---|
48 | /// create a random reference
|
---|
49 | void randomize();
|
---|
50 |
|
---|
51 | /// test emptyness
|
---|
52 | bool is_empty();
|
---|
53 |
|
---|
54 | /// test non-emptyness
|
---|
55 | bool not_empty();
|
---|
56 |
|
---|
57 | /// assignment of reference
|
---|
58 | Creference& operator = (const Creference &r);
|
---|
59 |
|
---|
60 | /// addition of reference
|
---|
61 | Creference operator + (const Creference &r);
|
---|
62 |
|
---|
63 | /// incrementation of reference
|
---|
64 | Creference& operator += (const Creference &r);
|
---|
65 |
|
---|
66 | /// decrementation of reference
|
---|
67 | Creference& operator -= (const Creference &r);
|
---|
68 |
|
---|
69 | /// accessing the reference
|
---|
70 | inline unsigned int operator[] (int i) {return ref[i];}
|
---|
71 |
|
---|
72 | unsigned int ref[3]; ///< actual data for the reference
|
---|
73 | };
|
---|
74 |
|
---|
75 | /// addition of two references
|
---|
76 | Creference operator + (Creference &r1, Creference &r2);
|
---|
77 |
|
---|
78 | /// equality test of two references
|
---|
79 | bool operator == (const Creference &r1, const Creference &r2);
|
---|
80 |
|
---|
81 | /// difference test of two references
|
---|
82 | bool operator != (const Creference &r1, const Creference &r2);
|
---|
83 |
|
---|
84 | /// ordering of two references
|
---|
85 | bool operator < (const Creference &r1, const Creference &r2);
|
---|
86 |
|
---|
87 |
|
---|
88 | //=============== inline material ================
|
---|
89 |
|
---|
90 | // equality test for two references
|
---|
91 | //----------------------------------
|
---|
92 | inline bool operator == (const Creference &r1, const Creference &r2){
|
---|
93 | return (r1.ref[0]==r2.ref[0]) && (r1.ref[1]==r2.ref[1]) && (r1.ref[2]==r2.ref[2]);
|
---|
94 | }
|
---|
95 |
|
---|
96 | // difference test for two references
|
---|
97 | //----------------------------------
|
---|
98 | inline bool operator != (const Creference &r1, const Creference &r2){
|
---|
99 | return (r1.ref[0]!=r2.ref[0]) || (r1.ref[1]!=r2.ref[1]) || (r1.ref[2]!=r2.ref[2]);
|
---|
100 | }
|
---|
101 |
|
---|
102 | // difference test for two references
|
---|
103 | //----------------------------------
|
---|
104 | inline bool operator < (const Creference &r1, const Creference &r2){
|
---|
105 | return (r1.ref[0]<r2.ref[0]) || ((r1.ref[0]==r2.ref[0]) &&
|
---|
106 | ((r1.ref[1]<r2.ref[1]) || ((r1.ref[1]==r2.ref[1]) && (r1.ref[2]<r2.ref[2]))
|
---|
107 | ));
|
---|
108 | }
|
---|
109 |
|
---|
110 | }
|
---|
111 | #endif
|
---|