Public Types | Public Member Functions | Static Public Member Functions | List of all members
sdf::SDF_VERSION_NAMESPACE::ParserConfig Class Reference

This class contains configuration options for the libsdformat parser. More...

#include <ParserConfig.hh>

Public Types

using SchemeToPathMap = std::map< std::string, std::vector< std::string > >
 type alias for the map from URI scheme to search directories More...
 

Public Member Functions

 ParserConfig ()
 Default constructor. More...
 
void AddURIPath (const std::string &_uri, const std::string &_path)
 Associate paths to a URI. More...
 
ConfigureResolveAutoInertials CalculateInertialConfiguration () const
 Get the current configuration for the CalculateInertial() function. More...
 
const CustomInertiaCalculatorCustomInertiaCalc () const
 Get the registered custom mesh MOI Calculator. More...
 
const std::vector< CustomModelParser > & CustomModelParsers () const
 Get the registered custom model parsers. More...
 
EnforcementPolicy DeprecatedElementsPolicy () const
 Get the current deprecated elements policy. More...
 
const std::function< std::string(const std::string &)> & FindFileCallback () const
 Get the find file callback function. More...
 
void RegisterCustomInertiaCalc (CustomInertiaCalculator _inertiaCalculator)
 Registers a custom Moment of Inertia Calculator for Meshes. More...
 
void RegisterCustomModelParser (CustomModelParser _modelParser)
 Registers a custom model parser. More...
 
void ResetDeprecatedElementsPolicy ()
 Resets the policy for deprecated elements so that it follows WarningsPolicy. More...
 
void SetCalculateInertialConfiguration (ConfigureResolveAutoInertials _configuration)
 Set the configuration for the CalculateInertial() function. More...
 
void SetDeprecatedElementsPolicy (EnforcementPolicy _policy)
 Set the policy for deprecated elements. More...
 
void SetFindCallback (std::function< std::string(const std::string &)> _cb)
 Set the callback to use when libsdformat can't find a file. More...
 
void SetStoreResolvedURIs (bool _resolveURI)
 Set the storeResolvedURIs flag value. More...
 
void SetStoreResovledURIs (bool _resolveURI)
 Set the storeResolvedURIs flag value. More...
 
void SetUnrecognizedElementsPolicy (EnforcementPolicy _policy)
 Set the policy for unrecogonized elements without an xmlns. More...
 
void SetWarningsPolicy (EnforcementPolicy _policy)
 Set the warning enforcment policy. More...
 
bool StoreResolvedURIs () const
 Get the storeResolvedURIs flag value. More...
 
EnforcementPolicy UnrecognizedElementsPolicy () const
 Get the current unrecognized elements policy. More...
 
bool URDFPreserveFixedJoint () const
 Get the preserveFixedJoint flag value. More...
 
void URDFSetPreserveFixedJoint (bool _preserveFixedJoint)
 Set the preserveFixedJoint flag. More...
 
const SchemeToPathMapURIPathMap () const
 Get the URI scheme to search directories map. More...
 
EnforcementPolicy WarningsPolicy () const
 Get the current warning enforcement policy. More...
 

Static Public Member Functions

static ParserConfigGlobalConfig ()
 Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all parsing operations that do not specify their own ParserConfig. More...
 

Detailed Description

This class contains configuration options for the libsdformat parser.

The configuration options include:

For backward compatibility, the functions sdf::setFindCallback() and sdf::addURIPath() update a singleton ParserConfig object, which can be retrieved by ParserConfig::GlobalConfig().

The functions sdf::readFile(), sdf::readString(), and sdf::Root::Load() have overloads that take a ParserConfig object. If the ParserConfig object is omitted, these functions will use the singleton ParserConfig object.

Example: To set an additional URI scheme search directory without affecting the global config,

// Copy the global config
// Add the new scheme to the config
config.AddURIPath("newScheme://", "path/to/directory");
// Use the new config when loading a new SDFormat file
sdf::Root root;
root.Load("path/to/file.sdf", config);
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:100
void AddURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
static ParserConfig & GlobalConfig()
Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all pars...
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:58
Errors Load(const std::string &_filename)
Parse the given SDF file, and generate objects based on types specified in the SDF file.

Member Typedef Documentation

◆ SchemeToPathMap

using sdf::SDF_VERSION_NAMESPACE::ParserConfig::SchemeToPathMap = std::map<std::string, std::vector<std::string> >

type alias for the map from URI scheme to search directories

Constructor & Destructor Documentation

◆ ParserConfig()

sdf::SDF_VERSION_NAMESPACE::ParserConfig::ParserConfig ( )

Default constructor.

Member Function Documentation

◆ AddURIPath()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::AddURIPath ( const std::string &  _uri,
const std::string &  _path 
)

Associate paths to a URI.

Example paramters: "model://", "/usr/share/models:~/.gazebo/models"

Parameters
[in]_uriURI that will be mapped to _path
[in]_pathColon separated set of paths.
See also
sdf::findFile() for the order of search operations

◆ CalculateInertialConfiguration()

ConfigureResolveAutoInertials sdf::SDF_VERSION_NAMESPACE::ParserConfig::CalculateInertialConfiguration ( ) const

Get the current configuration for the CalculateInertial() function.

Returns
Current set value of the ConfigureResolveAutoInertials enum

◆ CustomInertiaCalc()

const CustomInertiaCalculator& sdf::SDF_VERSION_NAMESPACE::ParserConfig::CustomInertiaCalc ( ) const

Get the registered custom mesh MOI Calculator.

Returns
registered mesh MOI Calculator.

◆ CustomModelParsers()

const std::vector<CustomModelParser>& sdf::SDF_VERSION_NAMESPACE::ParserConfig::CustomModelParsers ( ) const

Get the registered custom model parsers.

Returns
Vector of registered model parser callbacks.

◆ DeprecatedElementsPolicy()

EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::ParserConfig::DeprecatedElementsPolicy ( ) const

Get the current deprecated elements policy.

By default, the policy is the same as the overall WarningsPolicy, but it can be overriden by SetDeprecatedElementsPolicy. Once it is overriden, changing SetWarningsPolicy will not change the value of DeprecatedElementsPolicy unless ResetDeprecatedElementsPolicy is called.

Returns
The deperacted elements policy enum value

◆ FindFileCallback()

const std::function<std::string(const std::string &)>& sdf::SDF_VERSION_NAMESPACE::ParserConfig::FindFileCallback ( ) const

Get the find file callback function.

Returns
Immutable reference to the find file callback function

◆ GlobalConfig()

static ParserConfig& sdf::SDF_VERSION_NAMESPACE::ParserConfig::GlobalConfig ( )
static

Mutable access to a singleton ParserConfig that serves as the global ParserConfig object for all parsing operations that do not specify their own ParserConfig.

Returns
A mutable reference to the singleton ParserConfig object

◆ RegisterCustomInertiaCalc()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::RegisterCustomInertiaCalc ( CustomInertiaCalculator  _inertiaCalculator)

Registers a custom Moment of Inertia Calculator for Meshes.

Parameters
[in]_inertiaCalculatorCallback with signature as described in sdf/CustomInertiaCalcProperties.hh.

◆ RegisterCustomModelParser()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::RegisterCustomModelParser ( CustomModelParser  _modelParser)

Registers a custom model parser.

Parameters
[in]_modelParserCallback as described in sdf/InterfaceElements.hh.

◆ ResetDeprecatedElementsPolicy()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::ResetDeprecatedElementsPolicy ( )

Resets the policy for deprecated elements so that it follows WarningsPolicy.

◆ SetCalculateInertialConfiguration()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetCalculateInertialConfiguration ( ConfigureResolveAutoInertials  _configuration)

Set the configuration for the CalculateInertial() function.

Parameters
[in]_configurationThe configuration to set for the CalculateInertial() function

◆ SetDeprecatedElementsPolicy()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetDeprecatedElementsPolicy ( EnforcementPolicy  _policy)

Set the policy for deprecated elements.

Parameters
[in]_policyThe deprecated elements enforcement policy

◆ SetFindCallback()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetFindCallback ( std::function< std::string(const std::string &)>  _cb)

Set the callback to use when libsdformat can't find a file.

The callback should return a complete path to the requested file, or an empty string if the file was not found in the callback. Generally, the input argument is a URI or a file path (absolute or relative) obtained from a //include/uri element. For example, if the value custom://model_name is given in a //include/uri, sdf::findFile() may invoke the callback with the argument custom://model_name if it is unable to find a file using the steps listed in sdf::findfile().

Note, however, the input is not limited to URIs and file paths, and it is left up to the callback to interpret the contents of the input string.

Parameters
[in]_cbThe callback function.
See also
sdf::findFile() for the order of search operations

◆ SetStoreResolvedURIs()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetStoreResolvedURIs ( bool  _resolveURI)

Set the storeResolvedURIs flag value.

Parameters
[in]_resolveURITrue to make the parser attempt to resolve any URIs found and store them. False to preserve original URIs

The Parser will use the FindFileCallback provided to attempt to resolve URIs in the Mesh, Material, Heightmap, and Skybox DOM objects If the FindFileCallback provides a non-empty string, the URI will be stored in the DOM object, and the original (unresolved) URI will be stored in the underlying Element.

◆ SetStoreResovledURIs()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetStoreResovledURIs ( bool  _resolveURI)

Set the storeResolvedURIs flag value.

See also
SetStoreResolvedURIs

◆ SetUnrecognizedElementsPolicy()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetUnrecognizedElementsPolicy ( EnforcementPolicy  _policy)

Set the policy for unrecogonized elements without an xmlns.

Parameters
[in]_policyThe unrecognized elements enforcement policy

◆ SetWarningsPolicy()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::SetWarningsPolicy ( EnforcementPolicy  _policy)

Set the warning enforcment policy.

Parameters
[in]_policypolicy enum value to set

◆ StoreResolvedURIs()

bool sdf::SDF_VERSION_NAMESPACE::ParserConfig::StoreResolvedURIs ( ) const

Get the storeResolvedURIs flag value.

Returns
True if the parser will attempt to resolve any URIs found and store them. False to preserve original URIs

◆ UnrecognizedElementsPolicy()

EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::ParserConfig::UnrecognizedElementsPolicy ( ) const

Get the current unrecognized elements policy.

Returns
The unrecognized elements policy enum value

◆ URDFPreserveFixedJoint()

bool sdf::SDF_VERSION_NAMESPACE::ParserConfig::URDFPreserveFixedJoint ( ) const

Get the preserveFixedJoint flag value.

Returns
True to preserve fixed joints, false to reduce the fixed joints and merge the child link into the parent.

◆ URDFSetPreserveFixedJoint()

void sdf::SDF_VERSION_NAMESPACE::ParserConfig::URDFSetPreserveFixedJoint ( bool  _preserveFixedJoint)

Set the preserveFixedJoint flag.

Parameters
[in]_preserveFixedJointTrue to preserve fixed joints, false to reduce the fixed joints and merge the child link into the parent.

◆ URIPathMap()

const SchemeToPathMap& sdf::SDF_VERSION_NAMESPACE::ParserConfig::URIPathMap ( ) const

Get the URI scheme to search directories map.

Returns
Immutable reference to the URI scheme to search directories map

◆ WarningsPolicy()

EnforcementPolicy sdf::SDF_VERSION_NAMESPACE::ParserConfig::WarningsPolicy ( ) const

Get the current warning enforcement policy.

Returns
The warning enforcement policy enum value

The documentation for this class was generated from the following file: