Home > User Guide > Creating and Modifying Models
Generic Attributes
The Generic Attributes Component (GA), provides a means for applications to exchange data. The GA classes allow names, numbers, strings, vectors, positions, etc. to be attached to an entity or a list of entities as an attribute. GA created attributes can be saved and restored.
Generic attributes allow applications to exchange data that is not supported by ACIS without having to share code to define new ENTITY and/or ATTRIB classes. Each generic attribute associates a name with a simple data value. Attributes are defined which have integer, real, string, position, vector, and entity values. There is also an attribute with only a name and no associated value. Hierarchies of values can be created by attaching attributes to other attributes to represent more complex data structures.
Generic Attribute Classes
This section describes the GA classes that implement generic attributes. The class name is given (along with the name of the class from which it is derived), followed by a brief description. For more information, refer to the class reference templates.
ATTRIB_GENERIC : ATTRIB
This is the master attribute for GA.
ATTRIB_GEN_ENTITY : ATTRIB_GEN_NAME
ATTRIB_GEN_ENTITY associates a named entity ownership with an entity. When trans_owner is called for the attribute, the associated entity is transformed if the trans_action enumeration field is set to TransApply. The associated entity is copied when the attribute is copied. The associated entity is lost when the attribute's owner is lost.
ATTRIB_GEN_ENTITY adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_ENTITY( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
ENTITY *, // entity to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(ENTITY *) // change value of attribute
ENTITY *value() const // return value from attributeATTRIB_GEN_INTEGER : ATTRIB_GEN_NAME
ATTRIB_GEN_INTEGER associates a named integer value with an entity. Its value is not affected by transformation.
ATTRIB_GEN_INTEGER adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_INTEGER( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
int, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(int) // change value of attribute
int value() const // return value from attributeATTRIB_GEN_NAME : ATTRIB_GENERIC
ATTRIB_GEN_NAME associates a name with an entity. This attribute has no data value associated with it.
ATTRIB_GEN_NAME is the base class for the remaining generic attributes. As such, it defines most of the behavior for these classes.
Each generic attribute has a name associated with it. This can be any string agreed upon by two or more applications to indicate the meaning of the associated data, if any.
The behavior of a generic attribute when its owner is modified is determined by the specification of three enumeration fields when the attribute is created. Cooperating applications must agree upon the appropriate values for these fields for a given name and set them accordingly when creating an attribute.
The effect of calling split_owner for a generic attribute is determined by an enumeration field of type split_action:
- SplitLose
- The attribute is lost.
- SplitKeep
- The attribute is retained on the original owner.
- SplitCopy
- A copy of the attribute is attached to the new entity. split_owner is then called for any sub-attributes.
- SplitCustom
- The function registered by a call to set_split_method for the attribute's name is called. If no function is registered, the attribute is retained on the original owner.
An enumeration field of type merge_action determines the action to be performed when merge_owner is called for a generic attribute.
- MergeLose
- The attribute is lost from both entities.
- MergeKeepKept
- The attribute on the entity being kept is retained. The attribute on the entity being lost is lost.
- MergeKeepLost
- The attribute on the entity being kept is lost. The attribute on the entity being lost is transferred to the entity being kept.
- MergeKeepOne
- The attribute on the entity being lost is transferred to the entity being kept if there is none there already.
- MergeKeepAll
- The attribute on the entity being kept is retained and any attribute an the entity being lost is transferred to the entity being kept.
- MergeCustom
- The function registered by a call to set_merge_method for the attribute's name is called. If no function is registered, the attribute is retained on the original owner.
A trans_action enumeration field is used to determine the behavior of a generic attribute when its trans_owner method is called.
- TransLose
- The attribute is lost.
- TransIgnore
- The attribute is retained with no change in its value.
- TransApply
- The transform is applied to the attribute's value. Exactly how the value is affected, if at all, is determined by its type. trans_apply is called for any sub-attributes before applying the transform to the attribute's value. For ATTRIB_GEN_NAME, the attribute is unchanged.
- TransCustom
- The function registered by a call to set_trans_method for the attribute's name is called. If no function is registered, the attribute is retained on the original owner.
A copy_action enumeration field is used to determine the behavior of the generic attribute when the copy_owner method is called and when the generic attribute is involved in a copy through the copy scan mechanism. Since the copy scan mechanism allows control only over whether or not the original attribute is copied to the new entity, the behavior on different types of copies will be different depending on the method called in CopyLose and CopyCustom cases. The warning GA_COPY_SCAN_UNSUPPORTED is thrown to alert the application in these cases.
Note: In versions of ACIS prior to R11, the default behavior in copy scans was always CopyCopy regardless of the selected copy action.
- CopyLose
- Lose the original attribute, with no new copy when copy_owner method is called. Performs CopyKeep operation when copy scan mechanism is called.
- CopyKeep
- Keep the attribute on the old entity, no new attribute on copied entity.
- CopyCopy
- Copy the attribute to the new entity, keep the original attribute on the old entity.
- CopyCustom
- Call application supplied routine for name when copy_owner method is called. Performs CopyKeep operation when copy scan mechanism is called.
In addition to the standard ACIS ATTRIB methods, ATTRIB_GEN_NAME defines the following methods:
ATTRIB_GEN_NAME( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
char const *name() const // return name from attributeATTRIB_GEN_REAL : ATTRIB_GEN_NAME
ATTRIB_GEN_REAL associates a named real value with an entity. Its value is not affected by transformation.
ATTRIB_GEN_REAL adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_REAL( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
double, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(double) // change value of attribute
double value() const // return value from attributeATTRIB_GEN_POINTER : ATTRIB_GEN_NAME
ATTRIB_GEN_POINTER associates a named entity reference with an entity. Neither the attribute nor the referenced entity is affected by transformation. The referenced entity is not affected by copying or losing the attribute.
ATTRIB_GEN_POINTER adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_POINTER( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
ENTITY *, // entity to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(ENTITY *) // change value of attribute
ENTITY *value() const // return value from attributeATTRIB_GEN_POSITION : ATTRIB_GEN_NAME
ATTRIB_GEN_POSITION associates a named position with an entity. When trans_owner is called, the position is transformed by the supplied transformation if the trans_action enumeration field is set to TransApply.
ATTRIB_GEN_POSITION adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_POSITION( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
SPAposition const &, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(SPAposition const &) // change value of attribute
SPAposition value() const // return value from attributeATTRIB_GEN_STRING : ATTRIB_GEN_NAME
ATTRIB_GEN_STRING associates a named string value with an entity. Its value is not affected by transformation.
ATTRIB_GEN_STRING adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_STRING( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
char const *, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(char const *) // change value of attribute
char const *value() const // return value from attributeATTRIB_GEN_VECTOR : ATTRIB_GEN_NAME
ATTRIB_GEN_VECTOR associates a named vector with an entity. When trans_owner is called, the vector is transformed by the supplied transformation if the trans_action enumeration field is set to TransApply. The value is not affected by transformation.
ATTRIB_GEN_VECTOR adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_VECTOR( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
SPAvector const &, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(SPAvector const &) // change value of attribute
SPAvector value() const // return value from attributeATTRIB_GEN_WSTRING : ATTRIB_GEN_NAME
ATTRIB_GEN_WSTRING associates a named wide-character string value with an entity. Its value is not affected by transformation. The actual memory representation of a wide character in memory is dependent on the operating system and the size of the wchar_t datatype.
ATTRIB_GEN_WSTRING adds the following methods to those defined by ATTRIB_GEN_NAME:
ATTRIB_GEN_WSTRING( // constructor
ENTITY *, // owner for new attribute
char const *, // name to be associated with owner
wchar_t const *, // value to be associated with owner
split_action, // action for split_owner()
merge_action, // action for merge_owner()
trans_action // action for trans_owner()
)
void set_value(wchar_t const *) // change value of attribute
wchar_t const *value() const // return value from attributeGeneric Attribute Utility Functions
The find_named_attrib function returns a pointer to the first generic attribute with the given name in an ENTITY's list of attributes. NULL is returned if no generic attribute with the requested name is found.
ATTRIB_GEN_NAME * // return ATTRIB_GEN_NAME or derived class
find_named_attrib( // find first generic attribute with given name
ENTITY const *, // entity on which to find attribute
char const * // name of attribute to be found
)find_next_named_attrib returns a pointer to the next generic attribute with the same name and owner as the supplied attribute. NULL is returned if no such attribute is found.
ATTRIB_GEN_NAME * // return ATTRIB_GEN_NAME or derived class
find_next_named_attrib( // find next generic attribute with same name
ATTRIB_GEN_NAME const * // generic attribute from which to start search
)split_func defines the signature for custom split_owner methods for generic attributes.
typedef void
(*split_func)(
ATTRIB_GEN_NAME *, // attribute whose owner was split
ENTITY * // new entity created by split
)set_split_method registers a function which implements a custom split_owner method for generic attributes with the specified name.
split_func // return old split method, if any
set_split_method( // set custom split method for generic attribute
char const *, // attribute name to which method applies
split_func // function implementing custom split method
)merge_func defines the signature for custom merge_owner methods for generic attributes.
typedef void
(*merge_func)(
ATTRIB_GEN_NAME *, // attribute whose owner is being merged
ENTITY *, // other entity involved in merge
logical // attribute's owner will be lost?
)set_merge_method registers a function which implements a custom merge_owner method for generic attributes with the specified name.
merge_func // return old merge method, if any
set_merge_method( // set custom merge method for generic attribute
char const *, // attribute name to which method applies
merge_func // function implementing custom merge method
)trans_func defines the signature for custom trans_owner methods for generic attributes.
typedef void
(*trans_func)(
ATTRIB_GEN_NAME *, // attribute whose owner is being transformed
SPAtransf const & // transformation being applied
)set_trans_method registers a function which implements a custom trans_owner method for generic attributes with the specified name.
trans_func // return old transform method, if any
set_trans_method( // set custom trans method for generic attribute
char const *, // attribute name to which method applies
trans_func // function implementing custom transform method
)[Top]
© 1989-2007 Spatial Corp., a Dassault Systèmes company. All rights reserved.