thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
Containers.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// Containers.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_Containers_H
10#define ThePEG_Containers_H
11
25#include "ThePEG/Utilities/UnitIO.h"
26
27namespace ThePEG {
28
30ThePEG_DECLARE_SET(PDPtr,ParticleDataSet);
31
33typedef vector<PDPtr> PDVector;
34
36typedef vector<cPDPtr> cPDVector;
37
39typedef vector<tPDPtr> tPDVector;
40
42typedef vector<tcPDPtr> tcPDVector;
43
46
49
52
55
57ThePEG_DECLARE_MAP(long,PDPtr,ParticleMap);
58
60ThePEG_DECLARE_MAP(string,IBPtr,ObjectMap);
61
64ThePEG_DECLARE_MAP(IBPtr,DependencySet,DependencyMap);
65
67typedef vector<IBPtr> IVector;
68
70typedef vector<cIBPtr> CIVector;
71
73typedef vector<PPtr> ParticleVector;
74
76typedef vector<PPtr> PVector;
77
79typedef vector<cPPtr> cPVector;
80
82typedef vector<tPPtr> tPVector;
83
85typedef vector<tcPPtr> tcPVector;
86
88typedef list<PPtr> ParticleList;
89
91typedef list<PPtr> PList;
92
94typedef list<cPPtr> cPList;
95
97typedef list<tPPtr> tPList;
98
100typedef list<tcPPtr> tcPList;
101
103ThePEG_DECLARE_MAP(string,const InterfaceBase *,InterfaceMap);
104
107
109ThePEG_DECLARE_MAP(string,EGPtr,GeneratorMap);
110
112typedef vector<AnaPtr> AnalysisVector;
113
115typedef pair<PDPtr, PDPtr> PDPair;
116
118typedef pair<cPDPtr, cPDPtr> cPDPair;
119
121typedef pair<tPDPtr, tPDPtr> tPDPair;
122
124typedef pair<tcPDPtr, tcPDPtr> tcPDPair;
125
127typedef pair<PPtr, PPtr> PPair;
128
130typedef pair<cPPtr, cPPtr> cPPair;
131
133typedef pair<tPPtr, tPPtr> tPPair;
134
136typedef pair<tcPPtr, tcPPtr> tcPPair;
137
140
142typedef vector<SInterval> SIntervalVector;
143
145typedef vector<tPDPair> tPartonPairVec;
146
148typedef pair<tColinePtr,tColinePtr> tColinePair;
149
152
154ThePEG_DECLARE_SET(string,StringSet);
155
157typedef vector<Energy> EnergyVector;
158
160typedef vector<EIPtr> EIVector;
161
163typedef vector<double> DVector;
164
166typedef pair<double,double> DPair;
167
178template <typename T, typename U>
179vector<T> & operator<<(vector<T> & tv, const U & u) {
180 tv.push_back(u);
181 return tv;
182}
183
191template <typename T, typename U>
192vector<T> & operator>>(vector<T> & tv, U & u) {
193 u = tv.back();
194 tv.pop_back();
195 return tv;
196}
197
205template <typename T, typename U>
206stack<T> & operator<<(stack<T> & ts, const U & u) {
207 ts.push(u);
208 return ts;
209}
210
218template <typename T, typename U>
219stack<T> & operator>>(stack<T> & ts, U & u) {
220 u = ts.top();
221 ts.pop();
222 return ts;
223}
224
232template <typename T, typename U>
233deque<T> & operator<<(deque<T> & td, const U & u) {
234 td.push_back(u);
235 return td;
236}
237
245template <typename T, typename U>
246deque<T> & operator>>(deque<T> & td, U & u) {
247 u = td.front();
248 td.pop_front();
249 return td;
250}
251
259template <typename T, typename U>
260set<T> & operator<<(set<T> & ts, const U & u) {
261 ts.insert(u);
262 return ts;
263}
265
274template <typename OStream, typename T, typename Alloc, typename UT>
275void ounitstream(OStream & os, const vector<T,Alloc> & v, UT & u) {
276 os << v.size();
277 for ( typename vector<T,Alloc>::const_iterator i = v.begin();
278 i != v.end(); ++i )
279 os << ounit(*i, u);
280}
281
288template <typename IStream, typename T, typename Alloc, typename UT>
289void iunitstream(IStream & is, vector<T,Alloc> & v, UT & u) {
290 typename vector<T,Alloc>::size_type l;
291 is >> l;
292 v.resize(l);
293 for ( typename vector<T,Alloc>::iterator i = v.begin(); i != v.end(); ++i )
294 is >> iunit(*i, u);
295}
296
303template <typename OStream, typename T, typename CMP, typename A, typename UT>
304void ounitstream(OStream & os, const set<T,CMP,A> & s, UT & u) {
305 os << s.size();
306 for ( typename set<T,CMP,A>::const_iterator i = s.begin(); i != s.end(); ++i )
307 os << ounit(*i, u);
308}
309
316template <typename IStream, typename T, typename CMP, typename A, typename UT>
317void iunitstream(IStream & is, set<T,CMP,A> & s, UT & u) {
318 s.clear();
319 typename set<T,CMP,A>::size_type l;
320 is >> l;
321 T t;
322 while ( l-- ) {
323 is >> iunit(t, u);
324 s.insert(t);
325 }
326}
327
335template <typename OStream, typename K, typename T,
336 typename CMP, typename A, typename UT>
337void ounitstream(OStream & os, const map<K,T,CMP,A> & m, UT & u) {
338 os << m.size();
339 for ( typename map<K,T,CMP,A>::const_iterator i = m.begin();
340 i != m.end(); ++i )
341 os << i->first << ounit(i->second, u);
342}
343
351template <typename IStream, typename K, typename T,
352 typename CMP, typename A, typename UT>
353void iunitstream(IStream & is, map<K,T,CMP,A> & m, UT & u) {
354 m.clear();
355 typename map<K,T,CMP,A>::size_type l;
356 is >> l;
357 T t;
358 K k;
359 while ( l-- ) {
360 is >> k >> iunit(t, u);
361 m[k] = t;
362 }
363}
365
366}
367
368#endif /* ThePEG_Containers_H */
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
An Interval object is used to represent an interval [ lower(), upper() ) where the ordering is define...
Definition: Interval.h:27
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
Rebinder is a class associating pairs of pointers to objects.
Definition: Rebinder.h:27
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
vector< EIPtr > EIVector
A vector of pointers to EventInfoBase objects.
Definition: Containers.h:160
pair< PPtr, PPtr > PPair
A pair of pointers to Particle objects.
Definition: Containers.h:127
vector< cIBPtr > CIVector
A vector of pointers to const InterfacedBase objects.
Definition: Containers.h:70
IUnit< T, UT > iunit(T &t, const UT &ut)
Helper function creating a IUnit object given an object and a unit.
Definition: UnitIO.h:91
vector< T > & operator>>(vector< T > &tv, U &u)
Overload the right shift operator for vector to pop objects from a vector.
Definition: Containers.h:192
vector< PDPtr > PDVector
A vector of pointers to ParticleData objects.
Definition: Containers.h:33
pair< cPDPtr, cPDPtr > cPDPair
A pair of pointers to const ParticleData objects.
Definition: Containers.h:118
list< PPtr > ParticleList
A list of pointers to Particle objects.
Definition: Containers.h:88
vector< AnaPtr > AnalysisVector
A vector of pointers to AnalysisHandler objects.
Definition: Containers.h:112
pair< tPDPtr, tPDPtr > tPDPair
A pair of transient pointers to ParticleData objects.
Definition: Containers.h:121
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
vector< T > & operator<<(vector< T > &tv, const U &u)
Overload the left shift operator for vector to push_back objects to a vector.
Definition: Containers.h:179
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
list< cPPtr > cPList
A list of pointers to const Particle objects.
Definition: Containers.h:94
vector< tPDPtr > tPDVector
A vector of transient pointers to ParticleData objects.
Definition: Containers.h:39
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
vector< cPPtr > cPVector
A vector of pointers to const Particle objects.
Definition: Containers.h:79
Interval< Energy2 > SInterval
An Interval in scale.
Definition: Containers.h:139
pair< tcPDPtr, tcPDPtr > tcPDPair
A pair of transient pointers to const ParticleData objects.
Definition: Containers.h:124
pair< tcPPtr, tcPPtr > tcPPair
A pair of transient pointers to const Particle objects.
Definition: Containers.h:136
pair< tPPtr, tPPtr > tPPair
A pair of transient pointers to const Particle objects.
Definition: Containers.h:133
vector< Energy > EnergyVector
A vector of energies.
Definition: Containers.h:157
pair< tColinePtr, tColinePtr > tColinePair
A pair of transient pointers to ColourLine objects.
Definition: Containers.h:148
list< tPPtr > tPList
A list of transient pointers to Particle objects.
Definition: Containers.h:97
vector< tPDPair > tPartonPairVec
A vector of pairs of transient pointers to PartonBins.
Definition: Containers.h:145
vector< PPtr > ParticleVector
A vector of pointers to Particle objects.
Definition: Containers.h:73
vector< PPtr > PVector
A vector of pointers to Particle objects.
Definition: Containers.h:76
vector< SInterval > SIntervalVector
A vector of intervals of scales.
Definition: Containers.h:142
vector< double > DVector
A vector of doubles.
Definition: Containers.h:163
pair< double, double > DPair
A pair of doubles.
Definition: Containers.h:166
pair< cPPtr, cPPtr > cPPair
A pair of pointers to const Particle objects.
Definition: Containers.h:130
Rebinder< InterfacedBase > TranslationMap
A rebinder for InterfacedBase objects.
Definition: Containers.h:106
pair< PDPtr, PDPtr > PDPair
A pair of pointers to ParticleData objects.
Definition: Containers.h:115
list< PPtr > PList
A list of pointers to Particle objects.
Definition: Containers.h:91
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67
vector< tcPPtr > tcPVector
A vector of transient pointers to const Particle objects.
Definition: Containers.h:85
vector< tcPDPtr > tcPDVector
A vector of transient pointers to const ParticleData objects.
Definition: Containers.h:42
vector< cPDPtr > cPDVector
A vector of pointers to const ParticleData objects.
Definition: Containers.h:36
OUnit< T, UT > ounit(const T &t, const UT &ut)
Helper function creating a OUnit object given an object and a unit.
Definition: UnitIO.h:84
list< tcPPtr > tcPList
A list of transient pointers to const Particle objects.
Definition: Containers.h:100
#define ThePEG_DECLARE_MAP(KEYTYPE, VALTYPE, NAME)
Macro for declaring a map.
Definition: std.h:185
#define ThePEG_DECLARE_SET(VALTYPE, NAME)
Macro for declaring a set.
Definition: std.h:175