class cmpi::CMPIInstance

* */

Public Instance Methods

get(p1) click to toggle source

get a named property value Property access in Ruby: data = instance # access by name (symbol) data = instance[“propname” # access by name (string) data = instance # access by index

See #get_property_at to retrieve property name and value

VALUE get(VALUE property)
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data;
    if (FIXNUM_P(property)) {
      data = CMGetPropertyAt($self, FIX2ULONG(property), NULL, &st);
    }
    else {
      const char *name;
      name = target_charptr(property);

      data = CMGetProperty($self, name, &st);
    }
    RAISE_IF(st);
    return data_value(&data);
  }



#if defined (SWIGRUBY)
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV * 
#endif
  /** Gets a Property name and value defined by its index.
   * index: Position in the internal Data array.
   */
  __type get_property_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetPropertyAt($self, index, &s, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
/*    fprintf(stderr, "CMGetPropertyAt(%d) -> name %s, data type %x, state %x, value %p\n", index, CMGetCharPtr(s), data.type, data.state, data.value);
    fflush(stderr);
    */
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, tdata);
    PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
#else
    result = Target_SizedArray(2);
    Target_Append(result, tdata);
    Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
    TARGET_THREAD_END_BLOCK;
    CMRelease(s);
    return result;
  }


  %alias property_count "size";

  /* Gets the number of properties contained in this Instance. */
  int property_count() 
  {
    int result;
    CMPIStatus st = { CMPI_RC_OK, NULL };

    result = CMGetPropertyCount($self, &st);
    RAISE_IF(st);

    return result;
  }

  /* Generates an ObjectPath out of the namespace, classname and
   *  key propeties of this Instance.
   */
  CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
get_property_at(p1) click to toggle source

Gets a Property name and value defined by its index.

index: Position in the internal Data array.
__type get_property_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetPropertyAt($self, index, &s, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
/*    fprintf(stderr, "CMGetPropertyAt(%d) -> name %s, data type %x, state %x, value %p\n", index, CMGetCharPtr(s), data.type, data.state, data.value);
    fflush(stderr);
    */
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, tdata);
    PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
#else
    result = Target_SizedArray(2);
    Target_Append(result, tdata);
    Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
    TARGET_THREAD_END_BLOCK;
    CMRelease(s);
    return result;
  }


  %alias property_count "size";

  /* Gets the number of properties contained in this Instance. */
  int property_count() 
  {
    int result;
    CMPIStatus st = { CMPI_RC_OK, NULL };

    result = CMGetPropertyCount($self, &st);
    RAISE_IF(st);

    return result;
  }

  /* Generates an ObjectPath out of the namespace, classname and
   *  key propeties of this Instance.
   */
  CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
objectpath() click to toggle source

Generates an ObjectPath out of the namespace, classname and

key propeties of this Instance.
CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
property_count() click to toggle source

Gets the number of properties contained in this Instance.

int property_count() 
  {
    int result;
    CMPIStatus st = { CMPI_RC_OK, NULL };

    result = CMGetPropertyCount($self, &st);
    RAISE_IF(st);

    return result;
  }

  /* Generates an ObjectPath out of the namespace, classname and
   *  key propeties of this Instance.
   */
  CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
set(p1, p2, p3) click to toggle source

Property setting in Ruby

set property of Instance by name and type

instance = data # set by name (symbol) instance[:propname, data] = CMPI::uint16 # set by name (symbol) instance = data # set by name (string)

CMPIStatus set(VALUE property, VALUE data, VALUE expected_type = Qnil)
  {
    const char *name;
    CMPIValue value;
    CMPIType actual_type;
    CMPIType type;
    CMPIStatus status;
    if (NIL_P(expected_type)) {
      type = CMPI_null;
    }
    else if (FIXNUM_P(expected_type)) {
      type = FIX2LONG(expected_type);
    }
    else {
      SWIG_exception(SWIG_ValueError, "bad expected_type");
    }
    name = target_charptr(property);
    if (NIL_P(data)) {
      actual_type = type; /* prevent type error */
      value.chars = NULL;
    }
    else {
      actual_type = target_to_value(data, &value, type);
    }
/*    fprintf(stderr, "CMPIInstance.%s <expected %04x, actual %04x>\n",name, type, actual_type); */
    status = CMSetProperty($self, name, &value, actual_type);
    RAISE_IF(status);
    return status;
  }


  /* Adds/replaces a named Property.
   * name: Entry name.
   * value: Address of value structure.
   * type: Value type.
   */
  void set_property(
      const char *name, 
      const CMPIValue * value, 
      const CMPIType type) 
  {
    RAISE_IF(CMSetProperty($self, name, value, type));
  }


  %alias get "[]";
  /*
   * get a named property value
   * Property access in Ruby:
   * data = instance[:propname]     # access by name (symbol)
   * data = instance["propname"     # access by name (string)
   * data = instance[1]             # access by index
   *
   * See get_property_at to retrieve property name and value
   */
  VALUE get(VALUE property)
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data;
    if (FIXNUM_P(property)) {
      data = CMGetPropertyAt($self, FIX2ULONG(property), NULL, &st);
    }
    else {
      const char *name;
      name = target_charptr(property);

      data = CMGetProperty($self, name, &st);
    }
    RAISE_IF(st);
    return data_value(&data);
  }



#if defined (SWIGRUBY)
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV * 
#endif
  /** Gets a Property name and value defined by its index.
   * index: Position in the internal Data array.
   */
  __type get_property_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetPropertyAt($self, index, &s, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
/*    fprintf(stderr, "CMGetPropertyAt(%d) -> name %s, data type %x, state %x, value %p\n", index, CMGetCharPtr(s), data.type, data.state, data.value);
    fflush(stderr);
    */
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, tdata);
    PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
#else
    result = Target_SizedArray(2);
    Target_Append(result, tdata);
    Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
    TARGET_THREAD_END_BLOCK;
    CMRelease(s);
    return result;
  }


  %alias property_count "size";

  /* Gets the number of properties contained in this Instance. */
  int property_count() 
  {
    int result;
    CMPIStatus st = { CMPI_RC_OK, NULL };

    result = CMGetPropertyCount($self, &st);
    RAISE_IF(st);

    return result;
  }

  /* Generates an ObjectPath out of the namespace, classname and
   *  key propeties of this Instance.
   */
  CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
set_objectpath(p1) click to toggle source

Replaces the ObjectPath of the instance.

The passed objectpath shall contain the namespace, classname,
 as well as all keys for the specified instance.
void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
set_property(p1, p2, p3) click to toggle source

Adds/replaces a named Property.

name: Entry name.
value: Address of value structure.
type: Value type.
void set_property(
      const char *name, 
      const CMPIValue * value, 
      const CMPIType type) 
  {
    RAISE_IF(CMSetProperty($self, name, value, type));
  }


  %alias get "[]";
  /*
   * get a named property value
   * Property access in Ruby:
   * data = instance[:propname]     # access by name (symbol)
   * data = instance["propname"     # access by name (string)
   * data = instance[1]             # access by index
   *
   * See get_property_at to retrieve property name and value
   */
  VALUE get(VALUE property)
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data;
    if (FIXNUM_P(property)) {
      data = CMGetPropertyAt($self, FIX2ULONG(property), NULL, &st);
    }
    else {
      const char *name;
      name = target_charptr(property);

      data = CMGetProperty($self, name, &st);
    }
    RAISE_IF(st);
    return data_value(&data);
  }



#if defined (SWIGRUBY)
  VALUE
#endif
#if defined (SWIGPYTHON)
  PyObject* 
#endif
#if defined (SWIGPERL)
  SV * 
#endif
  /** Gets a Property name and value defined by its index.
   * index: Position in the internal Data array.
   */
  __type get_property_at(int index) 
  {
    Target_Type tdata;
    Target_Type result;
    CMPIString *s = NULL;
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIData data = CMGetPropertyAt($self, index, &s, &st);
    if (st.rc)
    {
        RAISE_IF(st);
        result = Target_Null;
        Target_INCREF(result);
        return result;
    }
/*    fprintf(stderr, "CMGetPropertyAt(%d) -> name %s, data type %x, state %x, value %p\n", index, CMGetCharPtr(s), data.type, data.state, data.value);
    fflush(stderr);
    */
    TARGET_THREAD_BEGIN_BLOCK;
    tdata = data_data(&data);
#if defined (SWIGPYTHON)
    result = PyTuple_New(2);
    PyTuple_SetItem(result, 0, tdata);
    PyTuple_SetItem(result, 1, PyString_FromString(CMGetCharPtr(s)));
#else
    result = Target_SizedArray(2);
    Target_Append(result, tdata);
    Target_Append(result, Target_String(CMGetCharPtr(s)));
#endif
    TARGET_THREAD_END_BLOCK;
    CMRelease(s);
    return result;
  }


  %alias property_count "size";

  /* Gets the number of properties contained in this Instance. */
  int property_count() 
  {
    int result;
    CMPIStatus st = { CMPI_RC_OK, NULL };

    result = CMGetPropertyCount($self, &st);
    RAISE_IF(st);

    return result;
  }

  /* Generates an ObjectPath out of the namespace, classname and
   *  key propeties of this Instance.
   */
  CMPIObjectPath *objectpath() 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* result;

    result = CMGetObjectPath($self, &st);
    RAISE_IF(st);
    /* fprintf(stderr, "<%p>.objectpath = %p\n", $self, result); */

    return result;
  }


  %alias set_objectpath "objectpath=";

  /* Replaces the ObjectPath of the instance.
   *  The passed objectpath shall contain the namespace, classname,
   *   as well as all keys for the specified instance.
   */
  void set_objectpath(const CMPIObjectPath *path) 
  {
    RAISE_IF(CMSetObjectPath($self, path));
  }

  /* Directs CMPI to ignore any setProperty operations for this
   *        instance for any properties not in this list.
   * properties: If not NULL, the members of the array define one
   *         or more Property names to be accepted by setProperty operations.
   */
  void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
set_property_filter(p1) click to toggle source

Directs CMPI to ignore any setProperty operations for this

       instance for any properties not in this list.
properties: If not NULL, the members of the array define one
        or more Property names to be accepted by setProperty operations.
void set_property_filter(const char **properties) 
  {
    CMPIStatus st = { CMPI_RC_OK, NULL };
    CMPIObjectPath* cop;
    CMPICount n;
    CMPICount i;
    char** props;

    /* Make copy of property list (we may modify it) */
    
    props = string_array_clone((char**)properties);

#if 0
    string_array_print(props);
#endif

    /* Pegasus requires that the keys be in the property list, else it
     * throws an exception. To work around, add key properties to property
     * list.
     */

    if (!(cop = CMGetObjectPath($self, &st)) || st.rc)
    {
        st.rc = CMPI_RC_ERR_FAILED;
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    n = CMGetKeyCount(cop, &st);

    if (st.rc)
    {
        RAISE_IF(st);
        string_array_free(props);
        return;
    }

    for (i = 0; i < n; i++)
    {
        CMPIString* pn = NULL;
        const char* str;

        (void)CMGetKeyAt(cop, i, &pn, &st); /* get key name at i */

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        str = CMGetCharsPtr(pn, &st);

        if (st.rc)
        {
            RAISE_IF(st);
            string_array_free(props);
            return;
        }

        if (string_array_find_ignore_case(props, str) == NULL)
            props = string_array_append(props, str);
    }

#if 0
    string_array_print(props);
#endif

    RAISE_IF(CMSetPropertyFilter($self, (const char**)props, NULL));

    string_array_free(props);
  }

  /* Add/replace a named Property value and origin
   * name: is a string containing the Property name.
   * value: points to a CMPIValue structure containing the value
   *        to be assigned to the Property.
   * type: is a CMPIType structure defining the type of the value.
   * origin: specifies the instance origin.  If NULL, then
             no origin is attached to  the property
   */
  void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}
set_property_with_origin(p1, p2, p3, p4) click to toggle source

Add/replace a named Property value and origin

name: is a string containing the Property name.
value: points to a CMPIValue structure containing the value
       to be assigned to the Property.
type: is a CMPIType structure defining the type of the value.
origin: specifies the instance origin.  If NULL, then
        no origin is attached to  the property
void set_property_with_origin(
      const char *name,
     const CMPIValue *value, 
     CMPIType type, 
     const char* origin)
  {
    RAISE_IF(CMSetPropertyWithOrigin($self, name, value, type, origin));
  }
}