Helper class for readers and importer that need to load more than one resource.
More...
|
virtual vtkTypeBool | IsA (const char *type) |
| Return 1 if this class is the same type of (or a subclass of) the named class.
|
|
vtkURILoader * | NewInstance () const |
|
void | PrintSelf (ostream &os, vtkIndent indent) override |
| Methods invoked by print to print information about the object including superclasses.
|
|
vtkURI * | GetBaseURI () const |
| Get base URI.
|
|
bool | HasBaseURI () const |
| Check if loader as a base URI.
|
|
bool | SetBaseFileName (VTK_FILEPATH const std::string &filepath) |
| Higher level way to set the base URI to an existing file.
|
|
bool | SetBaseDirectory (VTK_FILEPATH const std::string &dirpath) |
| Higher level way to set the base URI to an existing directory.
|
|
vtkSmartPointer< vtkURI > | Resolve (const vtkURI *uri) |
| Resolve URI from base URI.
|
|
vtkSmartPointer< vtkResourceStream > | Load (const std::string &uri) |
| Load a resource referenced by an URI.
|
|
vtkSmartPointer< vtkResourceStream > | Load (const char *uri, std::size_t size) |
| Load a resource referenced by an URI.
|
|
vtkSmartPointer< vtkResourceStream > | Load (const vtkURI *uri) |
| Try to resolve given URI from base URI, using vtkURI::Resolve .
|
|
vtkSmartPointer< vtkResourceStream > | LoadResolved (const vtkURI *uri) |
| Load a resource from a full URI.
|
|
|
bool | SetBaseURI (const std::string &uri) |
| Set base URI to use.
|
|
bool | SetBaseURI (vtkURI *uri) |
| Set base URI to use.
|
|
| vtkBaseTypeMacro (vtkObject, vtkObjectBase) |
|
virtual void | DebugOn () |
| Turn debugging output on.
|
|
virtual void | DebugOff () |
| Turn debugging output off.
|
|
bool | GetDebug () |
| Get the value of the debug flag.
|
|
void | SetDebug (bool debugFlag) |
| Set the value of the debug flag.
|
|
virtual void | Modified () |
| Update the modification time for this object.
|
|
virtual vtkMTimeType | GetMTime () |
| Return this object's modified time.
|
|
void | PrintSelf (ostream &os, vtkIndent indent) override |
| Methods invoked by print to print information about the object including superclasses.
|
|
void | RemoveObserver (unsigned long tag) |
|
void | RemoveObservers (unsigned long event) |
|
void | RemoveObservers (const char *event) |
|
void | RemoveAllObservers () |
|
vtkTypeBool | HasObserver (unsigned long event) |
|
vtkTypeBool | HasObserver (const char *event) |
|
vtkTypeBool | InvokeEvent (unsigned long event) |
|
vtkTypeBool | InvokeEvent (const char *event) |
|
std::string | GetObjectDescription () const override |
| The object description printed in messages and PrintSelf output.
|
|
unsigned long | AddObserver (unsigned long event, vtkCommand *, float priority=0.0f) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
unsigned long | AddObserver (const char *event, vtkCommand *, float priority=0.0f) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
vtkCommand * | GetCommand (unsigned long tag) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
void | RemoveObserver (vtkCommand *) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
void | RemoveObservers (unsigned long event, vtkCommand *) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
void | RemoveObservers (const char *event, vtkCommand *) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
vtkTypeBool | HasObserver (unsigned long event, vtkCommand *) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
vtkTypeBool | HasObserver (const char *event, vtkCommand *) |
| Allow people to add/remove/invoke observers (callbacks) to any VTK object.
|
|
template<class U , class T > |
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f) |
| Overloads to AddObserver that allow developers to add class member functions as callbacks for events.
|
|
template<class U , class T > |
unsigned long | AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f) |
| Overloads to AddObserver that allow developers to add class member functions as callbacks for events.
|
|
template<class U , class T > |
unsigned long | AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f) |
| Allow user to set the AbortFlagOn() with the return value of the callback method.
|
|
vtkTypeBool | InvokeEvent (unsigned long event, void *callData) |
| This method invokes an event and return whether the event was aborted or not.
|
|
vtkTypeBool | InvokeEvent (const char *event, void *callData) |
| This method invokes an event and return whether the event was aborted or not.
|
|
virtual void | SetObjectName (const std::string &objectName) |
| Set/get the name of this object for reporting purposes.
|
|
virtual std::string | GetObjectName () const |
| Set/get the name of this object for reporting purposes.
|
|
const char * | GetClassName () const |
| Return the class name as a string.
|
|
virtual std::string | GetObjectDescription () const |
| The object description printed in messages and PrintSelf output.
|
|
virtual vtkTypeBool | IsA (const char *name) |
| Return 1 if this class is the same type of (or a subclass of) the named class.
|
|
virtual vtkIdType | GetNumberOfGenerationsFromBase (const char *name) |
| Given the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class).
|
|
virtual void | Delete () |
| Delete a VTK object.
|
|
virtual void | FastDelete () |
| Delete a reference to this object.
|
|
void | InitializeObjectBase () |
|
void | Print (ostream &os) |
| Print an object to an ostream.
|
|
void | Register (vtkObjectBase *o) |
| Increase the reference count (mark as used by another object).
|
|
virtual void | UnRegister (vtkObjectBase *o) |
| Decrease the reference count (release by another object).
|
|
int | GetReferenceCount () |
| Return the current reference count of this object.
|
|
void | SetReferenceCount (int) |
| Sets the reference count.
|
|
bool | GetIsInMemkind () const |
| A local state flag that remembers whether this object lives in the normal or extended memory space.
|
|
virtual void | PrintHeader (ostream &os, vtkIndent indent) |
| Methods invoked by print to print information about the object including superclasses.
|
|
virtual void | PrintTrailer (ostream &os, vtkIndent indent) |
| Methods invoked by print to print information about the object including superclasses.
|
|
virtual bool | UsesGarbageCollector () const |
| Indicate whether the class uses vtkGarbageCollector or not.
|
|
|
static vtkTypeBool | IsTypeOf (const char *type) |
|
static vtkURILoader * | SafeDownCast (vtkObjectBase *o) |
|
static vtkURILoader * | New () |
|
static vtkObject * | New () |
| Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
|
|
static void | BreakOnError () |
| This method is called when vtkErrorMacro executes.
|
|
static void | SetGlobalWarningDisplay (vtkTypeBool val) |
| This is a global flag that controls whether any debug, warning or error messages are displayed.
|
|
static void | GlobalWarningDisplayOn () |
| This is a global flag that controls whether any debug, warning or error messages are displayed.
|
|
static void | GlobalWarningDisplayOff () |
| This is a global flag that controls whether any debug, warning or error messages are displayed.
|
|
static vtkTypeBool | GetGlobalWarningDisplay () |
| This is a global flag that controls whether any debug, warning or error messages are displayed.
|
|
static vtkTypeBool | IsTypeOf (const char *name) |
| Return 1 if this class type is the same type of (or a subclass of) the named class.
|
|
static vtkIdType | GetNumberOfGenerationsFromBaseType (const char *name) |
| Given a the name of a base class of this class type, return the distance of inheritance between this class type and the named class (how many generations of inheritance are there between this class and the named class).
|
|
static vtkObjectBase * | New () |
| Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
|
|
static void | SetMemkindDirectory (const char *directoryname) |
| The name of a directory, ideally mounted -o dax, to memory map an extended memory space within.
|
|
static bool | GetUsingMemkind () |
| A global state flag that controls whether vtkObjects are constructed in the usual way (the default) or within the extended memory space.
|
|
Helper class for readers and importer that need to load more than one resource.
Introduction
vtkURILoader
is a class that will load URIs, giving vtkResourceStream
s from resolved resource. URI logic (parsing, resolution) is implemented in vtkURI
.
Some formats, such as GLTF, may refer to external resources through URIs. This URI loader can be used to solve this problem.
vtkURILoader
provides "file" and "data" URIs loading. "file" URIs loading only supports localhost. More schemes may be supported in future versions.
Base URI
Base URI, specified in RFC3986#5, is a concept that enable URIs to refer to relative resources from a base resource. For example, you can have a file that needs to look for another file next to it. The best way to implement this, is to have the first file as the base URI, and the referenced file as a relative reference.
To set a local file as base URI, you should use SetBaseFileName
, and for a local directory, you should use SetBaseDirectory
. These functions generate a "file" URI from given path. For example, calling SetBaseFileName(".")
will generate the following URI: "file:///<absolute-current-working-directory>/."
. These functions should be used because they handle some platform specific details, such as adding a /
at the beginning of the path on Windows, percent-encoding, resolving relative paths, "." and "..", checking that path exists and actual filesystem entry type is coherent.
If the loader has no base URI, it can only load full URIs. See vtkURI
for more information.
Basic usage
Here is a basic example of vtkURILoader
usage:
loader->SetBaseFileName(".");
auto stream = loader->Load("example.txt");
auto other = loader->Load("data:;base64,AAAA");
Allocate and hold a VTK object.
Note that in previous example, loader->Load()
actually returns a vtkResourceStream
, the real type can be accessed through SafeDownCast
.
Usage in readers
When implementing a reader, you should use vtkURILoader
if the format can contain URIs. Here are the global guidelines of URI loader support in a reader:
- The function should be named
SetURILoader
.
- Depending on the format, the reader may require an URI loader, or just optionally use it.
- The reader may use a default constructed URI loader by default. This would enable full URI loading, such as "data" URIs.
- When reading from a file name, using
SetFileName
function, the reader should internally open a vtkFileResourceStream
on the file and create a vtkURILoader
with a base URI set to FileName
, then use the same code as the resource stream based reading. This prevents code duplication.
Extension
vtkURILoader::DoLoad
is responsible of actually loading a full URI. It is a virtual function, so it can be reimplemented to let the user support additional schemes. In case you want do support additional scheme, URI scheme and host should be case-insensitive as specified in RFC3986#6.2.2.1.
vtkURILoader::LoadFile
and vtkURILoader::LoadData
are the actual implementation of "file" and "data" URI loading.
Definition at line 99 of file vtkURILoader.h.