55 : m_type(
SCALAR_REAL), m_name(name), m_getReal(getter), m_setReal(setter)
60 : m_type(
SCALAR_REAL), m_name(name), m_group(group), m_getReal(getter), m_setReal(setter)
65 : m_type(
ARRAY_VEC3), m_name(name), m_numValues(numValues), m_getVec3(getter), m_setVec3(setter)
75 if ( value.isString() ) {
90 result = value.asBool();
92 else if ( value.isString() ) {
104 if ( value.isDouble() ) {
105 return value.asDouble();
107 else if ( value.isString() ) {
109 if ( value.asString() ==
"inf" ) {
112 else if ( value.asString() ==
"-inf" ) {
117 LOGGER_WARNING() <<
"Unknown value \"" << value.asString() <<
"\" in json data for " <<
136 if ( value.isArray() ) {
137 if ( value.size() != m_numValues )
138 LOGGER_WARNING() <<
"Array with values for " << m_name <<
" does not have expected length "
141 agxJson::Value::ArrayIndex maxIndex =
std::min(value.size(),
std::min(m_numValues, 3u));
143 for ( agxJson::Value::ArrayIndex i = 0; i < maxIndex; i++) {
144 agxJson::Value valueNode = value[i];
152 else if ( value.isDouble() ) {
156 else if ( value.isString() ) {
161 LOGGER_WARNING() <<
"Unknown value \"" << value.asString() <<
"\" in json data for " <<
173 agxJson::Value object;
175 if ( m_group !=
"" ) {
176 if ( !
root.hasMember( m_group.c_str() ) ) {
180 object =
root[m_group];
186 if ( !
object.hasMember( m_name.c_str() ) ) {
191 agxJson::Value valueNode =
object[m_name];
204 m_setVec3( v, material );
209 m_setReal( r, material );
215 m_setBool( b, material );
248 node = (value ?
"true" :
"false" );
257 agxJson::Value::ArrayIndex maxIndex =
std::min(m_numValues, 3u);
258 node.resize( maxIndex );
260 for ( agxJson::Value::ArrayIndex i = 0; i < maxIndex; ++i) {
272 agxJson::Value* outputNode = &
root;
274 if ( m_group.length() > 0 ) {
276 if ( !
root.hasMember( m_group ) ) {
280 outputNode = &
root[ m_group ];
297 m_resolved = outputNode->hasMember( m_name );
316 if ( m_group.length() > 0 ) {
329 unsigned int m_numValues { 0 };
340 bool m_resolved {
false };
static AgXString format(const char *format,...)
C printf formatting of a string.
A template class that can be used to read/write a json property and set/get the value in another obje...
bool isDefault(const agxJson::Value &value) const
Is value marked as "default"?
GenericJsonParameter(const agx::String &name, const agx::String &group, PropertySetReal setter, PropertyGetReal getter)
void writeValueVec3(agxJson::Value &node, agx::Vec3 value)
Write a short array, at most 3 elements.
void writeValueBool(agxJson::Value &node, bool value)
Writes a bool value to a json node.
void parseVec3(const agxJson::Value &value, agx::Vec3 &result) const
Parse a json node and produce a Vec3.
std::function< agx::Vec3(const T *) > PropertyGetVec3
ParameterType
Type of parameter that should be handled.
GenericJsonParameter(const agx::String &name, PropertySetVec3 setter, PropertyGetVec3 getter, unsigned int numValues)
bool writeProperty(agxJson::Value &root, const T *material)
Store a generic property to json.
void writeValueReal(agxJson::Value &node, agx::Real value)
Writes a real value to a json node.
std::function< void(agx::Vec3, T *) > PropertySetVec3
bool isResolved() const
Status flag if parameter could be read/written.
std::function< void(bool, T *) > PropertySetBool
std::function< bool(const T *) > PropertyGetBool
bool parseBool(const agxJson::Value &value) const
Read a bool from a json value.
GenericJsonParameter(const agx::String &name, PropertySetReal setter, PropertyGetReal getter)
std::function< agx::Real(const T *) > PropertyGetReal
std::function< void(agx::Real, T *) > PropertySetReal
agx::Real parseReal(const agxJson::Value &value) const
Read a real number from a json value.
agx::String getParameterPath() const
Text representation of where in the json structure this parameter lives.
bool readProperty(const agxJson::Value &root, T *material)
Reads a generic property from a json structure.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Vec3T< T > min(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
AGXCORE_EXPORT Component * root()
AgXString< std::string > String
AGXCORE_EXPORT const Real Infinity
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)