Using simple attribute groups

You can instantiate TSimpleAttributeGroup directly. The code below shows how to create a simple group and how to add and delete its attributes. Assume TOneAttribute and TAnotherSharedAttribute have different names (which is almost always the case).

Adding an attribute that has a new value, but has the same name as an existing attribute, replaces the existing attribute. And, because internal attributes are reference counted, they are not deleted until all of their shared attributes are deleted.

      // Create a simple group
      TSimpleAttributeGroup aGroup;
      
      // Create some attributes
      TOneAttribute oneA("one A");
      TTwoAttribute twoB("two B"); // different name from A
      TOneAttribute oneC("one C"); // same name as A but different value
      
      aGroup.Add(oneA);
      aGroup.Add(twoB); // doesn't replace A since names differ
      aGroup.Add(oneC); // replaces A with C since names are equal
      
      long count = aGroup.Count(); // count is "2", for B and C
      
      // Deletes attributeC from the group, since it has the same name as A.
      aGroup.Delete(oneA);
      count = aGroup.Count(); // count is "1", for B

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker