26#ifndef TESSERACT_COMMON_RESOURCE_LOCATOR_H
27#define TESSERACT_COMMON_RESOURCE_LOCATOR_H
31#include <boost/serialization/access.hpp>
45 using Ptr = std::shared_ptr<ResourceLocator>;
46 using ConstPtr = std::shared_ptr<const ResourceLocator>;
56 virtual std::shared_ptr<Resource>
locateResource(
const std::string& url)
const = 0;
63 template <
class Archive>
64 void serialize(Archive& ar,
const unsigned int version);
75 using Ptr = std::shared_ptr<GeneralResourceLocator>;
76 using ConstPtr = std::shared_ptr<const GeneralResourceLocator>;
84 std::shared_ptr<Resource>
locateResource(
const std::string& url)
const override;
91 template <
class Archive>
92 void serialize(Archive& ar,
const unsigned int version);
101 using Ptr = std::shared_ptr<Resource>;
144 template <
class Archive>
145 void serialize(Archive& ar,
const unsigned int version);
154 using Ptr = std::shared_ptr<SimpleLocatedResource>;
155 using ConstPtr = std::shared_ptr<const SimpleLocatedResource>;
173 bool isFile() const override final;
175 std::
string getUrl() const override final;
194 template <class Archive>
195 void serialize(Archive& ar, const
unsigned int version);
212 bool isFile() const override final;
213 std::
string getUrl() const override final;
228 template <class Archive>
229 void serialize(Archive& ar, const
unsigned int version);
234#include <boost/serialization/export.hpp>
235#include <boost/serialization/tracking.hpp>
#define vector(a, b, c)
Definition: FloatMath.inl:3227
Definition: resource_locator.h:199
BytesResource & operator=(const BytesResource &)=default
BytesResource & operator=(BytesResource &&)=default
BytesResource(const BytesResource &)=default
~BytesResource() override=default
BytesResource()=default
This is for boost serialization do not use directly.
BytesResource(BytesResource &&)=default
A general resource loaders using environment variable.
Definition: resource_locator.h:73
GeneralResourceLocator()
Definition: resource_locator.cpp:55
std::shared_ptr< Resource > locateResource(const std::string &url) const override
Locate a resource based on a URL.
Definition: resource_locator.cpp:110
~GeneralResourceLocator() override=default
bool operator==(const GeneralResourceLocator &rhs) const
Definition: resource_locator.cpp:151
GeneralResourceLocator & operator=(GeneralResourceLocator &&)=default
std::shared_ptr< GeneralResourceLocator > Ptr
Definition: resource_locator.h:75
std::unordered_map< std::string, std::string > package_paths_
Definition: resource_locator.h:94
GeneralResourceLocator(const GeneralResourceLocator &)=default
std::shared_ptr< const GeneralResourceLocator > ConstPtr
Definition: resource_locator.h:76
GeneralResourceLocator & operator=(const GeneralResourceLocator &)=default
friend class boost::serialization::access
Definition: resource_locator.h:90
bool operator!=(const GeneralResourceLocator &rhs) const
Definition: resource_locator.cpp:152
GeneralResourceLocator(GeneralResourceLocator &&)=default
void serialize(Archive &ar, const unsigned int version)
Definition: resource_locator.cpp:155
Abstract class for resource loaders.
Definition: resource_locator.h:43
void serialize(Archive &ar, const unsigned int version)
Definition: resource_locator.cpp:51
bool operator!=(const ResourceLocator &rhs) const
Definition: resource_locator.cpp:48
std::shared_ptr< const ResourceLocator > ConstPtr
Definition: resource_locator.h:46
virtual ~ResourceLocator()=default
std::shared_ptr< ResourceLocator > Ptr
Definition: resource_locator.h:45
virtual std::shared_ptr< Resource > locateResource(const std::string &url) const =0
Locate a resource based on a URL.
bool operator==(const ResourceLocator &rhs) const
Definition: resource_locator.cpp:47
friend class boost::serialization::access
Definition: resource_locator.h:62
Represents resource data available from a file or url.
Definition: resource_locator.h:99
virtual bool isFile() const =0
Returns true if the located resource is a local file.
virtual std::shared_ptr< std::istream > getResourceContentStream() const =0
Get the resource as a std::istream. This function and the returned stream may block.
bool operator==(const Resource &rhs) const
Definition: resource_locator.cpp:160
void serialize(Archive &ar, const unsigned int version)
Definition: resource_locator.cpp:164
virtual std::string getUrl() const =0
Get the original URL used to locate the file.
bool operator!=(const Resource &rhs) const
Definition: resource_locator.cpp:161
std::shared_ptr< const Resource > ConstPtr
Definition: resource_locator.h:102
friend class boost::serialization::access
Definition: resource_locator.h:143
std::shared_ptr< Resource > Ptr
Definition: resource_locator.h:101
virtual std::vector< uint8_t > getResourceContents() const =0
Get the resource as bytes. This function may block.
virtual std::string getFilePath() const =0
Get the file path of the resource. Only valid if isFile() is true.
Resource implementation for a local file.
Definition: resource_locator.h:152
std::vector< uint8_t > getResourceContents() const override final
Get the resource as bytes. This function may block.
Definition: resource_locator.cpp:179
bool isFile() const override final
Returns true if the located resource is a local file.
Definition: resource_locator.cpp:173
void serialize(Archive &ar, const unsigned int version)
Definition: resource_locator.cpp:245
SimpleLocatedResource & operator=(const SimpleLocatedResource &)=default
std::string filename_
Definition: resource_locator.h:190
SimpleLocatedResource()=default
This is for boost serialization do not use directly.
std::string getFilePath() const override final
Get the file path of the resource. Only valid if isFile() is true.
Definition: resource_locator.cpp:177
SimpleLocatedResource(SimpleLocatedResource &&)=default
Resource::Ptr locateResource(const std::string &url) const override final
Locate a resource based on a URL.
Definition: resource_locator.cpp:210
std::shared_ptr< const SimpleLocatedResource > ConstPtr
Definition: resource_locator.h:155
std::string getUrl() const override final
Get the original URL used to locate the file.
Definition: resource_locator.cpp:175
SimpleLocatedResource & operator=(SimpleLocatedResource &&)=default
std::shared_ptr< SimpleLocatedResource > Ptr
Definition: resource_locator.h:154
~SimpleLocatedResource() override=default
std::shared_ptr< std::istream > getResourceContentStream() const override final
Get the resource as a std::istream. This function and the returned stream may block.
Definition: resource_locator.cpp:199
friend class boost::serialization::access
Definition: resource_locator.h:193
std::string url_
Definition: resource_locator.h:189
SimpleLocatedResource(const SimpleLocatedResource &)=default
ResourceLocator::ConstPtr parent_
Definition: resource_locator.h:191
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: serialization.h:45
Definition: allowed_collision_matrix.h:16
std::function< std::string(const std::string &)> SimpleResourceLocatorFn
Definition: resource_locator.h:148