#include <MPxFileResolver.h>
Base Class for creating custom Maya File Resolvers.
This class provides a base class from which a custom file resolver plug-in can be derived. A file resolver plug-in allows the user to override the manner in which an unresolved file path value is converted to a resolved file path. The resolved file path is the location Maya will use to access the physical file.
Maya supports plug-in File Resolvers for file paths defined using URI values. When an unresolved URI file path is encountered, Maya will search for any registered URI file resolver plug-ins that can handle it.
URI file resolvers are registered for a given URI scheme. For example, a custom file resolver plug-in could be registered to handle the "http" URI scheme. If Maya attempts to resolve a URI file path that has the scheme "http", the custom resolver plug-in will be called. URI schemes are treated in a case-insensitive manner. For example, the schemes 'http', 'HTTP', and 'Http' are considered equivalent.
MPxFileResolvers for URI schemes are registered using the MFnPlugin::registerURIFileResolver method.
Public Types | |
enum | MPxFileResolverMode { kNone = (1<<0), kInput = (1<<1) } |
The MFileResolverMode provides additional information about the reason for the resolution call that can be used by the resolver implementation. More... | |
Public Member Functions | |
MPxFileResolver () | |
The class constructor. | |
virtual | ~MPxFileResolver () |
The class destructor. | |
virtual MString | resolveURI (const MURI &uriValue, MPxFileResolver::MPxFileResolverMode mode, MStatus *ReturnStatus=NULL) |
This routine is called by Maya to convert a URI value to a file path that can be accessed by Maya. More... | |
virtual MString | resolveURIWithContext (const MURI &uriValue, MPxFileResolver::MPxFileResolverMode mode, const MString &contextNodeFullName, MStatus *ReturnStatus=NULL) |
This routine is called by Maya to convert a URI value to a file path that can be accessed by Maya. More... | |
virtual MString | uriScheme () const |
This routine is called to query the URI scheme that is handled by this resolver. More... | |
MString | resolverName () const |
This routine is called to query the name of this resolver. More... | |
virtual void | performAfterSaveURI (const MURI &uriValue, const MString &resolvedFullPath) |
This optional handler is provided so that registered URI file resolvers can do custom processing after file save. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
static MPxFileResolver * | findURIResolverByScheme (const MString &uriScheme) |
Find a registered file resolver that implements a given URI scheme. More... | |
static MPxFileResolver * | findURIResolverByName (const MString &resolverName) |
Find a registered file resolver by name. More... | |
static MStringArray | getURIResolversByScheme () |
Generate a list containing the URI schemes for all registered file resolvers. More... | |
static MStringArray | getURIResolversByName () |
Generate a list containing the names of all registered file resolvers. More... | |
static int | numURIResolvers () |
Determine the number of registered URI file resolvers. More... | |
enum MPxFileResolverMode |
The MFileResolverMode provides additional information about the reason for the resolution call that can be used by the resolver implementation.
Note that this enum is implemented as a bitfield.
|
virtual |
This routine is called by Maya to convert a URI value to a file path that can be accessed by Maya.
This routine is only called if the resolveURIWithContext routine is not overridden in derived classes. Choose to use this routine when you do not need the context (fullName of the URI owner) to perform the resolution.
Derived classes must override either this method or resolveURIWithContext(), but not both. This virtual method must be overridden in derived classes if resolveURIWithContext() is not overridden, as the default version defined in MPxFileResolver simply fails unconditionally.
The routine is passed an MURI object that contains the URI value that requires resolution. The resolver will interpret the data in the URI and determine the physical file path value that Maya will use to access the file.
The output from the routine is a fully qualified file path that can be accessed by Maya.
It is important to note that successful resolution of a file path indicates that the URI filepath was successfully converted to a resolved file path. Successful resolution does not necessarily indicate whether or not the file referred to by the resolved file path actually exists.
The resolution mode provides additional information to the resolver about the reason for the resolution request that can be used by the resolver implementation. Refer to the list of supported MPxFileResolver::MPxFileResolverMode modes for more information.
[in] | uriValue | the unresolved URI value |
[in] | mode | the resolution mode |
[out] | ReturnStatus | status code, see below. |
|
virtual |
This routine is called by Maya to convert a URI value to a file path that can be accessed by Maya.
Derived classes must override either this method or resolveURI(), but not both.
The routine is passed an MURI object that contains the URI value that requires resolution. Additionally, it will be passed the owner fullname (context) when applicable. The resolver will interpret the data in the URI, use the context if required, and determine the physical file path value that Maya will use to access the file.
The context is the fullname of the owner Node. The context fullname might be an empty string if the URI is an application property not associated to any specific scene element.
The output from the routine is a fully qualified file path that can be accessed by Maya.
It is important to note that successful resolution of a file path indicates that the URI filepath was successfully converted to a resolved file path. Successful resolution does not necessarily indicate whether or not the file referred to by the resolved file path actually exists.
The resolution mode provides additional information to the resolver about the reason for the resolution request that can be used by the resolver implementation. Refer to the list of supported MPxFileResolver::MPxFileResolverMode modes for more information.
[in] | uriValue | the unresolved URI value |
[in] | mode | the resolution mode |
[in] | contextNodeFullName | the fullname of the URI owner Node |
[out] | ReturnStatus | status code, see below. |
|
virtual |
This routine is called to query the URI scheme that is handled by this resolver.
An MPxFileResolver handles exactly one URI scheme. For example, a resolver that handles the "http" scheme would return "http".
This virtual method must be overridden in derived classes. The default version defined in MPxFileResolver unconditionally returns an empty string.
MString resolverName | ( | ) | const |
This routine is called to query the name of this resolver.
The resolver name is specified when the resolver is registered in the call to MFnPlugin::registerURIFileResolver. Derived classes do not override this method.
|
static |
Returns the name of this class.
This optional handler is provided so that registered URI file resolvers can do custom processing after file save.
The method will be called by Maya after a scene file associated with this URI resolver is saved (i.e. a scene having a URI file path corresponding to the URI scheme implemented by this resolver). The timing of the call is similar to the MSceneMessage:kAfterSave callback, this method will however be called first, before any afterSave callbacks are invoked.
The arguments to the method provide information about the file that was just saved: The URI file path is the unresolved path to the file, the resolved path gives the physical location of the file.
This method is optional, it may be overridden in derived resolvers as required. The default version defined in MPxFileResolver does nothing.
[in] | uriValue | the URI (unresolved path) for the saved file |
[in] | resolvedFullName | full path to the file that was saved |
|
static |
Find a registered file resolver that implements a given URI scheme.
Note that URI schemes are matched in a case-insensitive manner. For example, the schemes 'http', 'HTTP', and 'Http' are considered equivalent.
[in] | uriScheme | URI scheme to search for |
|
static |
Find a registered file resolver by name.
[in] | resolverName | name of the file resolver to search for |
|
static |
Generate a list containing the URI schemes for all registered file resolvers.
Note: when called together, getURIResolversByScheme and getURIResolversByName will return lists of corresponding entries.
|
static |
Generate a list containing the names of all registered file resolvers.
Note: when called together, getURIResolversByScheme and getURIResolversByName will return lists of corresponding entries.
|
static |
Determine the number of registered URI file resolvers.