Class: Sfcc::Cim::ObjectPath
- Inherits:
-
Object
- Object
- Sfcc::Cim::ObjectPath
- Defined in:
- lib/sfcc.rb,
ext/sfcc/cim_object_path.c
Class Method Summary collapse
-
.new ⇒ Object
Creates an object path from
namespaceandclass_name.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#add_key(name, value) ⇒ Object
adds a named key value.
-
#class_qualifier(qualifier_name) ⇒ Object
Get class qualifier value.
-
#classname ⇒ Object
Get the class name component.
-
#classname=(ns) ⇒ Object
Set/replace the class name component.
-
#do(|name, value|) ⇒ Object
end.
-
#hostname ⇒ Object
Get the hostname component.
-
#hostname=(ns) ⇒ Object
Set/replace the hostname component.
-
#key(name) ⇒ Object
Gets a named key value.
-
#key_count ⇒ Object
Gets the number of properties contained in this ObjectPath.
- #method_missing(name, *args) ⇒ Object
-
#method_qualifier(method_name, qualifier_name) ⇒ Object
Get method qualifier value.
-
#namespace ⇒ Object
Get the namespace component.
-
#namespace=(ns) ⇒ Object
Set/replace the namespace component.
-
#parameter_qualifier(parameter_name, qualifier_name) ⇒ Object
Get parameter qualifier value.
-
#property_qualifier(property_name, qualifier_name) ⇒ Object
Get property qualifier value.
-
#set_host_and_namespace_from(object_path) ⇒ Object
Set/replace the hostname namespace and classname components from
object_path. -
#set_namespace_from(object_path) ⇒ Object
Set/replace the namespace and classname components from
object_path. -
#to_s ⇒ Object
Generates a well formed string representation of this ObjectPath.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
224 225 226 |
# File 'lib/sfcc.rb', line 224 def method_missing name, *args self[name] end |
Class Method Details
.new ⇒ Object
Creates an object path from namespace and class_name
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'ext/sfcc/cim_object_path.c', line 389
static VALUE new(int argc, VALUE *argv, VALUE self)
{
VALUE namespace;
VALUE class_name;
CIMCStatus status;
CIMCObjectPath *ptr;
memset(&status, 0, sizeof(CIMCStatus));
rb_scan_args(argc, argv, "11", &namespace, &class_name);
ptr = cimcEnv->ft->newObjectPath(cimcEnv, to_charptr(namespace), to_charptr(class_name), &status);
if (!status.rc)
return Sfcc_wrap_cim_object_path(ptr);
sfcc_rb_raise_if_error(status, "Can't create object path");
return Qnil;
}
|
Instance Method Details
#[](name) ⇒ Object
221 222 223 |
# File 'lib/sfcc.rb', line 221 def [] name self.key(name) end |
#add_key(name, value) ⇒ Object
adds a named key value
119 120 121 122 123 124 125 126 127 |
# File 'ext/sfcc/cim_object_path.c', line 119
static VALUE add_key(VALUE self, VALUE name, VALUE value)
{
CIMCObjectPath *ptr;
CIMCData data;
Data_Get_Struct(self, CIMCObjectPath, ptr);
data = sfcc_value_to_cimdata(value);
ptr->ft->addKey(ptr, to_charptr(name), &data.value, data.type);
return value;
}
|
#class_qualifier(qualifier_name) ⇒ Object
Get class qualifier value
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'ext/sfcc/cim_object_path.c', line 259
static VALUE class_qualifier(VALUE self, VALUE qualifier_name)
{
CIMCObjectPath *ptr;
CIMCStatus status;
CIMCData data;
memset(&status, 0, sizeof(CIMCStatus));
Data_Get_Struct(self, CIMCObjectPath, ptr);
if (ptr->ft->getClassQualifier) { /* might be missing in sfcc/backend/cimxml/objectpath.c */
data = ptr->ft->getClassQualifier(ptr, to_charptr(qualifier_name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
}
else {
status.rc = CIMC_RC_ERR_NOT_SUPPORTED;
status.msg = NULL;
}
sfcc_rb_raise_if_error(status, "Can't retrieve class qualifier '%s'", to_charptr(qualifier_name));
return Qnil;
}
|
#classname ⇒ Object
Get the class name component
104 105 106 107 108 109 110 111 |
# File 'ext/sfcc/cim_object_path.c', line 104
static VALUE classname(VALUE self)
{
CIMCObjectPath *ptr;
CIMCString *cimstr;
Data_Get_Struct(self, CIMCObjectPath, ptr);
cimstr = ptr->ft->getClassName(ptr, NULL);
return CIMSTR_2_RUBYSTR(cimstr);
}
|
#classname=(ns) ⇒ Object
Set/replace the class name component
90 91 92 93 94 95 96 |
# File 'ext/sfcc/cim_object_path.c', line 90
static VALUE set_classname(VALUE self, VALUE val)
{
CIMCObjectPath *ptr;
Data_Get_Struct(self, CIMCObjectPath, ptr);
ptr->ft->setClassName(ptr, to_charptr(val));
return val;
}
|
#do(|name, value|) ⇒ Object
end
enumerates properties yielding the key name and its value
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'ext/sfcc/cim_object_path.c', line 159
static VALUE each_key(VALUE self)
{
CIMCObjectPath *ptr;
CIMCStatus status;
int k=0;
int num_props=0;
CIMCString *key_name = NULL;
CIMCData data;
Data_Get_Struct(self, CIMCObjectPath, ptr);
num_props = ptr->ft->getKeyCount(ptr, &status);
if (!status.rc) {
for (; k < num_props; ++k) {
data = ptr->ft->getKeyAt(ptr, k, &key_name, &status);
if (!status.rc) {
rb_yield_values(2, rb_str_intern(CIMSTR_2_RUBYSTR(key_name)), sfcc_cimdata_to_value(data));
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve key #%d", k);
}
if (key_name) CMRelease(key_name);
}
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve key count");
}
return Qnil;
}
|
#hostname ⇒ Object
Get the hostname component
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'ext/sfcc/cim_object_path.c', line 72
static VALUE hostname(VALUE self)
{
CIMCObjectPath *ptr;
CIMCString *cimstr;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
cimstr = ptr->ft->getHostname(ptr, &status);
if (!status.rc)
return CIMSTR_2_RUBYSTR(cimstr);
sfcc_rb_raise_if_error(status, "Can't get hostname");
return Qnil;
}
|
#hostname=(ns) ⇒ Object
Set/replace the hostname component
54 55 56 57 58 59 60 61 62 63 64 |
# File 'ext/sfcc/cim_object_path.c', line 54
static VALUE set_hostname(VALUE self, VALUE val)
{
CIMCObjectPath *ptr;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
status = ptr->ft->setHostname(ptr, to_charptr(val));
if (!status.rc)
return val;
sfcc_rb_raise_if_error(status, "Can't set hostname");
return Qnil;
}
|
#key(name) ⇒ Object
Gets a named key value
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'ext/sfcc/cim_object_path.c', line 135
static VALUE key(VALUE self, VALUE name)
{
CIMCObjectPath *ptr;
CIMCStatus status;
CIMCData data;
Data_Get_Struct(self, CIMCObjectPath, ptr);
data = ptr->ft->getKey(ptr, to_charptr(name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
sfcc_rb_raise_if_error(status, "Can't retrieve key '%s'", to_charptr(name));
return Qnil;
}
|
#key_count ⇒ Object
Gets the number of properties contained in this ObjectPath
194 195 196 197 198 199 |
# File 'ext/sfcc/cim_object_path.c', line 194
static VALUE key_count(VALUE self)
{
CIMCObjectPath *ptr;
Data_Get_Struct(self, CIMCObjectPath, ptr);
return UINT2NUM(ptr->ft->getKeyCount(ptr, NULL));
}
|
#method_qualifier(method_name, qualifier_name) ⇒ Object
Get method qualifier value
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'ext/sfcc/cim_object_path.c', line 312
static VALUE method_qualifier(VALUE self, VALUE method_name, VALUE qualifier_name)
{
CIMCObjectPath *ptr;
CIMCStatus status;
CIMCData data;
memset(&status, 0, sizeof(CIMCStatus));
Data_Get_Struct(self, CIMCObjectPath, ptr);
if (ptr->ft->getMethodQualifier) { /* might be missing in sfcc/backend/cimxml/objectpath.c */
data = ptr->ft->getMethodQualifier(ptr, to_charptr(method_name),
to_charptr(qualifier_name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
}
else {
status.rc = CIMC_RC_ERR_NOT_SUPPORTED;
status.msg = NULL;
}
sfcc_rb_raise_if_error(status, "Can't retrieve method qualifier '%s' for method '%s'", to_charptr(qualifier_name), to_charptr(method_name));
return Qnil;
}
|
#namespace ⇒ Object
Get the namespace component
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'ext/sfcc/cim_object_path.c', line 35
static VALUE namespace(VALUE self)
{
CIMCObjectPath *ptr;
CIMCString *cimstr;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
cimstr = ptr->ft->getNameSpace(ptr, &status);
if (!status.rc)
return CIMSTR_2_RUBYSTR(cimstr);
sfcc_rb_raise_if_error(status, "Can't get namespace");
return Qnil;
}
|
#namespace=(ns) ⇒ Object
Set/replace the namespace component
17 18 19 20 21 22 23 24 25 26 27 |
# File 'ext/sfcc/cim_object_path.c', line 17
static VALUE set_namespace(VALUE self, VALUE val)
{
CIMCObjectPath *ptr;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
status = ptr->ft->setNameSpace(ptr, to_charptr(val));
if (!status.rc)
return val;
sfcc_rb_raise_if_error(status, "Can't set namespace");
return Qnil;
}
|
#parameter_qualifier(parameter_name, qualifier_name) ⇒ Object
Get parameter qualifier value
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'ext/sfcc/cim_object_path.c', line 339
static VALUE parameter_qualifier(VALUE self,
VALUE method_name,
VALUE parameter_name,
VALUE qualifier_name)
{
CIMCObjectPath *ptr;
CIMCStatus status;
CIMCData data;
memset(&status, 0, sizeof(CIMCStatus));
Data_Get_Struct(self, CIMCObjectPath, ptr);
if (ptr->ft->getParameterQualifier) { /* might be missing in sfcc/backend/cimxml/objectpath.c */
data = ptr->ft->getParameterQualifier(ptr,
to_charptr(method_name),
to_charptr(parameter_name),
to_charptr(qualifier_name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
}
else {
status.rc = CIMC_RC_ERR_NOT_SUPPORTED;
status.msg = NULL;
}
sfcc_rb_raise_if_error(status, "Can't retrieve parameter qualifier '%s' for '%s'/'%s'", to_charptr(qualifier_name), to_charptr(method_name), to_charptr(parameter_name));
return Qnil;
}
|
#property_qualifier(property_name, qualifier_name) ⇒ Object
Get property qualifier value
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'ext/sfcc/cim_object_path.c', line 285
static VALUE property_qualifier(VALUE self, VALUE property_name, VALUE qualifier_name)
{
CIMCObjectPath *ptr;
CIMCStatus status;
CIMCData data;
memset(&status, 0, sizeof(CIMCStatus));
Data_Get_Struct(self, CIMCObjectPath, ptr);
if (ptr->ft->getPropertyQualifier) { /* might be missing in sfcc/backend/cimxml/objectpath.c */
data = ptr->ft->getPropertyQualifier(ptr, to_charptr(property_name),
to_charptr(qualifier_name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
}
else {
status.rc = CIMC_RC_ERR_NOT_SUPPORTED;
status.msg = NULL;
}
sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier '%s' for property '%s'", to_charptr(qualifier_name), to_charptr(property_name));
return Qnil;
}
|
#set_host_and_namespace_from(object_path) ⇒ Object
Set/replace the hostname namespace and classname components from object_path
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'ext/sfcc/cim_object_path.c', line 233
static VALUE set_host_and_namespace_from(VALUE self, VALUE object_path)
{
CIMCObjectPath *ptr;
CIMCObjectPath *src;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
Data_Get_Struct(object_path, CIMCObjectPath, src);
if (ptr->ft->setHostAndNameSpaceFromObjectPath) { /* might be missing in sfcc/backend/cimxml/objectpath.c */
status = ptr->ft->setHostAndNameSpaceFromObjectPath(ptr, src);
}
if (!status.rc)
return self;
sfcc_rb_raise_if_error(status, "Can't set namespace and hostname");
return Qnil;
}
|
#set_namespace_from(object_path) ⇒ Object
Set/replace the namespace and classname components from object_path
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'ext/sfcc/cim_object_path.c', line 208
static VALUE set_namespace_from(VALUE self, VALUE object_path)
{
CIMCObjectPath *ptr;
CIMCObjectPath *src;
CIMCStatus status;
Data_Get_Struct(self, CIMCObjectPath, ptr);
Data_Get_Struct(object_path, CIMCObjectPath, src);
status = ptr->ft->setNameSpaceFromObjectPath(ptr, src);
if (!status.rc)
return self;
sfcc_rb_raise_if_error(status, "Can't set namespace");
return Qnil;
}
|
#to_s ⇒ Object
Generates a well formed string representation of this ObjectPath
370 371 372 373 374 375 376 377 378 379 380 |
# File 'ext/sfcc/cim_object_path.c', line 370
static VALUE to_s(VALUE self)
{
VALUE ret;
CIMCObjectPath *ptr;
CIMCString *cimstr;
Data_Get_Struct(self, CIMCObjectPath, ptr);
cimstr = ptr->ft->toString(ptr, NULL);
ret = CIMSTR_2_RUBYSTR(cimstr);
CMRelease(cimstr);
return ret;
}
|