|
ATLAS Offline Software
|
Go to the documentation of this file.
19 template<
typename T >
23 for( std::size_t
i = 0;
i <
vec.size(); ++
i ) {
25 if( (
i + 1 ) <
vec.size() ) {
113 if (this->
m_moved)
throw std::logic_error(
"Content already moved");
143 throw std::runtime_error(
"! operator called on unknown "
155 if (this->
m_moved)
throw std::logic_error(
"Content already moved");
183 throw std::runtime_error(
"- operator called on unknown "
193 #define IMPL_ASSIGN_OP( OP ) \
194 StackElement& StackElement::operator OP( StackElement& rhs ) { \
195 makeVectorIfNecessary( rhs ); \
196 makeDoubleIfNecessary( rhs ); \
199 m_intVal OP rhs.scalarValue< int >(); \
202 m_doubleVal OP rhs.scalarValue< double >(); \
205 *this OP rhs.vectorValue< int >( m_vecIntVal.size() ); \
208 *this OP rhs.vectorValue< double >( m_vecDoubleVal.size() ); \
211 throw std::runtime_error( "StackElement ill-defined in " \
224 #undef IMPL_ASSIGN_OP
249 throw std::runtime_error(
"asInt() only valid for SE_INT" );
252 return scalarValue< int >();
258 throw std::runtime_error(
"asBool() only valid for non-vector types" );
261 return scalarValue< bool >();
268 if (this->
m_moved)
throw std::logic_error(
"Content already moved");
282 return std::vector<int>( sizeIfScalar,
m_intVal );
286 return std::vector<int>( sizeIfScalar,
static_cast< int >(
m_doubleVal ) );
290 throw std::runtime_error(
"(int) vectorValue(): Unsupported "
294 return std::vector<int>();
298 std::vector< double >
301 if (this->
m_moved)
throw std::logic_error(
"Content already moved");
316 return std::vector<double>(sizeIfScalar,
static_cast< double >(
m_intVal ) );
320 return std::vector<double>(sizeIfScalar,
m_doubleVal );
324 throw std::runtime_error(
"(dbl) vectorValue(): Unsupported "
328 return std::vector<double>();
415 tmp=std::vector<double>();
419 throw std::runtime_error(
"Got VT_UNK - unknown identifier: " +
428 template <
class T_CompHelper,
class T>
431 std::vector<int> ret;
432 ret.resize(
a.size());
433 assert(
a.size() ==
b.size() );
434 for (std::size_t
idx=0;
idx <
a.size(); ++
idx) {
439 template <
class T_CompHelper,
class T>
445 template <
class T_CompHelper>
448 assert(
a.size() ==
b.size() );
449 for (std::size_t
idx=0;
idx <
a.size(); ++
idx) {
452 return std::vector<int>(std::move(
a));
455 template <
class T_CompHelper>
458 assert(
a.size() ==
b.size() );
459 for (std::size_t
idx=0;
idx <
a.size(); ++
idx) {
462 return std::vector<int>(std::move(
b));
465 template <
class T_CompHelper>
469 throw std::runtime_error(
"ERROR: Can't operate on SE_UNK "
474 return comp_helper.compare(scalarValue< int >(),
other.scalarValue<
int >() );
476 return comp_helper.compare(scalarValue< double >(),
other.scalarValue<
double >() );
480 throw std::runtime_error(
"Incompatible vectors - different length" );
485 return compareVector( this->vectorValue<int>(the_size) ,
other.vectorValue<
int >(the_size), comp_helper );
488 return compareVectorAlt( this->vectorValue<int>(the_size) ,
other.vectorValue<
int >(the_size), comp_helper );
491 return compareVector( this->vectorValue<double>(the_size) ,
other.vectorValue<
double >(the_size), comp_helper );
519 throw std::runtime_error(
"Can't use vector as exponent" );
521 return _pow(
n.scalarValue<
double >() );
602 if (this->
m_moved)
throw std::logic_error(
"Content already moved");
640 #define UNARY_MATH_FUNCTION( FUNC, BASEFUNC ) \
641 StackElement StackElement::FUNC() { \
642 if (this->m_moved) throw std::logic_error("Content already moved");\
643 StackElement temp( std::move(*this) ); \
644 this->m_moved=true; \
646 if( temp.m_type == SE_DOUBLE ) { \
647 temp.m_doubleVal = BASEFUNC( temp.m_doubleVal ); \
649 } else if( temp.m_type == SE_VECDOUBLE ) { \
650 for( double& value : temp.m_vecDoubleVal ) { \
651 value = BASEFUNC( value ); \
677 #undef UNARY_MATH_FUNCTION
685 if(
other.isVector() ) {
755 throw std::runtime_error(
"Incompatible stack elements" );
769 const std::size_t ourlen =
size();
770 if( ourlen !=
other.size() ) {
771 throw std::runtime_error(
"Incompatible vectors - different length" );
778 switch(
el.m_type ) {
781 os <<
"(int)" <<
el.m_intVal;
785 os <<
"(double)" <<
el.m_doubleVal;
789 os <<
"(vec<int>)" <<
el.m_vecIntVal;
793 os <<
"(vec<double>)" <<
el.m_vecDoubleVal;
ElementType
Type of the data held by this object.
StackElement _sum()
Function calculating a sum value.
int compare(const T &a, const T &b)
int compare(const T &a, const T &b)
bool isProxy() const
Check if the object takes its value from a StoreGate object.
StackElement valueFromProxy() const
Set the internal variables of the object based on the objects in SG.
void makeVectorIfNecessary(const StackElement &other)
The macro is not needed anymore:
ElementType getType() const
Get the variable type of the object.
std::vector< int > m_vecIntVal
The value of the object represented as a vector of integers.
int compare(const T &a, const T &b)
void ensureCompatibleVectors(const T &other) const
@ SE_DOUBLE
The type is a double.
StackElement _pow(const T &n)
Function raising the object's value to the n'th power.
void makeDoubleIfNecessary(const StackElement &other)
virtual double loadDoubleVariableFromString(const std::string &varname) const =0
std::vector< size_t > vec
StackElement _neq(StackElement &other)
#define UNARY_MATH_FUNCTION(FUNC, BASEFUNC)
Helper macro for implementing many of the mathematical functions.
int compare(const T &a, const T &b)
virtual VariableType variableTypeFromString(const std::string &varname) const =0
StackElement _and(StackElement &other)
void makeDouble()
Function constructing internal double values in case integer values were given to the object initiall...
std::vector< T > vectorValue(std::size_t sizeIfScalar=0)
Evaluate the value of the object into the requested vector type.
std::vector< int > compareVectorAlt(const std::vector< T > &&a, std::vector< T > &&b, T_CompHelper helper)
void makeInt()
Function constructing internal integer values in case double values were given to the object initiall...
StackElement _lt(StackElement &other)
virtual std::vector< int > loadVecIntVariableFromString(const std::string &varname) const =0
bool isVector() const
Check if the object describes a vector value.
StackElement _or(StackElement &other)
std::atomic< bool > m_determinedVariableType
Internal flag showing whether the type of the variable was already determined.
Namespace holding all the expression evaluation code.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
int asInt() const
Get the internal value of the object as an integer.
double m_doubleVal
The value of the object represented as a double.
def asinh(x)
helper methods ---------------------------------------------------------—
std::vector< int > compareVector(std::vector< T > &&a, std::vector< T > &&b, T_CompHelper helper)
std::atomic< IProxyLoader::VariableType > m_variableType
Type of the variable provided by the proxy loader.
std::string m_varName
The name/definition of the variable.
StackElement operator-()
Inverse operator.
StackElement _gt(StackElement &other)
@ SE_VECINT
The type is a vector of integers.
std::ostream & operator<<(std::ostream &os, const StackElement &el)
Declare an output operator for StackElement objects.
StackElement operator!()
NOT operator.
std::vector< double > m_vecDoubleVal
The value of the object represented as a vector of doubles.
StackElement _abs()
Function taking the absolute value of the object.
IProxyLoader * m_proxyLoader
Loader for the described variable.
virtual std::vector< double > loadVecDoubleVariableFromString(const std::string &varname) const =0
ElementType m_type
The type of the variable held by the object.
StackElement _lte(StackElement &other)
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
bool asBool() const
Get the internal value of the object as a boolean.
int compare(const T &a, const T &b)
bool isScalar() const
Check if the object describes a scalar value.
int compare(const T &a, const T &b)
StackElement _eq(StackElement &other)
StackElement & operator=(int rhs)
Operator assigning an integer value to the object.
@ SE_VECDOUBLE
The type is a vector of doubles.
StackElement _gte(StackElement &other)
@ SE_UNK
The type is not known, or not applicable.
int compare(const T &a, const T &b)
Class describing a single element in a text expression.
StackElement _count()
Function counting elements.
std::atomic< bool > m_moved
int m_intVal
The value of the object represented as an integer.
#define IMPL_ASSIGN_OP(OP)
Helper macro implementing the assignment operator specialisations.
StackElement _comparisonOp(StackElement &other, T_CompHelper comp_helper)
void ensureCompatible(const StackElement &other) const
virtual int loadIntVariableFromString(const std::string &varname) const =0
@ SE_INT
The type is an integer.
int compare(const T &a, const T &b)
void makeVector(std::size_t n)
Function converting a possibly scalar value into a vector.