Drake
PackageMap Class Reference

Maps ROS package names to their full path on the local file system. More...

#include <multibody/parsers/package_map.h>

Public Member Functions

 PackageMap ()
 A constructor that initializes an empty map. More...
 
void Add (const std::string &package_name, const std::string &package_path)
 Adds package package_name and its path, package_path. More...
 
bool Contains (const std::string &package_name) const
 Returns true if and only if this PackageMap contains package_name. More...
 
int size () const
 Returns the number of entries in this PackageMap. More...
 
const std::string & GetPath (const std::string &package_name) const
 Obtains the path associated with package package_name. More...
 
void PopulateFromFolder (const std::string &path)
 Crawls down the directory tree starting at path searching for directories containing the file package.xml. More...
 
void PopulateFromEnvironment (const std::string &environment_variable)
 Obtains one or more paths from environment variable environment_variable. More...
 
void PopulateUpstreamToDrake (const std::string &model_file)
 Crawls up the directory tree from model_file to drake-distro/drake searching for package.xml files. More...
 
Does not allow copy, move, or assignment
 PackageMap (const PackageMap &)=delete
 
PackageMapoperator= (const PackageMap &)=delete
 
 PackageMap (PackageMap &&)=delete
 
PackageMapoperator= (PackageMap &&)=delete
 

Friends

std::ostream & operator<< (std::ostream &out, const PackageMap &package_map)
 

Detailed Description

Maps ROS package names to their full path on the local file system.

It is used by the SDF and URDF parsers when parsing files that reference ROS packages for resources like mesh files.

Constructor & Destructor Documentation

PackageMap ( const PackageMap )
delete
PackageMap ( PackageMap &&  )
delete

A constructor that initializes an empty map.

Member Function Documentation

void Add ( const std::string &  package_name,
const std::string &  package_path 
)

Adds package package_name and its path, package_path.

Aborts if package_name is already present in this PackageMap, or if package_path does not exist.

Here is the caller graph for this function:

bool Contains ( const std::string &  package_name) const

Returns true if and only if this PackageMap contains package_name.

Here is the caller graph for this function:

const string & GetPath ( const std::string &  package_name) const

Obtains the path associated with package package_name.

Aborts if no package named package_name exists in this PackageMap.

Here is the call graph for this function:

Here is the caller graph for this function:

PackageMap& operator= ( PackageMap &&  )
delete
PackageMap& operator= ( const PackageMap )
delete
void PopulateFromEnvironment ( const std::string &  environment_variable)

Obtains one or more paths from environment variable environment_variable.

Crawls downard through the directory tree(s) starting from the path(s) searching for package.xml files. For each of these files, this method adds a new entry into this PackageMap where the key is the package name as specified within package.xml and the value is the path to the package.xml file. Multiple paths can be specified by separating them using the ':' symbol. For example, the environment variable can contain [path 1]:[path 2]:[path 3] to search three different paths.

Here is the call graph for this function:

void PopulateFromFolder ( const std::string &  path)

Crawls down the directory tree starting at path searching for directories containing the file package.xml.

For each of these directories, this method adds a new entry into this PackageMap where the key is the package name as specified within package.xml and the directory's path is the value.

void PopulateUpstreamToDrake ( const std::string &  model_file)

Crawls up the directory tree from model_file to drake-distro/drake searching for package.xml files.

Adds the packages described by these package.xml files. If model_file is not in drake-distro/drake, this method returns without doing anything.

Parameters
[in]model_fileThe model file whose directory is the start of the search for package.xml files. This file must be an SDF or URDF file.

Here is the call graph for this function:

Here is the caller graph for this function:

int size ( ) const

Returns the number of entries in this PackageMap.

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PackageMap package_map 
)
friend

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