LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCParametersImpl.cc
Go to the documentation of this file.
2 
3 #include "LCIOSTLTypes.h"
4 #include <algorithm>
5 
6 using namespace EVENT ;
7 
8 namespace IMPL{
9 
10  LCParametersImpl::LCParametersImpl(){
11 
12  }
13 
14  int LCParametersImpl::getIntVal(const std::string & key) const {
15 
16  IntMap::iterator it = _intMap.find( key ) ;
17 
18  if( it == _intMap.end() ) return 0 ;
19 
20  IntVec & iv = it->second ;
21 
22  return iv[0] ;
23  }
24 
25  float LCParametersImpl::getFloatVal(const std::string & key) const {
26 
27  FloatMap::iterator it = _floatMap.find( key ) ;
28 
29  if( it == _floatMap.end() ) return 0 ;
30 
31  FloatVec & fv = it->second ;
32 
33  return fv[0] ;
34  }
35 
36  double LCParametersImpl::getDoubleVal(const std::string & key) const {
37 
38  DoubleMap::iterator it = _doubleMap.find( key ) ;
39 
40  if( it == _doubleMap.end() ) return 0 ;
41 
42  DoubleVec & fv = it->second ;
43 
44  return fv[0] ;
45  }
46 
47  const std::string & LCParametersImpl::getStringVal(const std::string & key) const {
48 
49  static std::string empty("") ;
50 
51  StringMap::iterator it = _stringMap.find( key ) ;
52 
53  if( it == _stringMap.end() ) return empty ;
54 
55  StringVec & sv = it->second ;
56 
57  return sv[0] ;
58  }
59 
60  IntVec & LCParametersImpl::getIntVals(const std::string & key, IntVec & values) const {
61 
62  IntMap::iterator it = _intMap.find( key ) ;
63 
64  if( it != _intMap.end() ) {
65  values.insert( values.end() , it->second.begin() , it->second.end() ) ;
66  }
67 
68  return values ;
69  }
70 
71  FloatVec & LCParametersImpl::getFloatVals(const std::string & key, FloatVec & values) const {
72 
73  FloatMap::iterator it = _floatMap.find( key ) ;
74 
75  if( it != _floatMap.end() ) {
76  values.insert( values.end() , it->second.begin() , it->second.end() ) ;
77  }
78  return values ;
79  }
80 
81  DoubleVec & LCParametersImpl::getDoubleVals(const std::string & key, DoubleVec & values) const {
82 
83  DoubleMap::iterator it = _doubleMap.find( key ) ;
84 
85  if( it != _doubleMap.end() ) {
86  values.insert( values.end() , it->second.begin() , it->second.end() ) ;
87  }
88  return values ;
89  }
90 
91  StringVec & LCParametersImpl::getStringVals(const std::string & key, StringVec & values) const {
92 
93  StringMap::iterator it = _stringMap.find( key ) ;
94 
95  if( it != _stringMap.end() ) {
96  values.insert( values.end() , it->second.begin() , it->second.end() ) ;
97  }
98  return values ;
99  }
100 
101 
102  const StringVec & LCParametersImpl::getIntKeys(StringVec & keys) const {
103 
104  for( IntMap::iterator iter = _intMap.begin() ; iter != _intMap.end() ; iter++ ){
105  keys.push_back( iter->first ) ;
106  }
107 // fg: select1st is non-standard
108 // transform( _intMap.begin() , _intMap.end() , back_inserter( keys ) , select1st< IntMap::value_type >() ) ;
109 
110  return keys ;
111  }
112 
113  const StringVec & LCParametersImpl::getFloatKeys(StringVec & keys) const {
114 
115  for( FloatMap::iterator iter = _floatMap.begin() ; iter != _floatMap.end() ; iter++ ){
116  keys.push_back( iter->first ) ;
117  }
118 // fg: select1st is non-standard
119 // transform( _floatMap.begin() , _floatMap.end() , back_inserter( keys ) , select1st< FloatMap::value_type >() ) ;
120  return keys ;
121  }
122 
123  const StringVec & LCParametersImpl::getDoubleKeys(StringVec & keys) const {
124 
125  for( DoubleMap::iterator iter = _doubleMap.begin() ; iter != _doubleMap.end() ; iter++ ){
126  keys.push_back( iter->first ) ;
127  }
128 // fg: select1st is non-standard
129 // transform( _doubleMap.begin() , _doubleMap.end() , back_inserter( keys ) , select1st< DoubleMap::value_type >() ) ;
130  return keys ;
131  }
132 
133  const StringVec & LCParametersImpl::getStringKeys(StringVec & keys) const {
134 
135  for( StringMap::iterator iter = _stringMap.begin() ; iter != _stringMap.end() ; iter++ ){
136  keys.push_back( iter->first ) ;
137  }
138 // fg: select1st is non-standard
139 // transform( _stringMap.begin() , _stringMap.end() , back_inserter( keys ) , select1st< StringMap::value_type >() ) ;
140  return keys ;
141  }
142 
143  int LCParametersImpl::getNInt(const std::string & key) const {
144 
145  IntMap::iterator it = _intMap.find( key ) ;
146 
147  if( it == _intMap.end() )
148  return 0 ;
149  else
150  return it->second.size() ;
151  }
152 
153  int LCParametersImpl::getNFloat(const std::string & key) const {
154 
155  FloatMap::iterator it = _floatMap.find( key ) ;
156 
157  if( it == _floatMap.end() )
158  return 0 ;
159  else
160  return it->second.size() ;
161  }
162 
163  int LCParametersImpl::getNDouble(const std::string & key) const {
164 
165  DoubleMap::iterator it = _doubleMap.find( key ) ;
166 
167  if( it == _doubleMap.end() )
168  return 0 ;
169  else
170  return it->second.size() ;
171  }
172 
173  int LCParametersImpl::getNString(const std::string & key) const {
174 
175  StringMap::iterator it = _stringMap.find( key ) ;
176 
177  if( it == _stringMap.end() )
178  return 0 ;
179  else
180  return it->second.size() ;
181  }
182 
183  void LCParametersImpl::setValue(const std::string & key, int value){
184  checkAccess("LCParametersImpl::setValue") ;
185 // if( _intMap[ key ].size() > 0 )
186  _intMap[ key ].clear() ;
187  _intMap[ key ].push_back( value ) ;
188  }
189 
190  void LCParametersImpl::setValue(const std::string & key, float value){
191  checkAccess("LCParametersImpl::setValue") ;
192 // if( _floatMap[ key ].size() > 0 )
193  _floatMap[ key ].clear() ;
194  _floatMap[ key ].push_back( value ) ;
195  }
196 
197  void LCParametersImpl::setValue(const std::string & key, double value){
198  checkAccess("LCParametersImpl::setValue") ;
199 // if( _doubleMap[ key ].size() > 0 )
200  _doubleMap[ key ].clear() ;
201  _doubleMap[ key ].push_back( value ) ;
202  }
203 
204  void LCParametersImpl::setValue(const std::string & key, const std::string & value) {
205  checkAccess("LCParametersImpl::setValue") ;
206 // if( _stringMap[ key ].size() > 0 )
207  _stringMap[ key ].clear() ;
208  _stringMap[ key ].push_back( value ) ;
209 
210  }
211 
212 
213 
214  void LCParametersImpl::setValues(const std::string & key,const EVENT::IntVec & values){
215 
216  checkAccess("LCParametersImpl::setValues") ;
217 
218 // if( _intMap[ key ].size() > 0 ) _intMap[ key ].clear() ;
219 // copy( values.begin() , values.end() , back_inserter( _intMap[ key ] ) ) ;
220 
221  _intMap[ key ].assign( values.begin() , values.end() ) ;
222  }
223 
224  void LCParametersImpl::setValues(const std::string & key,const EVENT::FloatVec & values){
225 
226  checkAccess("LCParametersImpl::setValues") ;
227 
228 // if( _floatMap[ key ].size() > 0 ) _floatMap[ key ].clear() ;
229 // copy( values.begin() , values.end() , back_inserter( _floatMap[ key ] ) ) ;
230 
231  _floatMap[ key ].assign( values.begin() , values.end() ) ;
232  }
233 
234  void LCParametersImpl::setValues(const std::string & key,const EVENT::DoubleVec & values){
235 
236  checkAccess("LCParametersImpl::setValues") ;
237 
238 // if( _doubleMap[ key ].size() > 0 ) _doubleMap[ key ].clear() ;
239 // copy( values.begin() , values.end() , back_inserter( _doubleMap[ key ] ) ) ;
240 
241  _doubleMap[ key ].assign( values.begin() , values.end() ) ;
242  }
243 
244  void LCParametersImpl::setValues(const std::string & key, const EVENT::StringVec & values){
245 
246  checkAccess("LCParametersImpl::setValues") ;
247 
248 // if( _stringMap[ key ].size() > 0 ) _stringMap[ key ].clear() ;
249 // copy( values.begin() , values.end() , back_inserter( _stringMap[ key ] ) ) ;
250 
251  _stringMap[ key ].assign( values.begin() , values.end() ) ;
252  }
253 
254 } // namespace
T end(T...args)
STL class.
T push_back(T...args)
T insert(T...args)
T find(T...args)
T size(T...args)
T begin(T...args)