@@ -554,52 +554,66 @@ void MultiAttribute::add_user_default(vector<AttrProperty> &prop_list,vector<Att
554554//
555555// ------------------------------------------------------------------------------------------------------------------
556556
557- void MultiAttribute::check_associated (long index,string &dev_name)
557+ void MultiAttribute::check_associated (long index, std:: string &dev_name)
558558{
559- if ((attr_list[index]->get_writable () == Tango::READ_WITH_WRITE) ||
560- (attr_list[index]->get_writable () == Tango::READ_WRITE))
559+ Attribute& attribute = *attr_list[index];
560+ const AttrWriteType write_type = attribute.get_writable ();
561+
562+ if (write_type != Tango::READ_WITH_WRITE && write_type != Tango::READ_WRITE)
561563 {
562- unsigned long j;
563- string &assoc_name = attr_list[index]->get_assoc_name ();
564- transform (assoc_name.begin (),assoc_name.end (),assoc_name.begin (),::tolower);
565- for (j = 0 ;j < writable_attr_list.size ();j++)
566- {
567- if (attr_list[writable_attr_list[j]]->get_name_lower () == assoc_name)
568- break ;
569- }
570- if (j == writable_attr_list.size ())
571- {
572- TangoSys_OMemStream o;
564+ return ;
565+ }
573566
574- o << " Device --> " << dev_name;
575- o << " \n Property writable_attr_name for attribute " << attr_list[index]->get_name ();
576- o << " is set to " << assoc_name;
577- o << " , but this attribute does not exists or is not writable" << ends;
578- Except::throw_exception ((const char *)API_AttrOptProp,
579- o.str (),
580- (const char *)" MultiAttribute::MultiAttribute" );
581- }
567+ std::string& assoc_name = attribute.get_assoc_name ();
582568
583- //
584- // Check that the two associated attributes have the same data type
585- //
569+ long assoc_index = 0 ;
570+ try
571+ {
572+ assoc_index = get_attr_ind_by_name (assoc_name.c_str ());
573+ }
574+ catch (const DevFailed&)
575+ {
576+ TangoSys_OMemStream o;
577+ o << " Device --> " << dev_name;
578+ o << " \n Property writable_attr_name for attribute " << attribute.get_name ();
579+ o << " is set to " << assoc_name;
580+ o << " , but this attribute does not exist" << std::ends;
581+ Except::throw_exception (
582+ API_AttrOptProp,
583+ o.str ().c_str (),
584+ " MultiAttribute::check_associated" );
585+ }
586586
587- if (attr_list[writable_attr_list[j]]->get_data_type () != attr_list[index]->get_data_type ())
588- {
589- TangoSys_OMemStream o;
587+ Attribute& assoc_attribute = *attr_list[assoc_index];
588+ const AttrWriteType assoc_write_type = assoc_attribute.get_writable ();
590589
591- o << " Device --> " << dev_name;
592- o << " \n Property writable_attr_name for attribute " << attr_list[index]->get_name ();
593- o << " is set to " << assoc_name;
594- o << " , but these two attributes do not support the same data type" << ends;
595- Except::throw_exception ((const char *)API_AttrOptProp,
596- o.str (),
597- (const char *)" MultiAttribute::MultiAttribute" );
598- }
590+ if (assoc_write_type != Tango::WRITE && assoc_write_type != Tango::READ_WRITE)
591+ {
592+ TangoSys_OMemStream o;
593+ o << " Device --> " << dev_name;
594+ o << " \n Property writable_attr_name for attribute " << attribute.get_name ();
595+ o << " is set to " << assoc_name;
596+ o << " , but this attribute is not writable" << std::ends;
597+ Except::throw_exception (
598+ API_AttrOptProp,
599+ o.str ().c_str (),
600+ " MultiAttribute::check_associated" );
601+ }
599602
600- attr_list[index]->set_assoc_ind (writable_attr_list[j]);
603+ if (attribute.get_data_type () != assoc_attribute.get_data_type ())
604+ {
605+ TangoSys_OMemStream o;
606+ o << " Device --> " << dev_name;
607+ o << " \n Property writable_attr_name for attribute " << attribute.get_name ();
608+ o << " is set to " << assoc_name;
609+ o << " , but these two attributes do not support the same data type" << std::ends;
610+ Except::throw_exception (
611+ API_AttrOptProp,
612+ o.str ().c_str (),
613+ " MultiAttribute::check_associated" );
601614 }
602615
616+ attribute.set_assoc_ind (assoc_index);
603617}
604618
605619// +-----------------------------------------------------------------------------------------------------------------
0 commit comments