Classes | Macros | Typedefs | Functions | Variables
SDF

Classes

class  sdf::SDF_VERSION_NAMESPACE::AssertionInternalError
 Class for generating Exceptions which come from sdf assertions. They include information about the assertion expression violated, function where problem appeared and assertion debug message. More...
 
class  sdf::SDF_VERSION_NAMESPACE::Console
 Message, error, warning, and logging functionality. More...
 
class  sdf::SDF_VERSION_NAMESPACE::ConsolePrivate
 
class  sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream
 An ostream-like class that we'll use for logging. More...
 
class  sdf::SDF_VERSION_NAMESPACE::Element
 SDF Element class. More...
 
class  sdf::SDF_VERSION_NAMESPACE::ElementPrivate
 
class  sdf::SDF_VERSION_NAMESPACE::Exception
 Class for generating exceptions. More...
 
class  sdf::SDF_VERSION_NAMESPACE::InternalError
 Class for generating Internal Gazebo Errors: those errors which should never happend and represent programming bugs. More...
 
class  sdf::SDF_VERSION_NAMESPACE::SDF
 Base SDF class. More...
 

Macros

#define sdfdbg   (sdf::Console::Instance()->Log("Dbg", __FILE__, __LINE__))
 Output a debug message. More...
 
#define sdferr
 Output an error message. More...
 
#define sdfmsg
 Output a message. More...
 
#define sdfthrow(msg)
 This macro logs an error to the throw stream and throws an exception that contains the file name and line number. More...
 
#define sdfwarn
 Output a warning message. More...
 

Typedefs

typedef std::shared_ptr< Consolesdf::SDF_VERSION_NAMESPACE::ConsolePtr
 

Functions

 sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::ConsolePrivate ()
 Constructor. More...
 
 sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::ConsoleStream (std::ostream *_stream)
 Constructor. More...
 
virtual sdf::SDF_VERSION_NAMESPACE::Console::~Console ()
 Destructor. More...
 
GZ_SDFORMAT_VISIBLE void sdf::SDF_VERSION_NAMESPACE::addURIPath (const std::string &_uri, const std::string &_path)
 Associate paths to a URI. More...
 
static void sdf::SDF_VERSION_NAMESPACE::Console::Clear ()
 Clear out the current console to make room for a new one. More...
 
ConsoleStreamsdf::SDF_VERSION_NAMESPACE::Console::ColorMsg (const std::string &lbl, const std::string &file, unsigned int line, int color)
 Use this to output a colored message to the terminal. More...
 
GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile (const std::string &_filename, bool _searchLocalPath, bool _useCallback, const ParserConfig &_config)
 Find the absolute path of a file. More...
 
GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile (const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
 Find the absolute path of a file. More...
 
GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile (sdf::Errors &_errors, const std::string &_filename, bool _searchLocalPath, bool _useCallback, const ParserConfig &_config)
 Find the absolute path of a file. More...
 
GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile (sdf::Errors &_errors, const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
 Find the absolute path of a file. More...
 
template<typename T >
std::pair< T, bool > sdf::SDF_VERSION_NAMESPACE::Element::Get (const std::string &_key, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Get (const std::string &_key, T &_param, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
sdf::SDF_VERSION_NAMESPACE::Element::Get (const std::string &_key="") const
 Get the value of a key. More...
 
template<typename T >
std::pair< T, bool > sdf::SDF_VERSION_NAMESPACE::Element::Get (sdf::Errors &_errors, const std::string &_key, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Get (sdf::Errors &_errors, const std::string &_key, T &_param, const T &_defaultValue) const
 Get the value of a key. More...
 
template<typename T >
sdf::SDF_VERSION_NAMESPACE::Element::Get (sdf::Errors &_errors, const std::string &_key="") const
 Get the value of a key. More...
 
ConsoleStreamsdf::SDF_VERSION_NAMESPACE::Console::GetLogStream ()
 Get the current log stream object. More...
 
ConsoleStreamsdf::SDF_VERSION_NAMESPACE::Console::GetMsgStream ()
 Get the current message stream object. More...
 
std::ostream * sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::GetStream ()
 Get the current stream object. More...
 
static ConsolePtr sdf::SDF_VERSION_NAMESPACE::Console::Instance ()
 Return an instance to this class. More...
 
ConsoleStreamsdf::SDF_VERSION_NAMESPACE::Console::Log (const std::string &lbl, const std::string &file, unsigned int line)
 Use this to output a message to a log file at $HOME/.sdformat/sdformat.log. More...
 
template<class T >
ConsoleStreamsdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::operator<< (const T &_rhs)
 Redirect whatever is passed in to both our ostream (if non-NULL) and the log file (if open). More...
 
void sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::Prefix (const std::string &_lbl, const std::string &_file, unsigned int _line, int _color)
 Print a prefix to both terminal and log file. More...
 
template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Set (const T &_value)
 Set the value of this element. More...
 
template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Set (sdf::Errors &_errors, const T &_value)
 Set the value of this element. More...
 
GZ_SDFORMAT_VISIBLE void sdf::SDF_VERSION_NAMESPACE::setFindCallback (std::function< std::string(const std::string &)> _cb)
 Set the callback to use when SDF can't find a file. More...
 
void sdf::SDF_VERSION_NAMESPACE::Console::SetQuiet (bool _q)
 Set quiet output. More...
 
void sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::SetStream (std::ostream *_stream)
 Set the stream object. More...
 

Variables

std::ofstream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::logFileStream
 logfile stream More...
 
Console::ConsoleStream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::logStream
 log stream More...
 
Console::ConsoleStream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::msgStream
 message stream More...
 

Detailed Description

Macro Definition Documentation

◆ sdfdbg

#define sdfdbg   (sdf::Console::Instance()->Log("Dbg", __FILE__, __LINE__))

Output a debug message.

◆ sdferr

#define sdferr
Value:
(sdf::Console::Instance()->ColorMsg("Error", \
__FILE__, __LINE__, 31))

Output an error message.

◆ sdfmsg

#define sdfmsg
Value:
(sdf::Console::Instance()->ColorMsg("Msg", \
__FILE__, __LINE__, 32))

Output a message.

◆ sdfthrow

#define sdfthrow (   msg)
Value:
{std::ostringstream throwStream;\
throwStream << msg << std::endl << std::flush;\
throw sdf::Exception(__FILE__, __LINE__, throwStream.str()); }

This macro logs an error to the throw stream and throws an exception that contains the file name and line number.

◆ sdfwarn

#define sdfwarn
Value:
(sdf::Console::Instance()->ColorMsg("Warning", \
__FILE__, __LINE__, 33))

Output a warning message.

Typedef Documentation

◆ ConsolePtr

Function Documentation

◆ ConsolePrivate()

sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::ConsolePrivate ( )
inline

Constructor.

◆ ConsoleStream()

sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::ConsoleStream ( std::ostream *  _stream)
inlineexplicit

Constructor.

Parameters
[in]_streamPointer to an output stream operator. Can be NULL/nullptr.

◆ ~Console()

virtual sdf::SDF_VERSION_NAMESPACE::Console::~Console ( )
virtual

Destructor.

◆ addURIPath()

GZ_SDFORMAT_VISIBLE void sdf::SDF_VERSION_NAMESPACE::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.

◆ Clear()

static void sdf::SDF_VERSION_NAMESPACE::Console::Clear ( )
static

Clear out the current console to make room for a new one.

◆ ColorMsg()

ConsoleStream& sdf::SDF_VERSION_NAMESPACE::Console::ColorMsg ( const std::string &  lbl,
const std::string &  file,
unsigned int  line,
int  color 
)

Use this to output a colored message to the terminal.

Parameters
[in]_lblText label
[in]_fileFile containing the error
[in]_lineLine containing the error
[in]_colorColor to make the label
Returns
Reference to an output stream

◆ findFile() [1/4]

GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile ( const std::string &  _filename,
bool  _searchLocalPath,
bool  _useCallback,
const ParserConfig _config 
)

Find the absolute path of a file.

This overload uses the URI path map and and the callback function configured in the input ParserConfig object instead of their global counterparts.

Parameters
[in]_filenameName of the file to find.
[in]_searchLocalPathTrue to search for the file in the current working directory.
[in]_useCallbackTrue to find a file based on a registered callback if the file is not found via the normal mechanism.
[in]_configCustom parser configuration
Returns
File's full path.

◆ findFile() [2/4]

GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile ( const std::string &  _filename,
bool  _searchLocalPath = true,
bool  _useCallback = false 
)

Find the absolute path of a file.

The search order in the function is as follows:

  1. Using the global URI path map, search in paths associated with the URI scheme of the input.
  2. If enabled via _searchLocalPath, prepend the input with the current working directory and check if the result path exists.
  3. Seach in the path defined by the macro SDF_SHARE_PATH.
  4. Search in the the libsdformat install path. The path is formed by has the pattern SDF_SHARE_PATH/sdformat<major version>/<version>/
  5. Directly check if the input path exists in the filesystem.
  6. Seach in the path defined by the environment variable SDF_PATH.
  7. If enabled via _useCallback and the global callback function is set, invoke the function and return its result.
Parameters
[in]_filenameName of the file to find.
[in]_searchLocalPathTrue to search for the file in the current working directory.
[in]_useCallbackTrue to find a file based on a registered callback if the file is not found via the normal mechanism.
Returns
File's full path.

◆ findFile() [3/4]

GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile ( sdf::Errors _errors,
const std::string &  _filename,
bool  _searchLocalPath,
bool  _useCallback,
const ParserConfig _config 
)

Find the absolute path of a file.

This overload uses the URI path map and and the callback function configured in the input ParserConfig object instead of their global counterparts.

Parameters
[out]_errorsVector of errors.
[in]_filenameName of the file to find.
[in]_searchLocalPathTrue to search for the file in the current working directory.
[in]_useCallbackTrue to find a file based on a registered callback if the file is not found via the normal mechanism.
[in]_configCustom parser configuration.
Returns
File's full path.

◆ findFile() [4/4]

GZ_SDFORMAT_VISIBLE std::string sdf::SDF_VERSION_NAMESPACE::findFile ( sdf::Errors _errors,
const std::string &  _filename,
bool  _searchLocalPath = true,
bool  _useCallback = false 
)

Find the absolute path of a file.

The search order in the function is as follows:

  1. Using the global URI path map, search in paths associated with the URI scheme of the input.
  2. Seach in the path defined by the macro SDF_SHARE_PATH.
  3. Search in the the libsdformat install path. The path is formed by has the pattern SDF_SHARE_PATH/sdformat<major version>/<version>/
  4. Directly check if the input path exists in the filesystem.
  5. Seach in the path defined by the environment variable SDF_PATH.
  6. If enabled via _searchLocalPath, prepend the input with the current working directory and check if the result path exists.
  7. If enabled via _useCallback and the global callback function is set, invoke the function and return its result.
Parameters
[out]_errorsVector of errors.
[in]_filenameName of the file to find.
[in]_searchLocalPathTrue to search for the file in the current working directory.
[in]_useCallbackTrue to find a file based on a registered callback if the file is not found via the normal mechanism.
Returns
File's full path.

◆ Get() [1/6]

template<typename T >
std::pair< T, bool > sdf::SDF_VERSION_NAMESPACE::Element::Get ( const std::string &  _key,
const T &  _defaultValue 
) const

Get the value of a key.

Parameters
[in]_keythe name of a child attribute or element.
[in]_defaultValuea default value to use if _key is not found.
Returns
A pair where the first element is the value of _key, and the second element is true when the _key was found and false otherwise.

References sdferr, and sdf::SDF_VERSION_NAMESPACE::internal::throwOrPrintError().

◆ Get() [2/6]

template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Get ( const std::string &  _key,
T &  _param,
const T &  _defaultValue 
) const

Get the value of a key.

Parameters
[in]_keythe name of a child attribute or element.
[out]_paramthe parameter output
[in]_defaultValuea default value to use if _key is not found.
Returns
True when the _key was found and false otherwise.

◆ Get() [3/6]

template<typename T >
T sdf::SDF_VERSION_NAMESPACE::Element::Get ( const std::string &  _key = "") const

Get the value of a key.

This function assumes the _key exists.

Parameters
[in]_keythe name of a child attribute or element.
Returns
The value of the _key.
See also
std::pair<T, bool> Get(const std::string &_key, const T &_defaultValue)

◆ Get() [4/6]

template<typename T >
std::pair< T, bool > sdf::SDF_VERSION_NAMESPACE::Element::Get ( sdf::Errors _errors,
const std::string &  _key,
const T &  _defaultValue 
) const

Get the value of a key.

Parameters
[out]_errorsVector of errors.
[in]_keythe name of a child attribute or element.
[in]_defaultValuea default value to use if _key is not found.
Returns
A pair where the first element is the value of _key, and the second element is true when the _key was found and false otherwise.

References sdf::SDF_VERSION_NAMESPACE::Element::GetAttribute(), sdf::SDF_VERSION_NAMESPACE::Element::GetElementDescription(), sdf::SDF_VERSION_NAMESPACE::Element::GetElementImpl(), sdf::SDF_VERSION_NAMESPACE::Element::HasElement(), and sdf::SDF_VERSION_NAMESPACE::Element::HasElementDescription().

◆ Get() [5/6]

template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Get ( sdf::Errors _errors,
const std::string &  _key,
T &  _param,
const T &  _defaultValue 
) const

Get the value of a key.

Parameters
[out]_errorsVector of errors.
[in]_keythe name of a child attribute or element.
[out]_paramthe parameter output
[in]_defaultValuea default value to use if _key is not found.
Returns
True when the _key was found and false otherwise.

◆ Get() [6/6]

template<typename T >
T sdf::SDF_VERSION_NAMESPACE::Element::Get ( sdf::Errors _errors,
const std::string &  _key = "" 
) const

Get the value of a key.

This function assumes the _key exists.

Parameters
[out]_errorsVector of errors.
[in]_keythe name of a child attribute or element.
Returns
The value of the _key.
See also
std::pair<T, bool> Get(const std::string &_key, const T &_defaultValue)

◆ GetLogStream()

ConsoleStream& sdf::SDF_VERSION_NAMESPACE::Console::GetLogStream ( )

Get the current log stream object.

This can be useful for redirecting the output, for example, to a std::stringstream for testing.

Returns
Mutable reference to current log stream object.

◆ GetMsgStream()

ConsoleStream& sdf::SDF_VERSION_NAMESPACE::Console::GetMsgStream ( )

Get the current message stream object.

This can be useful for redirecting the output, for example, to a std::stringstream for testing.

Returns
Mutable reference to current message stream object.

◆ GetStream()

std::ostream* sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::GetStream ( )

Get the current stream object.

Returns
Pointer to current stream object.

◆ Instance()

static ConsolePtr sdf::SDF_VERSION_NAMESPACE::Console::Instance ( )
static

Return an instance to this class.

Referenced by sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::operator<<().

◆ Log()

ConsoleStream& sdf::SDF_VERSION_NAMESPACE::Console::Log ( const std::string &  lbl,
const std::string &  file,
unsigned int  line 
)

Use this to output a message to a log file at $HOME/.sdformat/sdformat.log.

To disable this log file, define the following symbol when compiling: SDFORMAT_DISABLE_CONSOLE_LOGFILE

Returns
Reference to output stream

◆ operator<<()

template<class T >
ConsoleStream& sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::operator<< ( const T &  _rhs)

Redirect whatever is passed in to both our ostream (if non-NULL) and the log file (if open).

Parameters
[in]_rhsContent to be logged.
Returns
Reference to myself.

◆ Prefix()

void sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::Prefix ( const std::string &  _lbl,
const std::string &  _file,
unsigned int  _line,
int  _color 
)

Print a prefix to both terminal and log file.

Parameters
[in]_lblText label
[in]_fileFile containing the error
[in]_lineLine containing the error
[in]_colorColor to make the label. Used only on terminal.

◆ Set() [1/2]

template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Set ( const T &  _value)

Set the value of this element.

Parameters
[in]_valuethe value to set.
Returns
True if the value was successfully set, false otherwise.

References sdferr, and sdf::SDF_VERSION_NAMESPACE::internal::throwOrPrintError().

◆ Set() [2/2]

template<typename T >
bool sdf::SDF_VERSION_NAMESPACE::Element::Set ( sdf::Errors _errors,
const T &  _value 
)

Set the value of this element.

Parameters
[out]_errorsVector of errors.
[in]_valuethe value to set.
Returns
True if the value was successfully set, false otherwise.

◆ setFindCallback()

GZ_SDFORMAT_VISIBLE void sdf::SDF_VERSION_NAMESPACE::setFindCallback ( std::function< std::string(const std::string &)>  _cb)

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

The callback should return a complete path to the requested file, or and empty string if the file was not found in the callback.

Parameters
[in]_cbThe callback function.

◆ SetQuiet()

void sdf::SDF_VERSION_NAMESPACE::Console::SetQuiet ( bool  _q)

Set quiet output.

Parameters
[in]qTrue to prevent warning

◆ SetStream()

void sdf::SDF_VERSION_NAMESPACE::Console::ConsoleStream::SetStream ( std::ostream *  _stream)

Set the stream object.

Parameters
[in]_streamPointer to an output stream. This can be useful for redirecting the output, for example, to a std::stringstream for testing.

Variable Documentation

◆ logFileStream

std::ofstream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::logFileStream

logfile stream

◆ logStream

Console::ConsoleStream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::logStream

log stream

◆ msgStream

Console::ConsoleStream sdf::SDF_VERSION_NAMESPACE::ConsolePrivate::msgStream

message stream

sdf::SDF_VERSION_NAMESPACE::Console::Instance
static ConsolePtr Instance()
Return an instance to this class.
sdf::SDF_VERSION_NAMESPACE::Exception
Class for generating exceptions.
Definition: Exception.hh:48