/usr/include/trilinos/RTC_ArrayIndexRTC.hh is in libtrilinos-pamgen-dev 12.4.2-2.
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 | #ifndef _ARRAYINDEXRTC_H
#define _ARRAYINDEXRTC_H
#include "RTC_VariableRTC.hh"
#include "RTC_commonRTC.hh"
#include "RTC_ExecutableRTC.hh"
#include "RTC_ValueRTC.hh"
#include <iostream>
#include <cassert>
namespace PG_RuntimeCompiler {
/**
* ArrayIndex objects represent the value of an array at a certain index.
* Anywhere the user get the index of an array,an ArrayIndex object is created.
* ArrayIndex extends Variable.
*/
class ArrayIndex : public Value {
public:
/**
* Contructor -> Constructs super class, initializes instance variables. Note
* this class will take responsibility for deleting index.
*
* @param parent - The Array object that is being indexed
* @param index - The expression that, when evaluated, will be the index
*/
ArrayIndex(Variable* parent, Executable* index)
: Value(parent->getType(), ArrayIndexOT)
{
assert(parent->getObjectType() == ArrayVarOT);
_parent = parent;
_indexExpr = index;
}
/**
* Destructor -> Deletes the index expression
*/
~ArrayIndex() {delete _indexExpr;}
/**
* getValue -> This method evaluates _indexExpr to get the index and then
* returns the indexth element of the parent array.
*/
double getValue() {
return _parent->getArrayValue((int)_indexExpr->execute()->getValue());
}
/**
* setValue -> This method evaluates _indexExpr to get the index and then
* sets the indexth element of the parent array equal to value.
*
* @param value - The value we are setting _parent[_indexExpr] equal to
*/
void setValue(double value) {
_parent->setArrayValue(value, (int)_indexExpr->execute()->getValue());
}
std::ostream& operator<<(std::ostream& os) const {
//os << "ArrayIndex:" << _parent->getName() << "[" << *_indexExpr << "]";
os << _parent->getArrayValue((int)_indexExpr->execute()->getValue());
return os;
}
private:
Variable* _parent; //!< The Array variable that is being indexed
Executable* _indexExpr; //!< The expr that, when evaluated, will be the index
};
}
#endif
|