|
AGX Dynamics 2.38.0.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_INT , SCALAR_BOOL , SCALAR_REAL , STRING , ARRAY_VEC3 } |
| Type of parameter that should be handled. More... | |
| using | PropertyGetBool = std::function< bool(const T *) > |
| using | PropertyGetInt = std::function< int(const T *) > |
| using | PropertyGetReal = std::function< agx::Real(const T *) > |
| using | PropertyGetString = std::function< agx::String(const T *) > |
| using | PropertyGetVec3 = std::function< agx::Vec3(const T *) > |
| using | PropertySetBool = std::function< void(bool, T *) > |
| using | PropertySetInt = std::function< void(int, T *) > |
| using | PropertySetReal = std::function< void(agx::Real, T *) > |
| using | PropertySetString = std::function< void(agx::String, T *) > |
| using | PropertySetVec3 = std::function< void(agx::Vec3, T *) > |
Public Member Functions | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetBool setter, PropertyGetBool getter) | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetInt setter, PropertyGetInt getter) | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetReal setter, PropertyGetReal getter) | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetString setter, PropertyGetString getter) | |
| GenericJsonParameter (const agx::String &name, const agx::String &group, PropertySetVec3 setter, PropertyGetVec3 getter) | |
| GenericJsonParameter (const agx::String &name, PropertySetBool setter, PropertyGetBool getter) | |
| GenericJsonParameter (const agx::String &name, PropertySetInt setter, PropertyGetInt getter) | |
| GenericJsonParameter (const agx::String &name, PropertySetReal setter, PropertyGetReal getter) | |
| GenericJsonParameter (const agx::String &name, PropertySetString setter, PropertyGetString 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. | |
| bool | isDefault (const agxJson::Value &value) const |
| Is value marked as "default"? | |
| bool | isResolved () const |
| Status flag if parameter could be read/written. | |
| bool | parseBool (const agxJson::Value &value) const |
| Read a bool from a json value. | |
| int | parseInt (const agxJson::Value &value) const |
| Read an int from a json value. | |
| agx::Real | parseReal (const agxJson::Value &value) const |
| Read a real number from a json value. | |
| agx::String | parseString (const agxJson::Value &value) const |
| Read a string from a json value. | |
| void | parseVec3 (const agxJson::Value &value, agx::Vec3 &result) const |
| Parse a json node and produce a Vec3. | |
| bool | readProperty (const agxJson::Value &root, T *material, bool optional=false) |
| Reads a generic property from a json structure. | |
| bool | writeProperty (agxJson::Value &root, const T *material) |
| Store a generic property to json. | |
| void | writeValueBool (agxJson::Value &node, bool value) |
| Writes a bool value to a json node. | |
| void | writeValueInt (agxJson::Value &node, int value) |
| Writes an int value to a json node. | |
| void | writeValueReal (agxJson::Value &node, agx::Real value) |
| Writes a real value to a json node. | |
| void | writeValueString (agxJson::Value &node, const agx::String value) |
| Writes a string value to a json node. | |
| void | writeValueVec3 (agxJson::Value &node, agx::Vec3 value) |
| Write a short array, at most 3 elements. | |
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 35 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetInt = std::function< int( const T* ) > |
Definition at line 34 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetReal = std::function< agx::Real( const T* ) > |
Definition at line 37 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetString = std::function< agx::String( const T* ) > |
Definition at line 36 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertyGetVec3 = std::function< agx::Vec3( const T* ) > |
Definition at line 38 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetBool = std::function< void( bool, T* ) > |
Definition at line 41 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetInt = std::function< void(int, T* ) > |
Definition at line 40 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetReal = std::function< void( agx::Real, T* ) > |
Definition at line 43 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetString = std::function< void( agx::String, T* ) > |
Definition at line 42 of file GenericJsonParameter.h.
| using agx::GenericJsonParameter< T >::PropertySetVec3 = std::function< void(agx::Vec3, T*) > |
Definition at line 44 of file GenericJsonParameter.h.
| enum agx::GenericJsonParameter::ParameterType |
Type of parameter that should be handled.
| Enumerator | |
|---|---|
| UNDEFINED_TYPE | |
| SCALAR_INT | |
| SCALAR_BOOL | |
| SCALAR_REAL | |
| STRING | |
| ARRAY_VEC3 | |
Definition at line 50 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 59 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 64 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 69 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 74 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 79 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 85 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 90 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 95 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 100 of file GenericJsonParameter.h.
|
inlineexplicit |
Definition at line 105 of file GenericJsonParameter.h.
|
inline |
Text representation of where in the json structure this parameter lives.
Definition at line 426 of file GenericJsonParameter.h.
References agx::AgXString< std::string >::format().
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 113 of file GenericJsonParameter.h.
References agx::AgXString< T >::lower().
Referenced by agx::GenericJsonParameter< T >::parseVec3(), and agx::GenericJsonParameter< T >::readProperty().
|
inline |
Status flag if parameter could be read/written.
Definition at line 418 of file GenericJsonParameter.h.
|
inline |
Read a bool from a json value.
Definition at line 143 of file GenericJsonParameter.h.
References agx::AgXString< T >::lower().
Referenced by agx::GenericJsonParameter< T >::readProperty().
|
inline |
Read an int from a json value.
Definition at line 125 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::readProperty().
|
inline |
Read a real number from a json value.
Definition at line 174 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 |
Read a string from a json value.
Definition at line 161 of file GenericJsonParameter.h.
Referenced by 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 205 of file GenericJsonParameter.h.
References agx::GenericJsonParameter< T >::getParameterPath(), agx::GenericJsonParameter< T >::isDefault(), LOGGER_END, LOGGER_ENDL, LOGGER_WARNING, and agx::GenericJsonParameter< T >::parseReal().
Referenced by agx::GenericJsonParameter< T >::readProperty().
|
inline |
Reads a generic property from a json structure.
param root - Pointer to root of data tree param material - Pointer to data that will be parsed using a Lambda expression param optional - If true, no warnings will be written if m_group or m_name cannot be found in root
Definition at line 246 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 >::parseInt(), agx::GenericJsonParameter< T >::parseReal(), agx::GenericJsonParameter< T >::parseString(), agx::GenericJsonParameter< T >::parseVec3(), agx::root(), agx::GenericJsonParameter< T >::SCALAR_BOOL, agx::GenericJsonParameter< T >::SCALAR_INT, agx::GenericJsonParameter< T >::SCALAR_REAL, and agx::GenericJsonParameter< T >::STRING.
|
inline |
Store a generic property to json.
If group objects are used, then those has to be created in advance.
Definition at line 376 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_INT, agx::GenericJsonParameter< T >::SCALAR_REAL, agx::GenericJsonParameter< T >::STRING, agx::GenericJsonParameter< T >::writeValueBool(), agx::GenericJsonParameter< T >::writeValueInt(), agx::GenericJsonParameter< T >::writeValueReal(), agx::GenericJsonParameter< T >::writeValueString(), and agx::GenericJsonParameter< T >::writeValueVec3().
|
inline |
Writes a bool value to a json node.
Definition at line 352 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Writes an int value to a json node.
Definition at line 343 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Writes a real value to a json node.
Definition at line 319 of file GenericJsonParameter.h.
References agx::equivalent(), and agx::Infinity.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Writes a string value to a json node.
Definition at line 335 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::writeProperty().
|
inline |
Write a short array, at most 3 elements.
Definition at line 361 of file GenericJsonParameter.h.
Referenced by agx::GenericJsonParameter< T >::writeProperty().