|
AGX Dynamics
2.37.3.2
|
A template class that can be used to read/write a json property and set/get the value in another object. More...
#include <GenericJsonParameter.h>
Public Types | |
| enum | ParameterType { UNDEFINED_TYPE, SCALAR_BOOL, SCALAR_REAL, ARRAY_VEC3 } |
| Type of parameter that should be handled. More... | |
| using | PropertyGetBool = std::function< bool(const T *) > |
| using | PropertyGetReal = std::function< agx::Real(const T *) > |
| using | PropertyGetVec3 = std::function< agx::Vec3(const T *) > |
| using | PropertySetBool = std::function< void(bool, T *) > |
| using | PropertySetReal = std::function< void(agx::Real, T *) > |
| using | PropertySetVec3 = std::function< void(agx::Vec3, T *) > |
Public Member Functions | |
| GenericJsonParameter (const agx::String &name, PropertySetReal setter, PropertyGetReal getter) | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetReal setter, PropertyGetReal getter) | |
| GenericJsonParameter (const agx::String &name, PropertySetVec3 setter, PropertyGetVec3 getter, unsigned int numValues) | |
| agx::String | getParameterPath () const |
| Text representation of where in the json structure this parameter lives. More... | |
| bool | isDefault (const agxJson::Value &value) const |
| Is value marked as "default"? More... | |
| bool | isResolved () const |
| Status flag if parameter could be read/written. More... | |
| bool | parseBool (const agxJson::Value &value) const |
| Read a bool from a json value. More... | |
| agx::Real | parseReal (const agxJson::Value &value) const |
| Read a real number from a json value. More... | |
| void | parseVec3 (const agxJson::Value &value, agx::Vec3 &result) const |
| Parse a json node and produce a Vec3. More... | |
| bool | readProperty (const agxJson::Value &root, T *material) |
| Reads a generic property from a json structure. More... | |
| bool | writeProperty (agxJson::Value &root, const T *material) |
| Store a generic property to json. More... | |
| void | writeValueBool (agxJson::Value &node, bool value) |
| Writes a bool value to a json node. More... | |
| void | writeValueReal (agxJson::Value &node, agx::Real value) |
| Writes a real value to a json node. More... | |
| void | writeValueVec3 (agxJson::Value &node, agx::Vec3 value) |
| Write a short array, at most 3 elements. More... | |
A template class that can be used to read/write a json property and set/get the value in another object.
Definition at line 31 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetBool = std::function< bool( const T* ) > |
Definition at line 34 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetReal = std::function< agx::Real( const T* ) > |
Definition at line 35 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetVec3 = std::function< agx::Vec3( const T* ) > |
Definition at line 36 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetBool = std::function< void( bool, T* ) > |
Definition at line 38 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetReal = std::function< void( agx::Real, T* ) > |
Definition at line 39 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetVec3 = std::function< void( agx::Vec3, T* ) > |
Definition at line 40 of file GenericJsonParameter.h.
| enum agx::GenericJsonParameter::ParameterType |
Type of parameter that should be handled.
| Enumerator | |
|---|---|
| UNDEFINED_TYPE | |
| SCALAR_BOOL | |
| SCALAR_REAL | |
| ARRAY_VEC3 | |
Definition at line 46 of file GenericJsonParameter.h.
|
inline |
Definition at line 54 of file GenericJsonParameter.h.
|
inline |
Definition at line 59 of file GenericJsonParameter.h.
|
inline |
Definition at line 64 of file GenericJsonParameter.h.
|
inline |
Text representation of where in the json structure this parameter lives.
Definition at line 314 of file GenericJsonParameter.h.
References agx::AgXString< T >::format(), and agx::GenericJsonParameter< T >::UNDEFINED_TYPE.
Referenced by agx::GenericJsonParameter< T >::parseReal(), agx::GenericJsonParameter< T >::parseVec3(), agx::GenericJsonParameter< T >::readProperty(), and agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Is value marked as "default"?
Definition at line 72 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::parseVec3(), and agx::GenericJsonParameter< T >::readProperty().
|
inline |
Status flag if parameter could be read/written.
Definition at line 306 of file GenericJsonParameter.h.
|
inline |
Read a bool from a json value.
Definition at line 84 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::readProperty().
|
inline |
Read a real number from a json value.
Definition at line 102 of file GenericJsonParameter.h.
References agx::GenericJsonParameter< T >::getParameterPath(), agx::Infinity, LOGGER_ENDL, and LOGGER_WARNING.
Referenced by agx::GenericJsonParameter< T >::parseVec3(), and agx::GenericJsonParameter< T >::readProperty().
|
inline |
Parse a json node and produce a Vec3.
The result is passed in by reference and should already contain the default values. Possible json include:
Definition at line 133 of file GenericJsonParameter.h.
References agx::GenericJsonParameter< T >::getParameterPath(), agx::GenericJsonParameter< T >::isDefault(), LOGGER_END, LOGGER_ENDL, LOGGER_WARNING, agx::min(), and agx::GenericJsonParameter< T >::parseReal().
Referenced by agx::GenericJsonParameter< T >::readProperty().
|
inline |
Reads a generic property from a json structure.
Definition at line 171 of file GenericJsonParameter.h.
References agx::GenericJsonParameter< T >::ARRAY_VEC3, agx::GenericJsonParameter< T >::getParameterPath(), agx::GenericJsonParameter< T >::isDefault(), LOGGER_ENDL, LOGGER_WARNING, agx::GenericJsonParameter< T >::parseBool(), agx::GenericJsonParameter< T >::parseReal(), agx::GenericJsonParameter< T >::parseVec3(), agx::root(), agx::GenericJsonParameter< T >::SCALAR_BOOL, and agx::GenericJsonParameter< T >::SCALAR_REAL.
|
inline |
Store a generic property to json.
If group objects are used, then those has to be created in advance.
Definition at line 270 of file GenericJsonParameter.h.
References agx::GenericJsonParameter< T >::ARRAY_VEC3, agx::GenericJsonParameter< T >::getParameterPath(), LOGGER_ENDL, LOGGER_WARNING, agx::root(), agx::GenericJsonParameter< T >::SCALAR_BOOL, agx::GenericJsonParameter< T >::SCALAR_REAL, agx::GenericJsonParameter< T >::writeValueBool(), agx::GenericJsonParameter< T >::writeValueReal(), and agx::GenericJsonParameter< T >::writeValueVec3().
|
inline |
Writes a bool value to a json node.
Definition at line 246 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Writes a real value to a json node.
Definition at line 230 of file GenericJsonParameter.h.
References agx::equivalent(), and agx::Infinity.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Write a short array, at most 3 elements.
Definition at line 255 of file GenericJsonParameter.h.
References agx::min().
Referenced by agx::GenericJsonParameter< T >::writeProperty().