BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/MdcRecoUtil/include/MdcRecoUtil/AstStringMap.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: AstStringMap.h,v 1.4 2010/03/25 09:55:57 zhangy Exp $
4//
5// Description:
6// This class is meant to be used to store an unowned pointer to
7// and object that you reference with a std::string key.
8//
9// Environment:
10// This software was developed for the BaBar collaboration. If you
11// use all or part of it, please give an appropriate acknowledgement.
12//
13// Author List:
14// Stephen J. Gowdy Originator
15//
16// Copyright Information:
17// Copyright (C) 2004 Stanford Linear Accelerator Center
18//
19// History:
20// Migration for BESIII MDC
21//
22//------------------------------------------------------------------------
23
24#ifndef ASTSTRINGMAP_H
25#define ASTSTRINGMAP_H
26
27//-------------
28// C Headers --
29//-------------
30extern "C" {}
31
32//---------------
33// C++ Headers --
34//---------------
35#include <iosfwd>
36#include <map>
37#include <string>
38#include <vector>
39
40//----------------------
41// Base Class Headers --
42//----------------------
43
44//-------------------------------
45// Collaborating Class Headers --
46//-------------------------------
47
48//------------------------------------
49// Collaborating Class Declarations --
50//------------------------------------
51
52// ---------------------
53// -- Class Interface --
54// ---------------------
55
56/**
57 * This class is meant to be used to store an unowned pointer to
58 * and object that you reference with a std::string key.
59 *
60 * This software was developed for the BaBar collaboration. If you
61 * use all or part of it, please give an appropriate acknowledgement.
62 *
63 * Copyright (C) 2004 Stanford Linear Accelerator Center
64//
65// History:
66// Migration for BESIII MDC
67 *
68 * @see Template
69 *
70 * @version $Id: AstStringMap.h,v 1.4 2010/03/25 09:55:57 zhangy Exp $
71 *
72 * @author Stephen J. Gowdy Originator;
73 */
74
75template <class T> class AstStringMap {
76
77 //--------------------
78 // Declarations --
79 //--------------------
80
81 // Typedefs, consts, and enums
82
83 //--------------------
84 // Instance Members --
85 //--------------------
86
87public:
88 // Constructors
90
91 // Destructor
92 virtual ~AstStringMap();
93
94 // Operators
95
96 /**
97 * Find object using a string key.
98 *
99 * @param key String to use to lookup object
100 * @return Pointer to object (0 if no object found)
101 *
102 */
103 virtual T* operator[]( const std::string& key ) const;
104
105 // Selectors (const)
106 virtual int size() const;
107
108 // Modifiers
109
110 /**
111 * Store a new reference to a pointer with a string as key
112 *
113 * @param key String to be used as a key for object
114 * @return reference for user to set to new object pointer
115 *
116 * @see Template#myFunction
117 */
118 virtual T*& insert( const std::string& key );
119
120 virtual void clear();
121
122protected:
123 // Helper functions
124 inline int stringToBucket( const std::string& key ) const;
125 // CHANGE inline uint64_t stringToInt( const std::string& key ) const;
126 inline unsigned stringToInt( const std::string& key ) const;
127
128private:
129 // Friends
130 // friend std::ostream& operator<<<T>( std::ostream& stream,
131 friend std::ostream& operator<<( std::ostream& stream, const AstStringMap<T>& map );
132
133 // Data members
134
135 // Here we map strings upto and including eight characters to a 64 bit int
136 std::map<unsigned, T*> _intMap;
137 // for output, remember the string
138 std::map<unsigned, std::string> _intStringMap;
139
140 // Here we have a std::map for each letter for longer strings
141 std::vector<std::map<std::string, T*>> _stringMap;
142
143 // Note: if your class needs a copy constructor or an assignment operator,
144 // make one of the following public and implement it.
145 AstStringMap( const AstStringMap<T>& ); // Copy Constructor
146 AstStringMap<T>& operator=( const AstStringMap<T>& );
147
148 //------------------
149 // Static Members --
150 //------------------
151
152public:
153 // Selectors (const)
154
155 // Modifiers
156
157private:
158 // Data members
159};
160
161/**
162 * Output contents of map to ostream, requires operator<< for T
163 *
164 * @param stream Stream to output on
165 * @param map Map to output contents of
166 * @return reference to stream
167 *
168 * @see Template#myFunction
169 */
170template <class T>
171std::ostream& operator<<( std::ostream& stream, const AstStringMap<T>& map );
172
173// SKIP #ifdef BES_COMP_INST
174// SKIP #include "MdcTrkRecon/Tools/AstStringMap.cxx"
175#include "AstStringMap.icc"
176// SKIP #endif // BES_COMP_INST
177
178#endif // ASTSTRINGMAP_H
std::ostream & operator<<(std::ostream &stream, const AstStringMap< T > &map)
*************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
virtual int size() const
virtual void clear()
virtual T *& insert(const std::string &key)
unsigned stringToInt(const std::string &key) const
int stringToBucket(const std::string &key) const
virtual ~AstStringMap()
virtual T * operator[](const std::string &key) const
friend std::ostream & operator<<(std::ostream &stream, const AstStringMap< T > &map)