BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/GeneratorObject/include/DataModel/tools/AssociativeIndexingPolicies.h
Go to the documentation of this file.
1#ifndef DATAMODEL_TOOLS_ASSOCIATIVEINDEXINGPOLICIES_H
2#define DATAMODEL_TOOLS_ASSOCIATIVEINDEXINGPOLICIES_H
3
4#ifndef _CPP_ALGORITHM
5# include <algorithm>
6#endif
7#include <cassert>
8#ifndef _CPP_IOSTREAM
9# include <iostream>
10#endif
11#ifndef BOOST_CONCEPT_CHECKS_HPP
12# include <boost/concept_check.hpp>
13#endif
14
15#ifndef DATAMODEL_TOOLS_REMOVEDATAPTR_H
16# include "DataModel/tools/RemoveDataPtr.h"
17#endif
18
19#ifndef ATHENAKERNEL_TOOLS_TYPE_TOOLS_H
20# include "AthenaKernel/tools/type_tools.h"
21#endif
22
23using ::boost::AssociativeContainerConcept;
24using ::boost::PairAssociativeContainerConcept;
25using ::boost::SimpleAssociativeContainerConcept;
26
27/** @class AssociativeIndexingPolicy
28 * @brief base class for associative STL containers
29 * (e.g. map, set)
30 * @author Paolo Calafiura
31 * $Id: AssociativeIndexingPolicies.h,v 1.2 2003/04/16 01:32:53 calaf Exp $
32 **/
33template <class ASS> class AssociativeIndexingPolicy {
34 // compiler checks that ASS is an stl associative container
35 BOOST_CLASS_REQUIRES( ASS, AssociativeContainerConcept );
36
37public:
38 typedef typename ASS::key_type index_type;
39 typedef typename type_tools::Parameter<index_type>::const_type index_parm_type;
40 typedef typename ASS::value_type value_type;
46 typedef typename type_tools::Parameter<removedDataPtr_type>::type ElementParameter;
47 typedef typename ASS::reference reference;
48 typedef typename ASS::const_reference const_reference;
49 typedef typename ASS::pointer pointer;
50 typedef typename ASS::const_pointer const_pointer;
51 typedef typename ASS::iterator iterator;
52 typedef typename ASS::const_iterator const_iterator;
53
54 index_parm_type index() const { return m_key; }
55
56 template <class OS> bool indexPut( OS& o ) const {
57 // boost::function_requires<isStreamable<OS, index_type> > ();
58 return ( o << m_key ).good();
59 }
60 template <class IS> bool indexGet( IS& i ) {
61 // boost::function_requires<isStreamable<IS, index_type> > ();
62 return ( i >> m_key ).good();
63 }
64
65protected:
68
69 ~AssociativeIndexingPolicy() {} // disallow accidental base class deletion
70
71 iterator lookup( ASS& data ) const { return data.find( m_key ); }
72 const_iterator lookup( const ASS& data ) const { return data.find( m_key ); }
73
75
77};
78
79/** @class SetIndexingPolicy
80 * @brief IndexingPolicy for std::set
81 * @author Paolo Calafiura
82 * $Id: AssociativeIndexingPolicies.h,v 1.2 2003/04/16 01:32:53 calaf Exp $
83 **/
84template <class SET> class SetIndexingPolicy : public AssociativeIndexingPolicy<SET> {
85 // compiler checks that SET is an stl simple associative container
86 BOOST_CLASS_REQUIRES( SET, SimpleAssociativeContainerConcept );
87
88public:
89 // FIXME this should be inherited from AssociativeIndexingPolicy
90 typedef typename SET::key_type index_type;
91 typedef typename type_tools::Parameter<index_type>::const_type index_parm_type;
92 typedef typename SET::value_type value_type;
98 typedef typename type_tools::Parameter<removedDataPtr_type>::type ElementParameter;
99 typedef typename SET::reference reference;
100 typedef typename SET::const_reference const_reference;
101 typedef typename SET::pointer pointer;
102 typedef typename SET::const_pointer const_pointer;
103 typedef typename SET::iterator iterator;
104 typedef typename SET::const_iterator const_iterator;
105
106 static bool reverseLookup( const SET& data, ElementParameter element, index_type& same ) {
107 // compiler checks we can compare elements
108 ::boost::function_requires<
109 typename ::boost::EqualityComparableConcept<removedDataPtr_type>>();
110 if ( data.end() != data.find( element ) )
111 {
112 same = element;
113 return true;
114 }
115 else
116 {
117#ifndef NDEBUG
118 std::cerr << __FILE__ << ':' << __LINE__ << ": "
119 << "SetIndexingPolicy::reverseLookup ERROR: element not found" << std::endl;
120#endif
121 return false;
122 }
123 }
124
125protected:
129 assert( reverseLookup( data, element, m_key ) );
130 }
131 // or the equivalent for old compilers
132 void setIndex( index_parm_type key ) { m_key = key; } // FIXME why this isn't inherited?
133 bool setIndex( const SET& data, ElementParameter element ) {
134 return ( reverseLookup( data, element, m_key ) );
135 }
136
137 ~SetIndexingPolicy() {} // disallow accidental base class deletion
138};
139
140/** @class MapIndexingPolicy
141 * @brief IndexingPolicy for std::map
142 * @author Paolo Calafiura
143 * $Id: AssociativeIndexingPolicies.h,v 1.2 2003/04/16 01:32:53 calaf Exp $
144 **/
145template <class MAP> class MapIndexingPolicy : public AssociativeIndexingPolicy<MAP> {
146 // compiler checks that MAP is an stl pair associative container
147 BOOST_CLASS_REQUIRES( MAP, PairAssociativeContainerConcept );
148
149public:
150 // FIXME this should be inherited from AssociativeIndexingPolicy
151 typedef typename MAP::key_type index_type;
152 typedef typename type_tools::Parameter<index_type>::const_type index_parm_type;
153 typedef typename MAP::value_type value_type;
154 typedef typename MAP::reference reference;
155 typedef typename MAP::const_reference const_reference;
156 typedef typename MAP::pointer pointer;
157 typedef typename MAP::const_pointer const_pointer;
158 typedef typename MAP::iterator iterator;
159 typedef typename MAP::const_iterator const_iterator;
160
161 typedef typename MAP::mapped_type mapped_type;
162
169 typedef typename type_tools::Parameter<removedDataPtr_type>::type ElementParameter;
170
171 static bool reverseLookup( const MAP& data, ElementParameter element, index_type& index ) {
172 // compiler checks we can compare elements
173 ::boost::function_requires<
174 typename ::boost::EqualityComparableConcept<removedDataPtr_type>>();
175 const_iterator it = data.begin();
176 const_iterator end = data.end();
177 while ( it != end && !( it->second == element ) ) { ++it; }
178 if ( it != end )
179 {
180 index = it->first;
181 return true;
182 }
183 else
184 {
185#ifndef NDEBUG
186 std::cerr << __FILE__ << ':' << __LINE__ << ": "
187 << "MapIndexingPolicy::reverseLookup ERROR: element not found" << std::endl;
188#endif
189 return false;
190 }
191 }
192
193protected:
196 MapIndexingPolicy( const MAP& data, ElementParameter element ) {
197 assert( reverseLookup( data, element, m_key ) );
198 }
199 // or the equivalent for old compilers
200 void setIndex( index_parm_type key ) { m_key = key; } // FIXME why this isn't inherited?
201 bool setIndex( const MAP& data, ElementParameter element ) {
202 return ( reverseLookup( data, element, m_key ) );
203 }
204 ~MapIndexingPolicy() {} // disallow accidental base class deletion
205};
206
207#endif
TTree * data
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42
static bool reverseLookup(const MAP &data, ElementParameter element, index_type &index)
type_tools::Parameter< removedDataPtr_type >::type ElementParameter
type_tools::Parameter< removedDataPtr_type >::type ElementParameter
static bool reverseLookup(const SET &data, ElementParameter element, index_type &same)