set_message_objT_set_message_objSetMessageObjSetMessageObj (Operator)

Name

set_message_objT_set_message_objSetMessageObjSetMessageObj — Add a key/object pair to the message.

Signature

set_message_obj(ObjectData : : MessageHandle, Key : )

Herror T_set_message_obj(const Hobject ObjectData, const Htuple MessageHandle, const Htuple Key)

void SetMessageObj(const HObject& ObjectData, const HTuple& MessageHandle, const HTuple& Key)

void HMessage::SetMessageObj(const HObject& ObjectData, const HTuple& Key) const

void HMessage::SetMessageObj(const HObject& ObjectData, const HString& Key) const

void HMessage::SetMessageObj(const HObject& ObjectData, const char* Key) const

void HMessage::SetMessageObj(const HObject& ObjectData, const wchar_t* Key) const   (Windows only)

static void HOperatorSet.SetMessageObj(HObject objectData, HTuple messageHandle, HTuple key)

void HMessage.SetMessageObj(HObject objectData, HTuple key)

void HMessage.SetMessageObj(HObject objectData, string key)

Description

set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj stores an object associated with a key in the message, which behaves as a dictionary-like data container. The message is denoted by the MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle parameter.

ObjectDataObjectDataObjectDataObjectDataobjectData is copied by the operation (copying the object data in HALCON's object database, see copy_objcopy_objCopyObjCopyObjCopyObj), and can thus be immediately reused. Both an empty object or an object tuple are considered as a valid value that can be associated with the key. If any data (tuple or object) was already associated with given key (KeyKeyKeyKeykey), the old data is destroyed by set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj and replaced by ObjectDataObjectDataObjectDataObjectDataobjectData.

The KeyKeyKeyKeykey has to be a string or an integer. String keys are treated case sensitive.

The object data for the given key can be retrieved again from the message using get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj.

Execution Information

This operator modifies the state of the following input parameter:

The value of this parameter may not be shared across multiple threads without external synchronization.

Parameters

ObjectDataObjectDataObjectDataObjectDataobjectData (input_object)  object(-array) objectHObjectHObjectHobject

Object to be associated with the key.

MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle (input_control, state is modified)  message HMessage, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Message handle.

Number of elements: MessageHandle == 1

Restriction: MessageHandle != 0

KeyKeyKeyKeykey (input_control)  string HTupleHTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Key string or integer.

Number of elements: Key == 1

Example (HDevelop)

create_message (Message)
read_image( Image, 'filename')
set_message_obj (Image, Message, 'my_image')

Result

If the operation succeeds, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple returns 2 (H_MSG_TRUE). Otherwise an exception is raised. Possible error conditions include invalid parameters (handle or key) or resource allocation error.

Possible Predecessors

create_messagecreate_messageCreateMessageCreateMessageCreateMessage

Possible Successors

enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple

Alternatives

set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple

See also

create_messagecreate_messageCreateMessageCreateMessageCreateMessage, clear_messageclear_messageClearMessageClearMessageClearMessage, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple, get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple, get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj, set_message_paramset_message_paramSetMessageParamSetMessageParamSetMessageParam, get_message_paramget_message_paramGetMessageParamGetMessageParamGetMessageParam, enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage, dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage

Module

Foundation