Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
tesseract_common::GeneralResourceLocator Class Reference

A general resource loaders using environment variable. More...

#include <resource_locator.h>

Inheritance diagram for tesseract_common::GeneralResourceLocator:
Inheritance graph
[legend]

Public Types

using ConstPtr = std::shared_ptr< const GeneralResourceLocator >
 
using Ptr = std::shared_ptr< GeneralResourceLocator >
 
- Public Types inherited from tesseract_common::ResourceLocator
using ConstPtr = std::shared_ptr< const ResourceLocator >
 
using Ptr = std::shared_ptr< ResourceLocator >
 

Public Member Functions

bool addPath (const std::filesystem::path &path)
 Add path to the resource locator. More...
 
 GeneralResourceLocator (const GeneralResourceLocator &)=default
 
 GeneralResourceLocator (const std::vector< std::filesystem::path > &paths, const std::vector< std::string > &environment_variables={ "TESSERACT_RESOURCE_PATH", "ROS_PACKAGE_PATH" })
 Construct a new General Resource Locator object using the provided paths and/or the TESSERACT_RESOURCE_PATH environment variable. More...
 
 GeneralResourceLocator (const std::vector< std::string > &environment_variables={ "TESSERACT_RESOURCE_PATH", "ROS_PACKAGE_PATH" })
 Construct a new General Resource Locator object using the TESSERACT_RESOURCE_PATH environment variable. More...
 
 GeneralResourceLocator (GeneralResourceLocator &&)=default
 
bool loadEnvironmentVariable (const std::string &environment_variable)
 Load paths from an environment variable. More...
 
std::shared_ptr< ResourcelocateResource (const std::string &url) const override
 Locate a resource based on a URL. More...
 
bool operator!= (const GeneralResourceLocator &rhs) const
 
GeneralResourceLocatoroperator= (const GeneralResourceLocator &)=default
 
GeneralResourceLocatoroperator= (GeneralResourceLocator &&)=default
 
bool operator== (const GeneralResourceLocator &rhs) const
 
 ~GeneralResourceLocator () override=default
 
- Public Member Functions inherited from tesseract_common::ResourceLocator
bool operator!= (const ResourceLocator &rhs) const
 
bool operator== (const ResourceLocator &rhs) const
 
virtual ~ResourceLocator ()=default
 

Private Member Functions

void processToken (const std::string &token)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::unordered_map< std::string, std::string > package_paths_
 

Friends

class boost::serialization::access
 
struct tesseract_common::Serialization
 

Detailed Description

A general resource loaders using environment variable.

Also can set this environment variable TESSERACT_RESOURCE_PATH with ':' separated directories and then use the directires as package names

Definition at line 84 of file resource_locator.h.

Member Typedef Documentation

◆ ConstPtr

Definition at line 88 of file resource_locator.h.

◆ Ptr

Definition at line 87 of file resource_locator.h.

Constructor & Destructor Documentation

◆ GeneralResourceLocator() [1/4]

tesseract_common::GeneralResourceLocator::GeneralResourceLocator ( const std::vector< std::string > &  environment_variables = { "TESSERACT_RESOURCE_PATH", "ROS_PACKAGE_PATH" })

Construct a new General Resource Locator object using the TESSERACT_RESOURCE_PATH environment variable.

Parameters
environment_variablesA vector of environment variables to search for paths

Definition at line 60 of file resource_locator.cpp.

◆ GeneralResourceLocator() [2/4]

tesseract_common::GeneralResourceLocator::GeneralResourceLocator ( const std::vector< std::filesystem::path > &  paths,
const std::vector< std::string > &  environment_variables = { "TESSERACT_RESOURCE_PATH", "ROS_PACKAGE_PATH" } 
)

Construct a new General Resource Locator object using the provided paths and/or the TESSERACT_RESOURCE_PATH environment variable.

Parameters
pathsA vector of paths to search for resources
environment_variablesA vector of environment variables to search for paths

Definition at line 68 of file resource_locator.cpp.

◆ GeneralResourceLocator() [3/4]

tesseract_common::GeneralResourceLocator::GeneralResourceLocator ( const GeneralResourceLocator )
default

◆ GeneralResourceLocator() [4/4]

tesseract_common::GeneralResourceLocator::GeneralResourceLocator ( GeneralResourceLocator &&  )
default

◆ ~GeneralResourceLocator()

tesseract_common::GeneralResourceLocator::~GeneralResourceLocator ( )
overridedefault

Member Function Documentation

◆ addPath()

bool tesseract_common::GeneralResourceLocator::addPath ( const std::filesystem::path &  path)

Add path to the resource locator.

Parameters
pathThe path to add. Must be a directory
Returns
true Success
false Directory does not exist

Definition at line 101 of file resource_locator.cpp.

◆ loadEnvironmentVariable()

bool tesseract_common::GeneralResourceLocator::loadEnvironmentVariable ( const std::string &  environment_variable)

Load paths from an environment variable.

Parameters
environment_variableThe environment variable to load paths from
Returns
true Success
false Environment variable does not exist

Definition at line 82 of file resource_locator.cpp.

◆ locateResource()

std::shared_ptr< Resource > tesseract_common::GeneralResourceLocator::locateResource ( const std::string &  url) const
overridevirtual

Locate a resource based on a URL.

Parameters
urlThe URL of the resource
Returns
A shared pointer to a Resource instance, or nullptr if not found

Implements tesseract_common::ResourceLocator.

Definition at line 169 of file resource_locator.cpp.

◆ operator!=()

bool tesseract_common::GeneralResourceLocator::operator!= ( const GeneralResourceLocator rhs) const

Definition at line 211 of file resource_locator.cpp.

◆ operator=() [1/2]

GeneralResourceLocator& tesseract_common::GeneralResourceLocator::operator= ( const GeneralResourceLocator )
default

◆ operator=() [2/2]

GeneralResourceLocator& tesseract_common::GeneralResourceLocator::operator= ( GeneralResourceLocator &&  )
default

◆ operator==()

bool tesseract_common::GeneralResourceLocator::operator== ( const GeneralResourceLocator rhs) const

Definition at line 210 of file resource_locator.cpp.

◆ processToken()

void tesseract_common::GeneralResourceLocator::processToken ( const std::string &  token)
private

Definition at line 113 of file resource_locator.cpp.

◆ serialize()

template<class Archive >
void tesseract_common::GeneralResourceLocator::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Definition at line 214 of file resource_locator.cpp.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 136 of file resource_locator.h.

◆ tesseract_common::Serialization

friend struct tesseract_common::Serialization
friend

Definition at line 137 of file resource_locator.h.

Member Data Documentation

◆ package_paths_

std::unordered_map<std::string, std::string> tesseract_common::GeneralResourceLocator::package_paths_
private

Definition at line 141 of file resource_locator.h.


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


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40