neuray Services API Programmer's Manual

mi::nservices::IHttp_import_api Class Reference

Description

Importer api interface over http and https protocols.

Public Member Functions

virtual IHttp_readerget_reader( const char* uri, Http_reader_open_mode mode) const =0
Returns a reader that can be used to import the given resource. More...
virtual mi::neuraylib::ICanvasimport_canvas( const char* uri) const =0
Imports a canvas from a http/https resouce. More...
virtual const mi::neuraylib::IImport_resultimport_elements( mi::neuraylib::ITransaction* transaction, const char* uri, const mi::IMap* importer_options = 0, const mi::neuraylib::IImpexp_state* parent_state = 0, const char* filetype = 0) const =0
Imports scene elements. More...

Member Functions

virtual IHttp_reader* mi::​nservices::​IHttp_import_api::get_reader( const char* uri, Http_reader_open_mode mode) const [pure virtual]

Returns a reader that can be used to import the given resource.

Parameters

uri
The URI of the resource to get the reader for.
mode

Returns

A reader that can be used to import the resource, or NULL in case of failures (e.g., the URI denotes a non-existing file).

virtual mi::neuraylib::ICanvas* mi::​nservices::​IHttp_import_api::import_canvas( const char* uri) const [pure virtual]

Imports a canvas from a http/https resouce.

Parameters

uri
The URI of the canvas to import. The ending of the URI determines the image format, e.g., ".jpg", unless a content-type header is supplied with the response. Note that support for a given image format requires an image plugin capable of handling that format.

Returns

The imported canvas, or NULL in case of failure.

virtual const mi::neuraylib::IImport_result* mi::​nservices::​IHttp_import_api::import_elements( mi::neuraylib::ITransaction* transaction, const char* uri, const mi::IMap* importer_options = 0, const mi::neuraylib::IImpexp_state* parent_state = 0, const char* filetype = 0) const [pure virtual]

Imports scene elements. This method reads the response body from uri and parses it with an importer. Importer selection is based on testing a file prefix (if available) or the uri filename extension. Elements will be put into the database as if they had been stored with mi::neuraylib::ITransaction::store().

In addition to importer-specific options, every importer supports the following standard options:

The method stores a non-zero status code in the returned instance of mi::neuraylib::IImport_result if an error occurred. The database and mi::neuraylib::IImport_result contain all elements read up to that point. The element that caused the error might be incomplete or inconsistent. If the "list_elements" options is selected, every changed or added element, even if it caused an error, is reported in the elements array of mi::neuraylib::IImport_result. In case of an error, the database can be returned to a safe state that does not contain incompletely defined elements by calling the mi::neuraylib::ITransaction::abort() method, which will return the database to the state it was in when the current transaction started. (This is not specific to scene importing, any operation that modifies the database can be reversed in this way.)

Parameters

transaction
The transaction to be used.
uri
The http or https URI of the resource to import from.
importer_options
The importer options (see above).
parent_state
An optional state that can be passed by a parent importer, or NULL. Such a state is used to resolve relative URIs w.r.t. to the URI of the parent state. In addition, the parent state can be used by the importer for better diagnostics in case of errors.
filetype
An optional filetype specifier used to select a specific importer. This parameter should be used when uri does not end with a file extension. should be specified as the extension supported by the importer without the preceding '.'.

Returns

The import result uses the following error codes. The severity of all listed errors (excluding the importer-specific error codes) is mi::base::details::MESSAGE_SEVERITY_ERROR . There might be other undocumented error codes.

  • 0: The import operation was successful.
  • 1: The passed URI is invalid (malformed).
  • 2: failed to create an instance of mi::neuraylib::IReader for the given URI, most probably because it was unable to open the specified file, e.g., because the file does not exist, or the user has insufficient permissions.
  • 3: There is no appropriate importer for this file format (and file content).
  • 4: The importer failed to create the instance of mi::neuraylib::IImpexp_state.
  • 5: The importer did not return a valid instance of mi::neuraylib::IImport_result.
  • 6: The option '...' has an invalid type.
  • 7: The option '...' has an invalid value.
  • 4000-5999: Reserved for importer-specific error codes.