Iray SDK API nvidia_logo_transpbg.gif Up
mi::bridge::IServer_job Class Referenceabstract

Represents the server-side part of a job that can be executed by the Bridge server. More...

#include <ibridge_server.h>

Inheritance diagram for mi::bridge::IServer_job:

Public Member Functions

virtual void execute (IServer_transaction *transaction, neuraylib::ISerializer *serializer, IServer_job_info *job_info)=0
 Executes a job on behalf of a Bridge client. More...
 
virtual void cancel ()=0
 Called if the Bridge transaction is aborted or if an error occurs. More...
 
- Public Member Functions inherited from mi::neuraylib::ISerializable
virtual base::Uuid get_class_id () const =0
 Returns the class ID of the object. More...
 
virtual void serialize (ISerializer *serializer) const =0
 Serializes the object to the given serializer. More...
 
virtual void deserialize (IDeserializer *deserializer)=0
 Deserializes the object from the given deserializer. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x555dea0f, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::Interface_declare< 0x7a70f2fb, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x555dea0f, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x7a70f2fb, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed Description

Represents the server-side part of a job that can be executed by the Bridge server.

The corresponding client-side part of the job must return the same ID from mi::neuraylib::ISerializable::get_class_id() and be registered as a Bridge job on the client.

The server-side part must implement mi::neuraylib::ISerializable::deserialize() to deserialize the data that is sent by mi::bridge::IClient_job::serialize(), and mi::bridge::IServer_job::execute() to serialize the result of the job which is consumed by mi::bridge::IClient_job::receive_remote_result(),

It is recommended to derived your implementation from mi::bridge::Server_job and overriding only the required methods.

Member Function Documentation

 cancel()

virtual void mi::bridge::IServer_job::cancel ( )
pure virtual

Called if the Bridge transaction is aborted or if an error occurs.

The job execution should be stopped as quickly as possible, no result will be written to the client.

 execute()

virtual void mi::bridge::IServer_job::execute ( IServer_transaction transaction,
neuraylib::ISerializer serializer,
IServer_job_info job_info 
)
pure virtual

Executes a job on behalf of a Bridge client.

Intermediate results can be sent to the client by calling mi::neuraylib::ISerializer::flush() on serializer. All data serialized until that point will be delivered in a single call to mi::bridge::IClient_job::receive_remote_result() on the client with the last_result flag set to false. When execute() returns any data not yet flushed will be flushed and mi::bridge::IClient_job::receive_remote_result() will be called one last time with last_result flag set to true.

Example 1: No intermediate results are required. The execute() method simply serializes the result and returns. The receive_remote_result() method will be called once with the full result and last_result flag set to true.

Example 2: Progress feedback. During execution of the job periodically one mi::Float32 representing the percentage of the work done is serialized periodically and the serializer is flushed. Finally, when the job is done the final result is serialized and the method returns. On the client side receive_remote_result() parses a single mi::Float32 for every call with the last_result flag set to false and updates a progress bar. When last_result is true it deserializes the entire result and is done.

Example 3: Custom protocol. Whenever the server is done with a partial result it is flushed as a chunk to the client for processing. The server is preparing multiple different types of results, so the chunk always begins with an mi::Uint8 which identifies the type of the chunk and the data to expect. After flushing the last chunk the execute() method returns without any pending data. On the client side receive_remote_result() will check the last_result flag. If true, then the job is done, no more data to parse. If false the first mi::Uint8 is deserialized and the rest of the data is deserialized depending on the type of the chunk and then processed.

Parameters
transactionThe Bridge transaction to be used for the job execution.
serializerThe serializer to be used to send the result back to the client.
job_infoAdditional information about this job.