set_dict_objectT_set_dict_objectSetDictObjectSetDictObjectset_dict_object (Operator)
Name
set_dict_objectT_set_dict_objectSetDictObjectSetDictObjectset_dict_object
— Add a key/object pair to the dictionary.
Signature
void SetDictObject(const HObject& Object, const HTuple& DictHandle, const HTuple& Key)
void HDict::SetDictObject(const HObject& Object, const HTuple& Key) const
void HDict::SetDictObject(const HObject& Object, const HString& Key) const
void HDict::SetDictObject(const HObject& Object, const char* Key) const
void HDict::SetDictObject(const HObject& Object, const wchar_t* Key) const
(
Windows only)
Description
set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObjectset_dict_object
stores an object associated with a key in the
dictionary.
The dictionary is denoted by the DictHandleDictHandleDictHandleDictHandledictHandledict_handle
parameter.
ObjectObjectObjectObjectobjectValobject
is copied by the operation and can thus be
immediately reused.
Thereby the object data is copied in HALCON's object database,
meaning the new object contains a reference to ObjectObjectObjectObjectobjectValobject
,
see copy_objcopy_objCopyObjCopyObjCopyObjcopy_obj
.
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
(KeyKeyKeyKeykeykey
), the old data is destroyed by set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObjectset_dict_object
and replaced by ObjectObjectObjectObjectobjectValobject
.
The KeyKeyKeyKeykeykey
has to be a string or an integer.
Strings are treated case sensitive.
The object data for the given key can be retrieved again from the dictionary
using get_dict_objectget_dict_objectGetDictObjectGetDictObjectGetDictObjectget_dict_object
.
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
This operator modifies the state of the following input parameter:
During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.
Parameters
ObjectObjectObjectObjectobjectValobject
(input_object) object(-array) →
objectHObjectHObjectHObjectHobject
Object to be associated with the key.
DictHandleDictHandleDictHandleDictHandledictHandledict_handle
(input_control, state is modified) dict →
HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Dictionary handle.
Number of elements:
DictHandle == 1
KeyKeyKeyKeykeykey
(input_control) string →
HTupleUnion[str, int]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)
Key string.
Number of elements:
Key == 1
Restriction:
length(Key) > 0
Example (HDevelop)
create_dict (Dict)
read_image (Image, 'filename')
set_dict_object (Image, Dict, 'my_image')
Result
If the operation succeeds, set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple
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_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict
Possible Successors
set_dict_objectset_dict_objectSetDictObjectSetDictObjectSetDictObjectset_dict_object
,
set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple
Alternatives
set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple
See also
create_dictcreate_dictCreateDictCreateDictCreateDictcreate_dict
,
set_dict_tupleset_dict_tupleSetDictTupleSetDictTupleSetDictTupleset_dict_tuple
,
get_dict_tupleget_dict_tupleGetDictTupleGetDictTupleGetDictTupleget_dict_tuple
,
get_dict_objectget_dict_objectGetDictObjectGetDictObjectGetDictObjectget_dict_object
,
remove_dict_keyremove_dict_keyRemoveDictKeyRemoveDictKeyRemoveDictKeyremove_dict_key
,
get_dict_paramget_dict_paramGetDictParamGetDictParamGetDictParamget_dict_param
Module
Foundation