spacepaste

  1.  
  2. def AOM_ask_value_strings(object_tag, prop_name__py_str):
  3. '''
  4. Input:
  5. tag_t object_tag (I) -- < (I) Unique identifier (tag) of the object instance.
  6. const char* prop_name (I) -- < (I) A property name of the object instance.
  7. Output:
  8. char*** values (OL(num)F) -- < (OF) num Actual values of the property. This must be a list or array
  9. of constant chars. If the property is an array, the number of
  10. values passed in must equal the size of the array.
  11. Iterate through the output array and call MEM_free on each element to de-allocate
  12. the nested memory block and then free the memory pointed by itself using MEM_free.
  13. Asks one or more values of a property. The property can be single-valued or multi-valued (i.e., array or list).
  14. This function uses #PROP_ask_value_strings_msg if multi-valued and #PROP_ask_value_string_msg if single-valued.
  15. To customize the behavior of this function, register a method against one of these messages.
  16. '''
  17. num = ffi.new('int*')
  18. values = ffi.new('char***')
  19. prop_name = prop_name__py_str if prop_name__py_str != None else ffi.NULL
  20. __pytk__ifail__return__ = itklib.AOM_ask_value_strings(object_tag, prop_name, num, values)
  21. iFail2Exception(__pytk__ifail__return__)
  22. values__py_list = [ffi.string(values[0][pytk_i]) if values[0][pytk_i] != ffi.NULL else None for pytk_i in xrange(num[0])]
  23. for pytk_i in xrange(num[0]):
  24. itklib.MEM_free(values[0][pytk_i])
  25. itklib.MEM_free(values[0])
  26. return values__py_list
  27. def AOM_ask_value_tag(object_tag, prop_name__py_str):
  28. '''
  29. Input:
  30. tag_t object_tag (I) -- < (I) Unique identifier (tag) of the object instance.
  31. const char* prop_name (I) -- < (I) A property name of the object instance.
  32. Output:
  33. tag_t* value (O) -- < (O) Actual value of the property.
  34. Asks value of a single-valued property.
  35. This function uses #PROP_ask_value_tag_msg.
  36. To customize the behavior of this function, register a method against this message name.
  37. '''
  38. value = ffi.new('tag_t*')
  39. prop_name = prop_name__py_str if prop_name__py_str != None else ffi.NULL
  40. __pytk__ifail__return__ = itklib.AOM_ask_value_tag(object_tag, prop_name, value)
  41. iFail2Exception(__pytk__ifail__return__)
  42. return value[0]
  43. def AOM_ask_value_tag_at(object_tag, prop_name__py_str, position):
  44. '''
  45. Input:
  46. tag_t object_tag (I) -- < (I) Unique identifier (tag) of the object instance.
  47. const char* prop_name (I) -- < (I) A property name of the object instance.
  48. int position (I) -- < (I) The position of the specified property in an array or list.
  49. The first position is 0. For example, if the property is
  50. an array of size 3 and the third value in the array is to be modified,
  51. then position = 2.
  52. Output:
  53. tag_t* value (O) -- < (O) Actual value of the property at the specified index position.
  54. Asks value of a multi-valued (i.e., list or array) property at a particular index position.
  55. The property can be single-valued if position = 0.
  56. This function uses #PROP_ask_value_tag_at_msg if the property is multi-valued or
  57. #PROP_ask_value_tag_msg if the property is single-valued and position = 0.
  58. To customize the behavior of this function, register a method against one of these messages.
  59. '''
  60. value = ffi.new('tag_t*')
  61. prop_name = prop_name__py_str if prop_name__py_str != None else ffi.NULL
  62. __pytk__ifail__return__ = itklib.AOM_ask_value_tag_at(object_tag, prop_name, position, value)
  63. iFail2Exception(__pytk__ifail__return__)
  64. return value[0]
  65. def AOM_ask_value_tags(object_tag, prop_name__py_str):
  66. '''
  67. Input:
  68. tag_t object_tag (I) -- < (I) Unique identifier (tag) of the object instance.
  69. const char* prop_name (I) -- < (I) A property name of the object instance.
  70. Output:
  71. tag_t** values (OL(num)F) -- < (OF) num Actual values of the property. This must be a list or array of
  72. constant chars. If the property is an array, the number of values
  73. passed in must equal the size of the array.
  74. Asks one or more values of a property. The property can be single-valued or multi-valued (i.e., array or list).
  75. This function uses #PROP_ask_value_tags_msg if multi-valued and #PROP_ask_value_tag_msg if single-valued.
  76. To customize the behavior of this function, register a method against one of these messages.
  77. '''
  78. num = ffi.new('int*')
  79. values = ffi.new('tag_t**')
  80. prop_name = prop_name__py_str if prop_name__py_str != None else ffi.NULL
  81. __pytk__ifail__return__ = itklib.AOM_ask_value_tags(object_tag, prop_name, num, values)
  82. iFail2Exception(__pytk__ifail__return__)
  83. values__py_list = [values[0][pytk_i] for pytk_i in xrange(num[0])]
  84. itklib.MEM_free(values[0])
  85. return values__py_list
  86.