/usr/include/simgear/props/ExtendedPropertyAdapter.hxx is in libsimgear-dev 1:2018.1.1+dfsg-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 | #ifndef SIMGEAR_EXTENDEDPROPERTYADAPTER_HXX
#define SIMGEAR_EXTENDEDPROPERTYADAPTER_HXX 1
#include <algorithm>
#include <boost/bind.hpp>
#include <simgear/math/SGMath.hxx>
#include <simgear/structure/exception.hxx>
#include "props.hxx"
namespace simgear
{
namespace props
{
// This should be in simgear/math/SGVec.hxx and friends
template<typename T> struct NumComponents;
template<> struct NumComponents<SGVec3d>
{
enum { num_components = 3 };
};
template<> struct NumComponents<SGVec4d>
{
enum { num_components = 4 };
};
}
template<typename T, typename NodeContainer>
class ExtendedPropertyAdapter
{
public:
enum { num_components = props::NumComponents<T>::num_components };
ExtendedPropertyAdapter(const NodeContainer& elements)
: _elements(elements)
{
}
T operator()() const
{
T result;
if (_elements.size() < num_components)
throw sg_exception();
for (int i = 0; i < num_components; ++i)
result[i] = _elements[i]->template getValue<double>();
return result;
}
void set(const T& val)
{
if (_elements.size() < num_components)
throw sg_exception();
for (int i = 0; i < num_components; ++i)
_elements[i]->setValue(val[i]);
}
private:
const NodeContainer& _elements;
};
template<typename InIterator, typename OutIterator>
inline void makeChildList(SGPropertyNode* prop, InIterator inBegin,
InIterator inEnd, OutIterator outBegin)
{
std::transform(inBegin, inEnd, outBegin,
boost::bind(static_cast<SGPropertyNode* (SGPropertyNode::*)(const char*, int, bool)>(&SGPropertyNode::getChild), prop, _1, 0, true));
}
}
#endif
|