Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
tesseract_common::BytesResource Class Reference

#include <resource_locator.h>

Inheritance diagram for tesseract_common::BytesResource:
Inheritance graph
[legend]
Collaboration diagram for tesseract_common::BytesResource:
Collaboration graph
[legend]

Public Member Functions

 BytesResource ()=default
 This is for boost serialization do not use directly. More...
 
 BytesResource (std::string url, std::vector< uint8_t > bytes, ResourceLocator::ConstPtr parent=nullptr)
 
 BytesResource (std::string url, const uint8_t *bytes, size_t bytes_len, ResourceLocator::ConstPtr parent=nullptr)
 
 ~BytesResource () override=default
 
 BytesResource (const BytesResource &)=default
 
BytesResourceoperator= (const BytesResource &)=default
 
 BytesResource (BytesResource &&)=default
 
BytesResourceoperator= (BytesResource &&)=default
 
bool isFile () const override final
 Returns true if the located resource is a local file. More...
 
std::string getUrl () const override final
 Get the original URL used to locate the file. More...
 
std::string getFilePath () const override final
 Get the file path of the resource. Only valid if isFile() is true. More...
 
std::vector< uint8_t > getResourceContents () const override final
 Get the resource as bytes. This function may block. More...
 
std::shared_ptr< std::istream > getResourceContentStream () const override final
 Get the resource as a std::istream. This function and the returned stream may block. More...
 
Resource::Ptr locateResource (const std::string &url) const override final
 Locate a resource based on a URL. More...
 
bool operator== (const BytesResource &rhs) const
 
bool operator!= (const BytesResource &rhs) const
 
- Public Member Functions inherited from tesseract_common::Resource
virtual bool isFile () const =0
 Returns true if the located resource is a local file. More...
 
virtual std::string getUrl () const =0
 Get the original URL used to locate the file. More...
 
virtual std::string getFilePath () const =0
 Get the file path of the resource. Only valid if isFile() is true. More...
 
virtual std::vector< uint8_t > getResourceContents () const =0
 Get the resource as bytes. This function may block. More...
 
virtual std::shared_ptr< std::istream > getResourceContentStream () const =0
 Get the resource as a std::istream. This function and the returned stream may block. More...
 
bool operator== (const Resource &rhs) const
 
bool operator!= (const Resource &rhs) const
 
- Public Member Functions inherited from tesseract_common::ResourceLocator
virtual ~ResourceLocator ()=default
 
virtual std::shared_ptr< ResourcelocateResource (const std::string &url) const =0
 Locate a resource based on a URL. More...
 
bool operator== (const ResourceLocator &rhs) const
 
bool operator!= (const ResourceLocator &rhs) const
 

Private Member Functions

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

Private Attributes

std::string url_
 
std::vector< uint8_t > bytes_
 
ResourceLocator::ConstPtr parent_
 

Friends

class boost::serialization::access
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ BytesResource() [1/5]

tesseract_common::BytesResource::BytesResource ( )
default

This is for boost serialization do not use directly.

◆ BytesResource() [2/5]

tesseract_common::BytesResource::BytesResource ( std::string  url,
std::vector< uint8_t >  bytes,
ResourceLocator::ConstPtr  parent = nullptr 
)

◆ BytesResource() [3/5]

tesseract_common::BytesResource::BytesResource ( std::string  url,
const uint8_t *  bytes,
size_t  bytes_len,
ResourceLocator::ConstPtr  parent = nullptr 
)

◆ ~BytesResource()

tesseract_common::BytesResource::~BytesResource ( )
overridedefault

◆ BytesResource() [4/5]

tesseract_common::BytesResource::BytesResource ( const BytesResource )
default

◆ BytesResource() [5/5]

tesseract_common::BytesResource::BytesResource ( BytesResource &&  )
default

Member Function Documentation

◆ getFilePath()

std::string tesseract_common::BytesResource::getFilePath ( ) const
finaloverridevirtual

Get the file path of the resource. Only valid if isFile() is true.

Returns
The file path to the resource

Implements tesseract_common::Resource.

◆ getResourceContents()

std::vector< uint8_t > tesseract_common::BytesResource::getResourceContents ( ) const
finaloverridevirtual

Get the resource as bytes. This function may block.

Returns
Resource bytes as a uint8_t vector

Implements tesseract_common::Resource.

◆ getResourceContentStream()

std::shared_ptr< std::istream > tesseract_common::BytesResource::getResourceContentStream ( ) const
finaloverridevirtual

Get the resource as a std::istream. This function and the returned stream may block.

Returns
A std::istream shared pointer for the resource data

Implements tesseract_common::Resource.

◆ getUrl()

std::string tesseract_common::BytesResource::getUrl ( ) const
finaloverridevirtual

Get the original URL used to locate the file.

Returns
The URL of the resource

Implements tesseract_common::Resource.

◆ isFile()

bool tesseract_common::BytesResource::isFile ( ) const
finaloverridevirtual

Returns true if the located resource is a local file.

Returns
true if the resource is a local file, otherwise false

Implements tesseract_common::Resource.

◆ locateResource()

Resource::Ptr tesseract_common::BytesResource::locateResource ( const std::string &  url) const
finaloverridevirtual

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.

◆ operator!=()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

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

◆ serialize()

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

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ bytes_

std::vector<uint8_t> tesseract_common::BytesResource::bytes_
private

◆ parent_

ResourceLocator::ConstPtr tesseract_common::BytesResource::parent_
private

◆ url_

std::string tesseract_common::BytesResource::url_
private

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