thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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 
27 namespace ThePEG {
28 
30 ThePEG_DECLARE_SET(PDPtr,ParticleDataSet);
31 
33 typedef vector<PDPtr> PDVector;
34 
36 typedef vector<cPDPtr> cPDVector;
37 
39 typedef vector<tPDPtr> tPDVector;
40 
42 typedef vector<tcPDPtr> tcPDVector;
43 
45 ThePEG_DECLARE_SET(PMPtr,MatcherSet);
46 
48 ThePEG_DECLARE_SET(DMPtr,DecayModeSet);
49 
51 ThePEG_DECLARE_SET(IBPtr,ObjectSet);
52 
54 ThePEG_DECLARE_SET(IBPtr,DependencySet);
55 
57 ThePEG_DECLARE_MAP(long,PDPtr,ParticleMap);
58 
60 ThePEG_DECLARE_MAP(string,IBPtr,ObjectMap);
61 
64 ThePEG_DECLARE_MAP(IBPtr,DependencySet,DependencyMap);
65 
67 typedef vector<IBPtr> IVector;
68 
70 typedef vector<cIBPtr> CIVector;
71 
73 typedef vector<PPtr> ParticleVector;
74 
76 typedef vector<PPtr> PVector;
77 
79 typedef vector<cPPtr> cPVector;
80 
82 typedef vector<tPPtr> tPVector;
83 
85 typedef vector<tcPPtr> tcPVector;
86 
88 typedef list<PPtr> ParticleList;
89 
91 typedef list<PPtr> PList;
92 
94 typedef list<cPPtr> cPList;
95 
97 typedef list<tPPtr> tPList;
98 
100 typedef list<tcPPtr> tcPList;
101 
103 ThePEG_DECLARE_MAP(string,const InterfaceBase *,InterfaceMap);
104 
107 
109 ThePEG_DECLARE_MAP(string,EGPtr,GeneratorMap);
110 
112 typedef vector<AnaPtr> AnalysisVector;
113 
115 typedef pair<PDPtr, PDPtr> PDPair;
116 
118 typedef pair<cPDPtr, cPDPtr> cPDPair;
119 
121 typedef pair<tPDPtr, tPDPtr> tPDPair;
122 
124 typedef pair<tcPDPtr, tcPDPtr> tcPDPair;
125 
127 typedef pair<PPtr, PPtr> PPair;
128 
130 typedef pair<cPPtr, cPPtr> cPPair;
131 
133 typedef pair<tPPtr, tPPtr> tPPair;
134 
136 typedef pair<tcPPtr, tcPPtr> tcPPair;
137 
140 
142 typedef vector<SInterval> SIntervalVector;
143 
145 typedef vector<tPDPair> tPartonPairVec;
146 
148 typedef pair<tColinePtr,tColinePtr> tColinePair;
149 
151 ThePEG_DECLARE_SET(tDMPtr,DecaySet);
152 
154 ThePEG_DECLARE_SET(string,StringSet);
155 
157 typedef vector<Energy> EnergyVector;
158 
160 typedef vector<EIPtr> EIVector;
161 
163 typedef vector<double> DVector;
164 
166 typedef pair<double,double> DPair;
167 
178 template <typename T, typename U>
179 vector<T> & operator<<(vector<T> & tv, const U & u) {
180  tv.push_back(u);
181  return tv;
182 }
183 
191 template <typename T, typename U>
192 vector<T> & operator>>(vector<T> & tv, U & u) {
193  u = tv.back();
194  tv.pop_back();
195  return tv;
196 }
197 
205 template <typename T, typename U>
206 stack<T> & operator<<(stack<T> & ts, const U & u) {
207  ts.push(u);
208  return ts;
209 }
210 
218 template <typename T, typename U>
219 stack<T> & operator>>(stack<T> & ts, U & u) {
220  u = ts.top();
221  ts.pop();
222  return ts;
223 }
224 
232 template <typename T, typename U>
233 deque<T> & operator<<(deque<T> & td, const U & u) {
234  td.push_back(u);
235  return td;
236 }
237 
245 template <typename T, typename U>
246 deque<T> & operator>>(deque<T> & td, U & u) {
247  u = td.front();
248  td.pop_front();
249  return td;
250 }
251 
259 template <typename T, typename U>
260 set<T> & operator<<(set<T> & ts, const U & u) {
261  ts.insert(u);
262  return ts;
263 }
265 
274 template <typename OStream, typename T, typename Alloc, typename UT>
275 void 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 
288 template <typename IStream, typename T, typename Alloc, typename UT>
289 void 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 
303 template <typename OStream, typename T, typename CMP, typename A, typename UT>
304 void 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 
316 template <typename IStream, typename T, typename CMP, typename A, typename UT>
317 void 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 
335 template <typename OStream, typename K, typename T,
336  typename CMP, typename A, typename UT>
337 void 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 
351 template <typename IStream, typename K, typename T,
352  typename CMP, typename A, typename UT>
353 void 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 */
pair< cPPtr, cPPtr > cPPair
A pair of pointers to const Particle objects.
Definition: Containers.h:130
pair< tcPDPtr, tcPDPtr > tcPDPair
A pair of transient pointers to const ParticleData objects.
Definition: Containers.h:124
vector< cPPtr > cPVector
A vector of pointers to const Particle objects.
Definition: Containers.h:79
pair< tColinePtr, tColinePtr > tColinePair
A pair of transient pointers to ColourLine objects.
Definition: Containers.h:148
The InterfaceBase class defines a generic interface to any class derived from the InterfacedBase clas...
Definition: InterfaceBase.h:59
void ounitstream(OStream &os, const vector< T, Alloc > &v, UT &u)
Ouput a vector of objects with the specified unit.
Definition: Containers.h:275
vector< tcPDPtr > tcPDVector
A vector of transient pointers to const ParticleData objects.
Definition: Containers.h:42
ThePEG_DECLARE_SET(PDPtr, ParticleDataSet)
A set of pointers to ParticleData objects.
list< tPPtr > tPList
A list of transient pointers to Particle objects.
Definition: Containers.h:97
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
list< tcPPtr > tcPList
A list of transient pointers to const Particle objects.
Definition: Containers.h:100
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
pair< tcPPtr, tcPPtr > tcPPair
A pair of transient pointers to const Particle objects.
Definition: Containers.h:136
vector< double > DVector
A vector of doubles.
Definition: Containers.h:163
void iunitstream(IStream &is, vector< T, Alloc > &v, UT &u)
Input a vector of objects with the specified unit.
Definition: Containers.h:289
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
vector< cIBPtr > CIVector
A vector of pointers to const InterfacedBase objects.
Definition: Containers.h:70
list< PPtr > ParticleList
A list of pointers to Particle objects.
Definition: Containers.h:88
ThePEG_DECLARE_MAP(long, PDPtr, ParticleMap)
A map relating integers to ParticleData objects.
vector< tPDPair > tPartonPairVec
A vector of pairs of transient pointers to PartonBins.
Definition: Containers.h:145
vector< tPDPtr > tPDVector
A vector of transient pointers to ParticleData objects.
Definition: Containers.h:39
vector< tcPPtr > tcPVector
A vector of transient pointers to const Particle objects.
Definition: Containers.h:85
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
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
pair< PDPtr, PDPtr > PDPair
A pair of pointers to ParticleData objects.
Definition: Containers.h:115
ThePEG::Ptr< ParticleData >::pointer PDPtr
Alias for a reference counted pointer to ParticleData .
Definition: Pointers.h:64
pair< PPtr, PPtr > PPair
A pair of pointers to Particle objects.
Definition: Containers.h:127
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
pair< double, double > DPair
A pair of doubles.
Definition: Containers.h:166
pair< tPDPtr, tPDPtr > tPDPair
A pair of transient pointers to ParticleData objects.
Definition: Containers.h:121
vector< cPDPtr > cPDVector
A vector of pointers to const ParticleData objects.
Definition: Containers.h:36
vector< PDPtr > PDVector
A vector of pointers to ParticleData objects.
Definition: Containers.h:33
vector< SInterval > SIntervalVector
A vector of intervals of scales.
Definition: Containers.h:142
Interval< Energy2 > SInterval
An Interval in scale.
Definition: Containers.h:139
list< cPPtr > cPList
A list of pointers to const Particle objects.
Definition: Containers.h:94
pair< cPDPtr, cPDPtr > cPDPair
A pair of pointers to const ParticleData objects.
Definition: Containers.h:118
vector< tPPtr > tPVector
A vector of transient pointers to Particle objects.
Definition: Containers.h:82
vector< IBPtr > IVector
A vector of pointers to InterfacedBase objects.
Definition: Containers.h:67
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< AnaPtr > AnalysisVector
A vector of pointers to AnalysisHandler objects.
Definition: Containers.h:112
vector< EIPtr > EIVector
A vector of pointers to EventInfoBase objects.
Definition: Containers.h:160
Rebinder< InterfacedBase > TranslationMap
A rebinder for InterfacedBase objects.
Definition: Containers.h:106
list< PPtr > PList
A list of pointers to Particle objects.
Definition: Containers.h:91
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