Iray SDK API nvidia_logo_transpbg.gif Up
ibridge_server.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_NEURAYLIB_IBRIDGE_SERVER_H
8#define MI_NEURAYLIB_IBRIDGE_SERVER_H
9
10#include <mi/base/enums.h>
11#include <mi/base/handle.h>
13#include <mi/base/uuid.h>
17
18namespace mi {
19
20class IString;
21class IMap;
22
23namespace http { class IServer; }
24
25namespace neuraylib { class IImport_result; class IExport_result; }
26
27namespace bridge {
28
29class IApplication;
30class IApplication_session_handler;
31class IElement_set;
32class IServer_session;
33class IServer_transaction;
34class IServer_video_context;
35
64class IServer_job_info;
65
79class IServer_job : public
80 mi::base::Interface_declare<0x555dea0f,0x4eeb,0x44b9,0xba,0x81,0x5a,0x42,0x3d,0xe5,0xf8,0x30,
81 neuraylib::ISerializable>
82{
83public:
118 virtual void execute(IServer_transaction* transaction, neuraylib::ISerializer* serializer,
119 IServer_job_info* job_info) = 0;
120
125 virtual void cancel() = 0;
126};
127
132template <Uint32 i_id1, Uint16 i_id2, Uint16 i_id3
133, Uint8 i_id4, Uint8 i_id5, Uint8 i_id6, Uint8 i_id7
134, Uint8 i_id8, Uint8 i_id9, Uint8 i_id10, Uint8 i_id11
135, class I = IServer_job>
137{
138public:
141
144
150 static bool compare_iid( const base::Uuid& iid)
151 {
152 if( iid == IID())
153 return true;
154 return I::compare_iid( iid);
155 }
156
167 virtual const base::IInterface* get_interface( const base::Uuid& interface_id) const
168 {
169 if( interface_id == IID()) {
170 const Self* self = static_cast<const Self*>( this);
171 self->retain();
172 return self;
173 }
174 return I::get_interface_static( this, interface_id);
175 }
176
187 virtual base::IInterface* get_interface( const base::Uuid& interface_id)
188 {
189 if( interface_id == IID()) {
190 Self* self = static_cast<Self*>( this);
191 self->retain();
192 return self;
193 }
194 return I::get_interface_static( this, interface_id);
195 }
196
198
200 virtual base::Uuid get_class_id() const
201 {
202 return IID();
203 }
204
206 virtual void serialize( neuraylib::ISerializer* serializer) const
207 {
208 // avoid warnings
209 (void) serializer;
210 }
211
213 virtual void cancel() { }
214};
215
217class IServer_job_info : public
218 mi::base::Interface_declare<0xa28b5525,0x728b,0x447a,0x89,0x9f,0x15,0x64,0xdf,0x14,0xc7,0xdc>
219{
220public:
224 virtual IServer_job* get_job() const = 0;
225
233 template<class T>
234 T* get_job() const
235 {
236 IServer_job* ptr_job = get_job();
237 if ( !ptr_job)
238 return 0;
239 T* ptr_T = static_cast<T*>( ptr_job->get_interface( typename T::IID()));
240 ptr_job->release();
241 return ptr_T;
242 }
243
247 virtual const char* get_id() const = 0;
248
254};
255
257class IServer_job_list : public
258 mi::base::Interface_declare<0xde301678,0x11e9,0x4bed,0x9b,0xc3,0x60,0x1e,0xcf,0xa3,0x88,0xa9>
259{
260public:
261
263 virtual Size get_size() = 0;
264
267 virtual IServer_job_info* get_job(Size index) = 0;
268};
269
275 mi::base::Interface_declare<0x7796c406,0xff8f,0x423d,0x8f,0x53,0x1a,0x66,0x50,0xcf,0x83,0x86>
276{
277public:
283
294 virtual void transaction_aborted_callback( Sint32 error_code, const char* message) = 0;
295};
296
301 mi::base::Interface_declare<0x5ec24e12,0x9ce9,0x4f39,0x9f,0xd5,0x35,0xf1,0xe5,0x41,0x34,0x2e>
302{
303public:
315 virtual Sint32 create_snapshot( IServer_transaction* transaction, IString* snapshot_id) = 0;
316};
317
327 mi::base::Interface_declare<0x67fd848e,0xce43,0x4675,0x8b,0x14,0xb2,0x54,0xd,0xd2,0x29,0x63>
328{
329public:
331 virtual IServer_session* get_session() const = 0;
332
342
350 template<class T>
352 {
354 if ( !ptr_itransaction)
355 return 0;
356 T* ptr_T = static_cast<T*>( ptr_itransaction->get_interface( typename T::IID()));
357 ptr_itransaction->release();
358 return ptr_T;
359 }
360
376
388
409 virtual Sint32 create_snapshot( const char* element, IString* snapshot_id) = 0;
410
440 const char* element, IString* snapshot_id, IIncremental_snapshot_context** context) = 0;
441
446 virtual Size get_updated_element_count() const = 0;
447
460 virtual IServer_job_list* get_pending_jobs() const = 0;
461
466 virtual const char* get_id() const = 0;
467};
468
473{
476
479
482
485
486 SERVER_SESSION_FORCE_32_BIT = 0xffffffffU
487};
488
489mi_static_assert( sizeof( Server_session_state) == sizeof( Uint32));
490
496 mi::base::Interface_declare<0x12a50ba1,0x9cfc,0x4a12,0x9a,0x4b,0x52,0x13,0xf6,0x98,0x81,0x11>
497{
498public:
500 virtual void session_state_callback( IServer_session* session) = 0;
501};
502
505 mi::base::Interface_declare<0xe97c6925,0x780,0x40b7,0x8c,0xc0,0xa9,0x2f,0x73,0xfe,0xb7,0x8
506>
507{
508public:
509
511 virtual Size get_size() = 0;
512
515};
516
521class IServer_session : public
522 mi::base::Interface_declare<0x42574f4a,0xfab1,0x4fdc,0xa0,0xc7,0x52,0x48,0xba,0xfa,0x8e,0x7d>
523{
524public:
526 virtual Server_session_state get_state() const = 0;
527
529 virtual IApplication* get_application() const = 0;
530
544
554
561
563 virtual const char* get_security_token() const = 0;
564
566 virtual const char* get_session_id() const = 0;
567
569 virtual const char* get_client_build_number() = 0;
570
574 virtual const char* get_client_bridge_protocol_version() = 0;
575
597};
598
604 mi::base::Interface_declare<0x8913c078,0xeba2,0x4e0b,0x83,0x44,0x1,0xcb,0x2b,0x57,0x67,0x3c>
605{
606public:
615 virtual bool on_session_connect( IServer_session* session) = 0;
616};
617
625class IApplication : public
626 mi::base::Interface_declare<0x84c2d806,0x6e1f,0x402d,0xb2,0xa,0x2f,0xcf,0x47,0xd1,0xf,0x2e>
627{
628public:
641 const base::Uuid& job_class_id, neuraylib::IUser_class_factory* factory) = 0;
642
655 template <class T>
657 {
660 return register_job( typename T::IID(), factory.get());
661 }
662
669 virtual Sint32 unregister_job( const base::Uuid& job_class_id) = 0;
670
679 template <class T>
681 {
682 return unregister_job( typename T::IID());
683 }
684
702 virtual Sint32 set_disk_cache( const char* location) = 0;
703
707 virtual const char* get_disk_cache() const = 0;
708
716 virtual Sint32 open() = 0;
717
724 virtual Sint32 close() = 0;
725
727 virtual bool is_open() = 0;
728
740
743
760
767};
768
773 mi::base::Interface_declare<0x9a9ceafe,0x876b,0x4647,0xbc,0xae,0xb6,0x4,0x9c,0x7b,0x9,0xfc>
774{
775public:
799 neuraylib::ITransaction* transaction,
800 const char* snapshot_id,
801 const IMap* importer_options = 0) = 0;
802
813 virtual Sint32 remove_snapshot( const char* snapshot_id) = 0;
814
838 neuraylib::ITransaction* transaction,
839 const IArray* elements,
840 const IMap* exporter_options,
841 IString* snapshot_id) = 0;
842};
843
847class IBridge_server : public
848 mi::base::Interface_declare<0x1fd8a3ac,0xa70c,0x4273,0xa9,0x1a,0x67,0x57,0xdf,0xc7,0xa5,0xb>
849{
850public:
868 const char* application_path, http::IServer* http_server) = 0;
869
879 virtual IBridge_snapshot_context* create_snapshot_context( const char* disk_cache) = 0;
880
882 virtual const char* get_bridge_protocol_version() const = 0;
883
897 neuraylib::ITransaction* transaction,
898 const char* element,
899 IString* o_hash,
900 Size* o_size) = 0;
901};
902 // end group mi_neuray_bridge_server
904
905} // namespace bridge
906
907} // namespace mi
908
909#endif // MI_NEURAYLIB_IBRIDGE_SERVER_H
This interface represents static arrays, i.e., arrays with a fixed number of elements.
Definition: iarray.h:37
This interface represents maps, i.e., a key-value based data structure.
Definition: imap.h:41
A simple string class.
Definition: istring.h:22
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
The basic extensible interface.
Definition: iinterface.h:103
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
Mixin class template for deriving interface implementations.
Definition: interface_implement.h:41
Class template for a compile-time representation of universally unique identifiers (UUIDs or GUIDs).
Definition: uuid.h:122
Abstract interface that can be used to control which sessions to a Bridge application are established...
Definition: ibridge_server.h:605
virtual bool on_session_connect(IServer_session *session)=0
This method is called when a session to a Bridge application is to be established.
This class represents a Bridge application.
Definition: ibridge_server.h:627
virtual Sint32 unregister_job(const base::Uuid &job_class_id)=0
Unregisters a Bridge job with the application.
virtual IApplication_session_handler * get_session_handler() const =0
Returns the current session handler, or NULL if no session handler has been set.
Sint32 register_job()
Registers a Bridge job with the application.
Definition: ibridge_server.h:656
virtual base::Message_severity get_log_forwarding_limit() const =0
Returns the maximum verbosity of log messages that will be forwarded to the client.
virtual Sint32 register_job(const base::Uuid &job_class_id, neuraylib::IUser_class_factory *factory)=0
Registers a Bridge job with the application.
virtual bool is_open()=0
Indicates whether the application is open, i.e., whether it accepts client sessions.
virtual Sint32 set_log_forwarding_limit(base::Message_severity limit)=0
Sets the maximum verbosity of log messages that will be forwarded to the client.
Sint32 unregister_job()
Unregisters a Bridge job with the application.
Definition: ibridge_server.h:680
virtual const char * get_disk_cache() const =0
Returns the disk cache location.
virtual Sint32 set_session_handler(IApplication_session_handler *handler)=0
Sets the session handler that will be called when clients connect.
virtual Sint32 open()=0
Opens the application so that clients can open sessions to it.
virtual Sint32 set_disk_cache(const char *location)=0
Sets the disk cache to use.
virtual Sint32 close()=0
Closes the application and any open sessions.
API component that serves as entry point for the server-side Bridge API.
Definition: ibridge_server.h:849
virtual IBridge_snapshot_context * create_snapshot_context(const char *disk_cache)=0
Creates a snapshot context for importing or deleting snapshots.
virtual Sint32 calculate_hash(neuraylib::ITransaction *transaction, const char *element, IString *o_hash, Size *o_size)=0
Returns the hash and serialized size for the provided element.
virtual const char * get_bridge_protocol_version() const =0
Returns the Bridge protocol version string.
virtual IApplication * create_application(const char *application_path, http::IServer *http_server)=0
Creates a Bridge application.
Context to import, export, or remove snapshots.
Definition: ibridge_server.h:774
virtual neuraylib::IImport_result * import_snapshot(neuraylib::ITransaction *transaction, const char *snapshot_id, const IMap *importer_options=0)=0
Imports a previously saved snapshot from the disk cache.
virtual neuraylib::IExport_result * export_snapshot(neuraylib::ITransaction *transaction, const IArray *elements, const IMap *exporter_options, IString *snapshot_id)=0
Exports a set of elements to the disk cache.
virtual Sint32 remove_snapshot(const char *snapshot_id)=0
Removes a snapshot from the disk cache.
Context for incremental snapshots.
Definition: ibridge_server.h:302
virtual Sint32 create_snapshot(IServer_transaction *transaction, IString *snapshot_id)=0
Creates an incremental snapshot.
Provides additional information about a bridge job.
Definition: ibridge_server.h:219
T * get_job() const
Returns the Bridge job instance.
Definition: ibridge_server.h:234
virtual const char * get_id() const =0
Returns the id of this job.
virtual IServer_job * get_job() const =0
Returns the Bridge job instance.
virtual base::Uuid get_job_uuid()=0
Returns the universally unique identifier (UUID or GUID) of the Bridge job.
A list of IServer_job instances.
Definition: ibridge_server.h:259
virtual IServer_job_info * get_job(Size index)=0
Returns the job at the given index, or 0 if the index is out of bounds.
virtual Size get_size()=0
Returns the number of jobs in the list.
Represents the server-side part of a job that can be executed by the Bridge server.
Definition: ibridge_server.h:82
virtual void execute(IServer_transaction *transaction, neuraylib::ISerializer *serializer, IServer_job_info *job_info)=0
Executes a job on behalf of a Bridge client.
virtual void cancel()=0
Called if the Bridge transaction is aborted or if an error occurs.
Abstract interface for callbacks for session state changes.
Definition: ibridge_server.h:497
virtual void session_state_callback(IServer_session *session)=0
This method is called whenever the session changes its state.
Represents the server side of a Bridge session.
Definition: ibridge_server.h:523
virtual IServer_transaction_list * get_pending_transactions()=0
Returns a list of the currently pending Bridge transactions for this session in the order they were s...
virtual void remove_session_state_callback(IServer_session_state_callback *callback)=0
Removes a previously added session state callback.
virtual const char * get_session_id() const =0
Returns the session ID.
virtual const char * get_security_token() const =0
Returns the security token specified by the client.
virtual Server_session_state get_state() const =0
Returns the state of this session.
virtual const char * get_client_build_number()=0
Returns build number of the client.
virtual IServer_video_context * get_video_context(Sint32 context_id)=0
Returns the video context for a given ID.
virtual IApplication * get_application() const =0
Returns the application this session belongs to.
virtual void add_session_state_callback(IServer_session_state_callback *callback)=0
Adds a session state callback.
virtual const char * get_client_bridge_protocol_version()=0
Returns the client Bridge protocol version.
Abstract interface for callbacks for transaction commit or abort events.
Definition: ibridge_server.h:276
virtual void transaction_aborted_callback(Sint32 error_code, const char *message)=0
This method is called when the Bridge transaction has been aborted.
virtual void transaction_committed_callback()=0
This method is called when the Bridge transaction has been successfully committed.
A list of IServer_transaction instances.
Definition: ibridge_server.h:507
virtual IServer_transaction * get_transaction(Size index)=0
Returns the job at the given index, or 0 if the index is out of bounds.
virtual Size get_size()=0
Returns the number of transactions in the list.
Database transactions started on the client will be automatically mirrored to the server and exposed ...
Definition: ibridge_server.h:328
virtual Size get_updated_element_count() const =0
Returns the number of database elements updated by this transaction so far.
virtual Sint32 create_incremental_snapshot_context(const char *element, IString *snapshot_id, IIncremental_snapshot_context **context)=0
Creates a base snapshot and a context for subsequent incremental snapshots.
virtual Sint32 create_snapshot(const char *element, IString *snapshot_id)=0
Creates a snapshot of some database elements.
T * get_database_transaction() const
Returns the local transaction corresponding to this Bridge transaction.
Definition: ibridge_server.h:351
virtual IServer_session * get_session() const =0
Returns the session of the transaction.
virtual Sint32 remove_transaction_callback(IServer_transaction_callback *callback)=0
Removes a transaction callback.
virtual Sint32 add_transaction_callback(IServer_transaction_callback *callback)=0
Adds a transaction callback.
virtual IServer_job_list * get_pending_jobs() const =0
Returns the list of currently pending jobs for this transaction in the order they will be executed.
virtual neuraylib::ITransaction * get_database_transaction() const =0
Returns the local transaction corresponding to this Bridge transaction, or NULL if this transaction h...
virtual const char * get_id() const =0
Returns the id of this Bridge transaction.
Server-side video context that generates and encodes video frames for the corresponding client-side v...
Definition: ibridge_video_server.h:41
This mixin class provides a default implementation for some of the methods needed by mi::bridge::ISer...
Definition: ibridge_server.h:137
virtual const base::IInterface * get_interface(const base::Uuid &interface_id) const
Acquires a const interface.
Definition: ibridge_server.h:167
static bool compare_iid(const base::Uuid &iid)
Compares the interface ID iid against the interface ID of this interface and its ancestors.
Definition: ibridge_server.h:150
Server_job<i_id1, i_id2, i_id3, i_id4, i_id5, i_id6, i_id7, i_id8, i_id9, i_id10, i_id11, I> Self
Own type.
Definition: ibridge_server.h:140
base::Uuid_t<i_id1, i_id2, i_id3, i_id4, i_id5, i_id6, i_id7, i_id8, i_id9, i_id10, i_id11> IID
Declares the interface ID.
Definition: ibridge_server.h:143
virtual base::IInterface * get_interface(const base::Uuid &interface_id)
Acquires a mutable interface.
Definition: ibridge_server.h:187
virtual base::Uuid get_class_id() const
Returns the class ID corresponding to the template parameters of this mixin class.
Definition: ibridge_server.h:200
virtual void cancel()
Does nothing in the default implementation.
Definition: ibridge_server.h:213
virtual void serialize(neuraylib::ISerializer *serializer) const
Empty body. This method from the base class is not needed for client jobs.
Definition: ibridge_server.h:206
The server builds a framework for the handlers.
Definition: http.h:725
This interface represents the result of an export operation.
Definition: iexport_result.h:44
This interface represents the result of an import operation.
Definition: iimport_result.h:44
Target for serializing objects to byte streams.
Definition: iserializer.h:171
A transaction provides a consistent view on the database.
Definition: itransaction.h:81
Abstract interface for user class factories.
Definition: iuser_class_factory.h:31
This mixin class provides a default implementation of the IUser_class_factory interface.
Definition: iuser_class_factory.h:66
Basic enums.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:65
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
Interface * get() const
Access to the interface. Returns 0 for an invalid interface.
Definition: handle.h:294
virtual Uint32 release() const =0
Decrements the reference count.
virtual Uint32 retain() const
Increments the reference count.
Definition: interface_implement.h:93
Message_severity
Constants for possible message severities.
Definition: enums.h:31
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
unsigned short Uint16
16-bit unsigned integer.
Definition: types.h:48
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Server_session_state
The different states a server session can be in.
Definition: ibridge_server.h:473
@ SERVER_SESSION_PENDING
The session was disconnected unexpectedly and is waiting for the client to reconnect.
Definition: ibridge_server.h:481
@ SERVER_SESSION_CONNECTING
A client has connected to the application but has not yet been approved.
Definition: ibridge_server.h:475
@ SERVER_SESSION_CLOSED
The session has been closed.
Definition: ibridge_server.h:484
@ SERVER_SESSION_CONNECTED
The session has successfully established a connection to the Bridge application.
Definition: ibridge_server.h:478
Smart-pointer handle class for interfaces, const and non-const version.
Mixin class template for deriving interface implementations.
Serialization of objects to a byte stream.
Database transactions.
Abstract interface for factories for user-defined class.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: neuraylib.h:179
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26
A 128 bit representation of a universally unique identifier (UUID or GUID).