public void add_attribute ( final Attr new_attr ) throws DevFailed { final Vector attr_list = device_class . get_class_attr ( ) . get_attr_list ( ) ; final int old_attr_nb = attr_list . size ( ) ; // // Check that this attribute is not already defined for this device. // If it is alaredy there, immediately returns. // Trick : If you add an attribute to a device, this attribute will be // inserted in the device class attribute list. Therefore, all devices // created after this attribute addition will also have this attribute. // final String attr_name = new_attr . get_name ( ) ; boolean already_there = true ; try { dev_attr . get_attr_by_name ( attr_name ) ; } catch ( final DevFailed ex ) { already_there = false ; } if ( already_there == true ) { return ; } // // Add this attribute in the MultiClassAttribute attr_list vector if it // does not // already exist // int i ; for ( i = 0 ; i < old_attr_nb ; i ++ ) { if ( ( ( Attr ) attr_list . elementAt ( i ) ) . get_name ( ) . equals ( attr_name ) == true ) { break ; } } if ( i == old_attr_nb ) { attr_list . addElement ( new_attr ) ; // // Get all the properties defined for this attribute at class level // device_class . get_class_attr ( ) . init_class_attribute ( device_class . get_name ( ) , old_attr_nb ) ; } // // Add the attribute to the MultiAttribute object // dev_attr . add_attribute ( device_name , device_class , i ) ; }
Add a new attribute to the device attribute list .