/usr/include/ThePEG/Interface/ParVector.tcc is in libthepeg-dev 1.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | // -*- C++ -*-
//
// ParVector.tcc is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
//
// This is the implementation of the non-inlined templated member
// functions of the ParVector and ParVectorTBase classes.
//
#include "ParVector.xh"
namespace ThePEG {
template <typename Type>
string ParVectorTBase<Type>::type() const {
if ( std::numeric_limits<Type>::is_integer ) return "Vi";
if ( typeid(Type) == typeid(string) ) return "Vs";
return "Vf";
}
template <typename Type>
string ParVectorTBase<Type>::doxygenType() const {
ostringstream os;
if ( size() <= 0 ) os << "Varying size ";
else os << "Fixed size (" << size() << ") ";
os << "vector of ";
string lim = "";
if ( !limited() ) lim = " unlimited";
if ( std::numeric_limits<Type>::is_integer ) os << lim << "integer ";
else if ( typeid(Type) == typeid(string) ) os << "string ";
else os << lim;
os << "parameters";
return os.str();
}
template <typename Type>
string ParVectorTBase<Type>::fullDescription(const InterfacedBase & ib) const {
return ParVectorBase::fullDescription(ib) + def() + "\n";
}
template <typename Type>
void ParVectorTBase<Type>::setDef(InterfacedBase & i, int place) const
{
if ( place >= 0 ) tset(i, tdef(i, place), place);
int sz = get(i).size();
for ( int j = 0; j < sz; ++j ) tset(i, tdef(i, j), j);
}
template <typename Type>
inline void ParVectorTBase<Type>::
setImpl(InterfacedBase & i, string newValue, int place, StandardT)
const {
istringstream is(newValue);
if ( unit() > Type() ) {
double t;
is >> t;
tset(i, Type(t*unit()), place);
} else {
Type t = Type();
is >> t;
tset(i, t, place);
}
}
template <typename Type>
inline void ParVectorTBase<Type>::
setImpl(InterfacedBase & i, string newValue, int place, DimensionT)
const {
istringstream is(newValue);
double t;
is >> t;
tset(i, t*unit(), place);
}
template <typename T>
void ParVectorTBase<T>::
set(InterfacedBase & i, string newValue, int place) const
{
setImpl(i, newValue, place, typename TypeTraits<T>::DimType());
}
template <typename Type>
inline void ParVectorTBase<Type>::
insertImpl(InterfacedBase & i, string newValue, int place, StandardT)
const {
istringstream is(newValue);
if ( unit() > Type() ) {
double t;
is >> t;
tinsert(i, Type(t*unit()), place);
} else {
Type t = Type();
is >> t;
tinsert(i, t, place);
}
}
template <typename Type>
inline void ParVectorTBase<Type>::
insertImpl(InterfacedBase & i, string newValue, int place, DimensionT)
const {
istringstream is(newValue);
double t;
is >> t;
tinsert(i, t*unit(), place);
}
template <typename T>
void ParVectorTBase<T>::
insert(InterfacedBase & i, string newValue, int place) const
{
insertImpl(i, newValue, place, typename TypeTraits<T>::DimType());
}
template <typename Type>
typename ParVectorTBase<Type>::StringVector ParVectorTBase<Type>::
get(const InterfacedBase & i) const {
TypeVector tres = tget(i);
StringVector res;
for ( typename TypeVector::iterator it = tres.begin();
it != tres.end(); ++it ) {
ostringstream os;
putUnit(os, *it);
res.push_back(os.str());
}
return res;
}
template <typename Type>
string ParVectorTBase<Type>::
minimum(const InterfacedBase & i, int place) const {
ostringstream os;
putUnit(os, tminimum(i,place));
return os.str();
}
template <typename Type>
string ParVectorTBase<Type>::
maximum(const InterfacedBase & i, int place) const {
ostringstream os;
putUnit(os, tmaximum(i, place));
return os.str();
}
template <typename Type>
string ParVectorTBase<Type>::
def(const InterfacedBase & i, int place) const {
ostringstream os;
putUnit(os, tdef(i,place));
return os.str();
}
template <typename Type>
string ParVectorTBase<Type>::def() const {
ostringstream os;
putUnit(os, tdef());
return os.str();
}
template <typename T, typename Type>
Type ParVector<T,Type>::tdef() const {
return theDef;
}
template <typename T, typename Type>
void ParVector<T,Type>::tset(InterfacedBase & i, Type newValue, int place) const
{
if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( ( ParVectorBase::lowerLimit() && newValue < tminimum(*t, place) ) ||
( ParVectorBase::upperLimit() && newValue > tmaximum(*t, place) ) )
throw ParVExLimit(*this, i, newValue);
TypeVector oldVector = tget(i);
if ( theSetFn ) {
try { (t->*theSetFn)(newValue, place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExUnknown(*this, i, newValue, place, "set"); }
} else {
if ( !theMember ) throw InterExSetup(*this, i);
if ( place < 0 || unsigned(place) >= (t->*theMember).size() )
throw ParVExIndex(*this, i, place);
(t->*theMember)[place] = newValue;
}
if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch();
}
template <typename T, typename Type>
void ParVector<T,Type>::
tinsert(InterfacedBase & i, Type newValue, int place) const
{
if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i);
if ( ParVectorBase::size() > 0 ) throw ParVExFixed(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( ( ParVectorBase::lowerLimit() && newValue < tminimum(*t, place) ) ||
( ParVectorBase::upperLimit() && newValue > tmaximum(*t, place) ) )
throw ParVExLimit(*this, i, newValue);
TypeVector oldVector = tget(i);
if ( theInsFn ) {
try { (t->*theInsFn)(newValue, place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExUnknown(*this, i, newValue, place, "insert"); }
} else {
if ( !theMember ) throw InterExSetup(*this, i);
if ( place < 0 || unsigned(place) > (t->*theMember).size() )
throw ParVExIndex(*this, i, place);
(t->*theMember).insert((t->*theMember).begin()+place, newValue);
}
if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch();
}
template <typename T, typename Type>
void ParVector<T,Type>::
erase(InterfacedBase & i, int place) const {
if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i);
if ( ParVectorBase::size() > 0 ) throw ParVExFixed(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
TypeVector oldVector = tget(i);
if ( theDelFn ) {
try { (t->*theDelFn)(place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExDelUnknown(*this, i, place); }
} else {
if ( !theMember ) throw InterExSetup(*this, i);
if ( place < 0 || unsigned(place) >= (t->*theMember).size() )
throw ParVExIndex(*this, i, place);
(t->*theMember).erase((t->*theMember).begin()+place);
}
if ( !InterfaceBase::dependencySafe() && oldVector != tget(i) ) i.touch();
}
template <typename T, typename Type>
typename ParVector<T,Type>::TypeVector ParVector<T,Type>::
tget(const InterfacedBase & i) const {
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( theGetFn ) {
try { return (t->*theGetFn)(); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExGetUnknown(*this, i, "current"); }
}
if ( theMember ) return t->*theMember;
throw InterExSetup(*this, i);
}
template <typename T, typename Type>
typename ParVector<T,Type>::StringVector ParVector<T,Type>::
get(const InterfacedBase & i) const {
if ( !theStringGetFn ) return ParVectorTBase<Type>::get(i);
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theStringGetFn)(); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExGetUnknown(*this, i, "current"); }
}
template <typename T, typename Type>
Type ParVector<T,Type>::tdef(const InterfacedBase & i, int place) const
{
if ( place < 0 || !theDefFn ) return theMin;
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theDefFn)(place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExGetUnknown(*this, i, "default"); }
}
template <typename T, typename Type>
Type ParVector<T,Type>::tminimum(const InterfacedBase & i, int place) const
{
if ( place < 0 || !theMinFn ) return theMin;
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theMinFn)(place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExGetUnknown(*this, i, "minimum"); }
}
template <typename T, typename Type>
Type ParVector<T,Type>::tmaximum(const InterfacedBase & i, int place) const
{
if ( place < 0 || !theMaxFn ) return theMax;
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theMaxFn)(place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParVExGetUnknown(*this, i, "maximum"); }
}
template <typename T, typename Type>
void ParVector<T,Type>::doxygenDescription(ostream & os) const {
ParVectorTBase<Type>::doxygenDescription(os);
os << "<b>Default value:</b> ";
this->putUnit(os, theDef);
if ( theDefFn ) os << " (May be changed by member function.)";
if ( ParVectorBase::lowerLimit() ) {
os << "<br>\n<b>Minimum value:</b> ";
this->putUnit(os, theMin);
if ( theMinFn ) os << " (May be changed by member function.)";
}
if ( ParVectorBase::upperLimit() ) {
os << "<br>\n<b>Maximum value:</b> ";
this->putUnit(os, theMax);
if ( theMaxFn ) os << " (May be changed by member function.)";
}
os << "<br>\n";
}
namespace {
template <typename T>
inline
void ostreamInsert2(ostream & os, T v, DimensionT) {
os << ounit(v,T::baseunit());
}
template <typename T>
inline
void ostreamInsert2(ostream & os, T v, StandardT) {
os << v;
}
}
template <typename T>
ParVExLimit::ParVExLimit(const InterfaceBase & i,
const InterfacedBase & o, T v) {
theMessage << "Could not set/insert ";
ostreamInsert2(theMessage,v,typename TypeTraits<T>::DimType() );
theMessage << " in the parameter vector \""
<< i.name() << "\" for the object \"" << o.name()
<< "\" because the value is outside the specified limits.";
severity(setuperror);
}
template <typename T>
ParVExUnknown::ParVExUnknown(const InterfaceBase & i, const InterfacedBase & o,
T v, int j, const char * s) {
theMessage << "Could not " << s << " the value ";
ostreamInsert2(theMessage,v,typename TypeTraits<T>::DimType() );
theMessage << " at position "
<< j << " in the parameter vector \"" << i.name()
<< "\" for the object \"" << o.name() << "\" because the "
<< s << " function threw an unknown exception.";
severity(setuperror);
}
}
|