/usr/include/ThePEG/Interface/Parameter.tcc is in libthepeg-dev 1.8.0-1.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 | // -*- C++ -*-
//
// Parameter.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 Parameter and ParameterTBase classes.
//
namespace ThePEG {
template <typename Type>
string ParameterTBase<Type>::type() const {
if ( std::numeric_limits<Type>::is_integer ) return "Pi";
if ( typeid(Type) == typeid(string) ) return "Ps";
return "Pf";
}
template <typename Type>
string ParameterTBase<Type>::doxygenType() const {
string lim = "";
if ( !limited() ) lim = "Unlimited ";
if ( std::numeric_limits<Type>::is_integer ) return lim + "Integer parameter";
if ( typeid(Type) == typeid(string) ) return "Character string parameter";
return lim + "Parameter";
}
template <typename Type>
inline void
ParameterTBase<Type>::setImpl(InterfacedBase & i,
string newValue, StandardT)
const {
istringstream is(newValue);
if ( unit() > Type() ) {
double t;
is >> t;
tset(i, Type(t*unit()));
} else {
Type t = Type();
is >> t;
tset(i, t);
}
}
template <typename Type>
inline void
ParameterTBase<Type>::setImpl(InterfacedBase & i,
string newValue, DimensionT)
const {
istringstream is(newValue);
double t;
is >> t;
tset(i, t*unit());
}
template <typename T>
void ParameterTBase<T>::
set(InterfacedBase & i, string newValue) const {
setImpl(i, newValue, typename TypeTraits<T>::DimType());
}
template <typename Type>
string ParameterTBase<Type>::
get(const InterfacedBase & i) const {
ostringstream os;
putUnit(os, tget(i));
return os.str();
}
template <typename Type>
string ParameterTBase<Type>::
minimum(const InterfacedBase & i) const {
ostringstream os;
if ( ParameterBase::lowerLimit() ) putUnit(os, tminimum(i));
return os.str();
}
template <typename Type>
string ParameterTBase<Type>::
maximum(const InterfacedBase & i) const {
ostringstream os;
if ( ParameterBase::upperLimit() ) putUnit(os, tmaximum(i));
return os.str();
}
template <typename Type>
string ParameterTBase<Type>::
def(const InterfacedBase & i) const {
ostringstream os;
putUnit(os, tdef(i));
return os.str();
}
template <typename T, typename Type>
void Parameter<T,Type>::tset(InterfacedBase & i, Type newValue) const
{
if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( ( ParameterBase::lowerLimit() && newValue < tminimum(i) ) ||
( ParameterBase::upperLimit() && newValue > tmaximum(i) ) )
throw ParExSetLimit(*this, i, newValue);
Type oldValue = tget(i);
if ( theSetFn ) {
try { (t->*theSetFn)(newValue); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExSetUnknown(*this, i, newValue); }
} else {
if ( theMember ) t->*theMember = newValue;
else throw InterExSetup(*this, i);
}
if ( !InterfaceBase::dependencySafe() && oldValue != tget(i)) i.touch();
}
template <typename T>
void Parameter<T,string>::tset(InterfacedBase & i, string newValue) const
{
if ( InterfaceBase::readOnly() ) throw InterExReadOnly(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
string oldValue = tget(i);
if ( theSetFn ) {
try { (t->*theSetFn)(newValue); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExSetUnknown(*this, i, newValue); }
} else {
if ( theMember ) t->*theMember = newValue;
else throw InterExSetup(*this, i);
}
if ( !InterfaceBase::dependencySafe() && oldValue != tget(i)) i.touch();
}
template <typename T, typename Type>
Type Parameter<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 ParExGetUnknown(*this, i, "current"); }
}
if ( theMember ) return t->*theMember;
else throw InterExSetup(*this, i);
}
template <typename T>
string Parameter<T,string>::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 ParExGetUnknown(*this, i, "current"); }
}
if ( theMember ) return t->*theMember;
else throw InterExSetup(*this, i);
}
template <typename T, typename Type>
Type Parameter<T,Type>::tminimum(const InterfacedBase & i) const
{
if ( theMinFn ) {
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return max(theMin, (t->*theMinFn)()); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExGetUnknown(*this, i, "minimum"); }
}
return theMin;
}
template <typename T, typename Type>
Type Parameter<T,Type>::tmaximum(const InterfacedBase & i) const
{
if ( theMaxFn ) {
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return min(theMax, (t->*theMaxFn)()); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExGetUnknown(*this, i, "maximum"); }
}
return theMax;
}
template <typename T, typename Type>
Type Parameter<T,Type>::tdef(const InterfacedBase & i) const
{
if ( theDefFn ) {
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theDefFn)(); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExGetUnknown(*this, i, "default"); }
}
return theDef;
}
template <typename T>
string Parameter<T,string>::tdef(const InterfacedBase & i) const
{
if ( theDefFn ) {
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
try { return (t->*theDefFn)(); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw ParExGetUnknown(*this, i, "default"); }
}
return theDef;
}
template <typename T, typename Type>
void Parameter<T,Type>::doxygenDescription(ostream & os) const {
ParameterTBase<Type>::doxygenDescription(os);
os << "<b>Default value:</b> ";
this->putUnit(os, theDef);
if ( theDefFn ) os << " (May be changed by member function.)";
if ( ParameterBase::lowerLimit() ) {
os << "<br>\n<b>Minimum value:</b> ";
this->putUnit(os, theMin);
if ( theMinFn ) os << " (May be changed by member function.)";
}
if ( ParameterBase::upperLimit() ) {
os << "<br>\n<b>Maximum value:</b> ";
this->putUnit(os, theMax);
if ( theMaxFn ) os << " (May be changed by member function.)";
}
os << "<br>\n";
}
template <typename T>
void Parameter<T,string>::doxygenDescription(ostream & os) const {
ParameterTBase<string>::doxygenDescription(os);
os << "<b>Default value:</b> " << theDef;
if ( theDefFn ) os << " (May be changed by member function.)";
os << "<br>\n";
}
namespace {
template <typename T>
inline
void ostreamInsert(ostream & os, T v, DimensionT) {
os << ounit(v,T::baseunit());
}
template <typename T>
inline
void ostreamInsert(ostream & os, T v, StandardT) {
os << v;
}
}
template <typename T>
ParExSetLimit::ParExSetLimit(const InterfaceBase & i,
const InterfacedBase & o, T v) {
theMessage << "Could not set the parameter \"" << i.name()
<< "\" for the object \"" << o.name() << "\" to ";
ostreamInsert(theMessage,v,typename TypeTraits<T>::DimType() );
theMessage << " because the value is outside the specified limits.";
severity(setuperror);
}
template <typename T>
ParExSetUnknown::ParExSetUnknown(const InterfaceBase & i,
const InterfacedBase & o, T v) {
theMessage << "Could not set the parameter \"" << i.name()
<< "\" for the object \"" << o.name() << "\" to ";
ostreamInsert(theMessage,v,typename TypeTraits<T>::DimType() );
theMessage << " because the set function threw an unknown exception.";
severity(setuperror);
}
}
|