/usr/include/ThePEG/Interface/RefVector.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 | // -*- C++ -*-
//
// RefVector.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 RefVector class.
//
namespace ThePEG {
template <class T, class R>
RefVector<T,R>::
RefVector(string newName, string newDescription,
Member newMember, int newSize, bool depSafe,
bool readonly, bool rebind, bool nullable, SetFn newSetFn,
InsFn newInsFn, DelFn newDelFn, GetFn newGetFn, CheckFn newCheckFn)
: RefVectorBase(newName, newDescription, ClassTraits<T>::className(),
typeid(T), ClassTraits<R>::className(), typeid(R), newSize,
depSafe, readonly, !rebind, nullable, false),
theMember(newMember), theSetFn(newSetFn), theInsFn(newInsFn),
theDelFn(newDelFn), theGetFn(newGetFn), theCheckFn(newCheckFn) {}
template <class T, class R>
RefVector<T,R>::
RefVector(string newName, string newDescription,
Member newMember, int newSize, bool depSafe,
bool readonly, bool rebind, bool nullable, bool defnull,
SetFn newSetFn, InsFn newInsFn, DelFn newDelFn, GetFn newGetFn,
CheckFn newCheckFn)
: RefVectorBase(newName, newDescription, ClassTraits<T>::className(),
typeid(T), ClassTraits<R>::className(), typeid(R), newSize,
depSafe, readonly, !rebind, nullable, defnull),
theMember(newMember), theSetFn(newSetFn), theInsFn(newInsFn),
theDelFn(newDelFn), theGetFn(newGetFn), theCheckFn(newCheckFn) {}
template <class T, class R>
void RefVector<T,R>::
set(InterfacedBase & i, IBPtr newRef, int place, bool chk) const
{
if ( readOnly() ) throw InterExReadOnly(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( noNull() && !newRef ) throw InterExNoNull(*this, i);
RefPtr r = dynamic_ptr_cast<RefPtr>(newRef);
if ( !r && newRef ) throw RefVExRefClass(*this, i, newRef, "set");
IVector oldVector = get(i);
if ( theSetFn && ( chk || !theMember ) ) {
try { (t->*theSetFn)(r, place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw RefVExSetUnknown(*this, i, r, place, "set"); }
} else {
if ( !theMember ) throw RefVExNoSet(*this, i);
if ( place < 0 || static_cast<unsigned long>(place) >= (t->*theMember).size() )
throw RefVExIndex(*this, i, place);
(t->*theMember)[place] = r;
}
if ( !InterfaceBase::dependencySafe() && oldVector != get(i) ) i.touch();
}
template <class T, class R>
void RefVector<T,R>::
insert(InterfacedBase & i, IBPtr newRef, int place, bool chk) const
{
if ( readOnly() ) throw InterExReadOnly(*this, i);
if ( size() > 0 ) throw RefVExFixed(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( noNull() && !newRef ) throw InterExNoNull(*this, i);
RefPtr r = dynamic_ptr_cast<RefPtr>(newRef);
if ( !r && newRef ) throw RefVExRefClass(*this, i, newRef, "insert");
IVector oldVector = get(i);
if ( theInsFn && ( chk || !theMember ) ) {
try { (t->*theInsFn)(r, place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw RefVExSetUnknown(*this, i, r, place, "insert"); }
} else {
if ( !theMember ) throw RefVExNoIns(*this, i);
if ( place < 0 || static_cast<unsigned long>(place) > (t->*theMember).size() )
throw RefVExIndex(*this, i, place);
(t->*theMember).insert((t->*theMember).begin()+place, r);
}
if ( !InterfaceBase::dependencySafe() && oldVector != get(i) ) i.touch();
}
template <class T, class R>
void RefVector<T,R>::erase(InterfacedBase & i, int place) const
{
if ( readOnly() ) throw InterExReadOnly(*this, i);
if ( size() > 0 ) throw RefVExFixed(*this, i);
T * t = dynamic_cast<T *>(&i);
if ( !t ) throw InterExClass(*this, i);
IVector oldVector = get(i);
if ( theDelFn ) {
try { (t->*theDelFn)(place); }
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw RefVExDelUnknown(*this, i, place); }
} else {
if ( !theMember ) throw RefVExNoDel(*this, i);
if ( place < 0 || static_cast<unsigned long>(place) >= (t->*theMember).size() )
throw RefVExIndex(*this, i, place);
(t->*theMember).erase((t->*theMember).begin()+place);
}
if ( !InterfaceBase::dependencySafe() && oldVector != get(i) ) i.touch();
}
template <class T, class R>
IVector RefVector<T,R>::get(const InterfacedBase & i) const
{
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( theGetFn ) {
try {
vector<RefPtr> ret = (t->*theGetFn)();
return IVector(ret.begin(), ret.end());
}
catch (InterfaceException & e) { throw e; }
catch ( ... ) { throw RefVExGetUnknown(*this, i); }
}
if ( theMember ) return IVector((t->*theMember).begin(),
(t->*theMember).end());
throw InterExSetup(*this, i);
}
template <class T, class R>
bool RefVector<T,R>::check(const InterfacedBase & i, cIBPtr ir, int place) const
{
const T * t = dynamic_cast<const T *>(&i);
if ( !t ) throw InterExClass(*this, i);
if ( noNull() && !ir ) return false;
cRefPtr r = dynamic_ptr_cast<cRefPtr>(ir);
if ( !r && ir ) return false;
if ( theCheckFn ) return (t->*theCheckFn)(r, place);
if ( !theMember ) return true;
return place >= 0 && static_cast<unsigned long>(place) <= (t->*theMember).size();
}
}
|