neuray Services API Programmer's Manual

mi::nservices::ICommand_context Class Reference

[Commands]

Description

The context is which a command is executed. This includes

  • Command name and arguments.

  • Neuray environment

  • Access to scenes

  • Events

  • Data Factory

  • Attachments

Public Member Functions

virtual Sint32 change_scope( const char* scope_name) =0
Changes the scope that the command is executing to the given scope name. More...
virtual Sint32 change_scope( neuraylib::IScope* scope) =0
Changes the scope that the command is executing to the given scope. More...
virtual ICommand_responsecreate_command_response() const =0
Creates a command response. More...
virtual Sint32 create_new_transaction( bool commit = true) =0
Creates a new transaction at the same scope as the current one. More...
virtual const ICommand_responseexecute_command( ICommand_request* command_request) =0
Executes a neuray service command and returns its response. More...
virtual const IDataget_argument( const char* name) const =0
Gets the value for argument 'name'. More...
virtual Sint32 get_argument( Uint32 index, const char** name, const IData** value) const =0
Gets the argument name and value of index. More...
template< class T>const T* get_argument( const char* name) const
Gets the value for argument 'name'. More...
virtual IMapget_attachments() const =0
Retrieves the global attachment object. More...
virtual IMapget_command_attachments() const =0
Retrieves the attachment object for the current command. More...
virtual const char* get_command_name() const =0
The name of the command being executed. More...
virtual IConverterget_converter() const =0
Returns a type converter. More...
virtual IEvent_contextget_event_context() const =0
Gets an event context. More...
virtual IFactoryget_factory() const =0
Returns a factory, may be used to create neuray services data or other required classes. More...
virtual Uint32 get_num_arguments() const =0
The number of arguments to the command. More...
virtual neuraylib::IPlugin_apiget_plugin_api() const =0
Get the neuray IPlugin_api. More...
virtual neuraylib::ITransactionget_transaction() =0
Get the current transaction associated with this service request. More...
virtual neuraylib::ITransactionget_user_state() =0
Gets a transaction into the user state. More...

Member Functions

virtual Sint32 mi::​nservices::​ICommand_context::change_scope( const char* scope_name) [pure virtual]

Changes the scope that the command is executing to the given scope name. The current transaction is committed before the new transaction is created and any transaction previously obtained by get_transaction becomes invalid. Any future commands executed in this request will execute in the new scope. Users should ensure that an open edits on the current transaction are closed before calling this method. The new scope transaction can be accessed by calling ICommand_context::get_transaction. Events: Use of this method will trigger a CHANGE_SCOPE event.

Parameters

scope_name
the name of the scope

Returns

  • NRS_ERROR_NONE success.
  • NRS_ERROR_INVALID_PARAMETERS scope_name is NULL.
  • NRS_ERROR_NOT_FOUND scope scope_name not found.
  • NRS_ERROR_FAILED internal error.
virtual Sint32 mi::​nservices::​ICommand_context::change_scope( neuraylib::IScope* scope) [pure virtual]

Changes the scope that the command is executing to the given scope. The current transaction is committed before the new transaction is created and any transaction previously obtained by get_transaction becomes invalid. Any future commands executed will execute in the new scope. Users should ensure that an open edits on the current transaction are closed before calling this method. The new transaction can be accessed by calling ICommand_context::get_transaction. Events: Use of this method will trigger a CHANGE_SCOPE event.

Parameters

scope
the scope to change to

Returns

  • NRS_ERROR_NONE success.
  • NRS_ERROR_INVALID_PARAMETERS scope is NULL
  • NRS_ERROR_FAILED internal error.
virtual ICommand_response* mi::​nservices::​ICommand_context::create_command_response() const [pure virtual]

Creates a command response.

Returns

A command response.

virtual Sint32 mi::​nservices::​ICommand_context::create_new_transaction( bool commit = true) [pure virtual]

Creates a new transaction at the same scope as the current one. The new transaction is used by any subsequent commands executed in this request. Users should ensure that any open handles on the current transaction are closed before calling this method. The new transaction can be accessed by calling ICommand_context::get_transaction.

Parameters

commit
if true the current transaction is committed, if false it is aborted.

Returns

  • NRS_ERROR_NONE success.
  • NRS_ERROR_FAILED internal error.
virtual const ICommand_response* mi::​nservices::​ICommand_context::execute_command( ICommand_request* command_request) [pure virtual]

Executes a neuray service command and returns its response. The command will be executed within the same environment as this command. The new command will be searched for within the same pool of command sets that this command was found in.

Parameters

command_request
the command request to execute, create with IFactory.

Returns

the response to the request.

virtual const IData* mi::​nservices::​ICommand_context::get_argument( const char* name) const [pure virtual]

Gets the value for argument 'name'.

Parameters

name
The name of the argument.

Returns

the value or NULL if argument doesn't exist

virtual Sint32 mi::​nservices::​ICommand_context::get_argument( Uint32 index, const char** name, const IData** value) const [pure virtual]

Gets the argument name and value of index.

Parameters

index
the index of the argument, start at 0 and increment until returns NRS_ERROR_NOT_FOUND
name
receives the name of the argument
value
receives the value of the argument

Returns

  • NRS_ERROR_NONE success, name and value contains the argument name and it's value.
  • NRS_ERROR_NOT_FOUND index is greater than the number of supplied arguments.
  • NRS_ERROR_FAILED internal error.

template< class T>

const T* mi::​nservices::​ICommand_context::get_argument( const char* name) const [inline]

Gets the value for argument 'name'. This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid&) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Parameters

name
the argument name

Returns

the value or NULL if argument doesn't exist

virtual IMap* mi::​nservices::​ICommand_context::get_attachments() const [pure virtual]

Retrieves the global attachment object.

Returns

An object with which to manipulate the global attachments

virtual IMap* mi::​nservices::​ICommand_context::get_command_attachments() const [pure virtual]

Retrieves the attachment object for the current command.

Returns

an object with which to manipulate attachments

virtual const char* mi::​nservices::​ICommand_context::get_command_name() const [pure virtual]

The name of the command being executed. Can be used for sanity checking.

Returns

the command name

virtual IConverter* mi::​nservices::​ICommand_context::get_converter() const [pure virtual]

Returns a type converter. If an incoming parameter is not the expected data type then the converter can be used to try and convert it to the expected type. It can also be used to convert array and object elements to their expected types.

Returns

the type converter

virtual IEvent_context* mi::​nservices::​ICommand_context::get_event_context() const [pure virtual]

Gets an event context. The command can use this to trigger any necessary. events.

Returns

an event context

virtual IFactory* mi::​nservices::​ICommand_context::get_factory() const [pure virtual]

Returns a factory, may be used to create neuray services data or other required classes.

Returns

a factory

virtual Uint32 mi::​nservices::​ICommand_context::get_num_arguments() const [pure virtual]

The number of arguments to the command.

Returns

number of arguments

virtual neuraylib::IPlugin_api* mi::​nservices::​ICommand_context::get_plugin_api() const [pure virtual]

Get the neuray IPlugin_api. Provides direct access to the neuray library.

Returns

the plugin api

virtual neuraylib::ITransaction* mi::​nservices::​ICommand_context::get_transaction() [pure virtual]

Get the current transaction associated with this service request. This transaction is the primary entry point into the neuray database. Unless the command requires access to a specific scope it should conduct all work with this transaction.

Returns

the transaction

virtual neuraylib::ITransaction* mi::​nservices::​ICommand_context::get_user_state() [pure virtual]

Gets a transaction into the user state.

Returns

the state transaction or NULL if no state exists