38 lines
953 B
Plaintext
38 lines
953 B
Plaintext
#ifndef OSGINTROSPECTION_UTILITY_
|
|
#define OSGINTROSPECTION_UTILITY_
|
|
|
|
#include <osgIntrospection/Export>
|
|
#include <osgIntrospection/Value>
|
|
#include <osgIntrospection/ParameterInfo>
|
|
#include <osgIntrospection/MethodInfo>
|
|
#include <osgIntrospection/variant_cast>
|
|
|
|
#include <vector>
|
|
|
|
namespace osgIntrospection
|
|
{
|
|
|
|
bool OSGINTROSPECTION_EXPORT areParametersCompatible(const ParameterInfoList &pl1, const ParameterInfoList &pl2);
|
|
bool OSGINTROSPECTION_EXPORT areArgumentsCompatible(const ValueList &vl, const ParameterInfoList &pl, float &match);
|
|
|
|
template<typename T>
|
|
void convertArgument(ValueList &src, ValueList &dest, const ParameterInfoList &pl, int index)
|
|
{
|
|
if (index >= static_cast<int>(src.size()))
|
|
{
|
|
dest[index] = pl[index]->getDefaultValue();
|
|
}
|
|
else
|
|
{
|
|
Value &sv = src[index];
|
|
if (requires_conversion<T>(sv))
|
|
dest[index] = sv.convertTo(pl[index]->getParameterType());
|
|
else
|
|
dest[index].swap(sv);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|