-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for generic URIs #464
Conversation
Conflicts: dart/dynamics/MeshShape.cpp dart/utils/urdf/DartLoader.cpp
, mPackageRetriever(new utils::PackageResourceRetriever(mLocalRetriever)) | ||
, mRetriever(new utils::SchemaResourceRetriever) | ||
{ | ||
using namespace std::placeholders; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this line?
Most comments I made in the code are about code style. Strictly speaking, we don't have written code convention and furthermore I've followed different code styles myself so far. I tried to comment for something settled styles but you can skip those style issue for now. We might begin to write up our code convention in not too far future and check code style more strictly from that time. Also, note that |
I think I addressed all of your comments. 😓 Please take another look and let me know if I missed anything. Github's not great at displaying diffs of this size, so it's hard to tell if I got them all. |
|
||
/// ResourceRetriever provides methods for testing for the existance of and | ||
/// accessing the content of a resource specified by URI. | ||
class ResourceRetriever { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ResourceRetriever
{
Thanks @mkoval ! I found more minor formatting issues. Once these are modified then we could merge this PR if there is no other feedback. |
Looks good to me 👍 |
I think I fixed the remaining formatting issues. |
👍 Nice work! |
This pull request adds full-fledged URI support to DART. This generalizes the rudimentary support for
package://
URIs inDartLoader
to the other file loaders and for loading meshes. I believe that this pull request is fully backwards compatible (with one minor exception), so I'd like to get this into DART 5.1.The key idea is that external resources should be specified by URIs, not paths, nested resources should resolved relative to their parent URI, and it should be possible for the user to add support for custom URIs without modifying DART.
This pull request adds the following classes:
common::ResourceRetriever
provides a standard interface for opening am URI and returning a...common::Resource
provides file-like access to a resource using anfread
-like APIcommon::LocalResourceRetriever
provides access to local paths andfile://
URIs using the standard librarycommon::Uri
class that provides URI parsing and merging functionality with no dependencies (painstakingly implemented from RFC 3986)utils::PackageResourceRetriever
resolvespackage://
URIs tofile://
URis using a user-specified mapping. This mimics the behavior ofaddPackageDirectory
onDartLoader
utils::SchemaResourceRetriever
adds support for using multipleResourceRetrievers
at the same time; e.g. to support bothfile://
andpackage://
URIs.dynamics::AssimpResourceInputResourceAdaptor
maps between the DART'sResource
andResourceRetriever
classes and the corresponding AssimpIOFile
andIOSystem
classes. This allows Assimp to transparently load meshes that consist of multiple files (e.g. external textures).It also makes the following API changes:
MeshShape
optionally takes aResourceRetriever
argument. If specified, this is made available through agetResourceRetriever
function, e.g. to resolve textures using the sameResourceRetriever
as was used to load the mesh.MeshShape
now supports arbitrary URIs, which are accessible using thegetMeshUri
method. If the URI is afile://
URI, then it is also available (for backwards compatibility) via thegetMeshPath
method.SdfParser
andSkelParser
methods now take an optionalResourceRetriever
argument and use it resolve both the input URI and any embedded URIs. If not specified, the argument defaults to aLocalResourceRetriever
.SkelParser
now resolves meshes relative to the.skel
file instead of assuming that they are inDART_DATA_PATH
. This technically breaks backwards compatibility. However, it makes the class so much more useful that I think it's worth it.DartLoader
now optionally accepts aResourceRetriever
argument (see above). If not specified, it defaults to aSchemaResourceRetriever
that uses aLocalResourceRetriever
to resolvefile://
URIs and aPackageResourceRetriever
to resolvepackage://
URIs.DartLoader
'saddPackageDirectory
function is deprecated in favor of passing a customResourceRetriever
.DartLoader
is refactored to use primarily static methods. In DART 6.0, we can removeaddPackageDirectory
and provide an entirely static API.These features add no dependencies if the compiler has full C++11 support. Unfortunately, the version of
libstdc++
shipped with GCC 4.8 (this is the version distributed on Ubuntu 14.04) and below have a broken implementation ofstd::regex
. There isn't a reliable way of testing the version oflibstdc++
in both GCC and Clang, so I fall back on Boost.Regex if I detectlibstdc++
being used at all.This is a big pull request, so I am sure I missed something. Please post if you have any questions or see anything that may break backwards compatibility.