Complex Attribute Header File
List of: Discussion Topic
Subjects: Attributes
Contents: Kernel

To create the .hxx file for the complex color attribute example, the following steps need to be completed in addition to those described for creating the simple color attribute .hxx file (refer to Example 3-6):


1. Add a pointer to the owning body in this declaration.


2. Add an initialization for the body pointer with a default NULL value to the constructor.


3. Add prototypes for functions that get and set the body pointer.

Except for the addition of the body pointers, Example 3-8 is identical to Example 3-5. The changes are shown in bold.

C++ Example

// User attribute class definition for a color.

#if !defined(ATTRIB_COL_CLASS)
#define ATTRIB_COL_CLASS
#include "at_abc.hxx"
extern int ATTRIB_COL_TYPE;
#define ATTRIB_COL_LEVEL (ATTRIB_ABC_LEVEL + 1)

class ATTRIB_COL: public ATTRIB_ABC {

int color_data;

BODY* my_body;

public:


ATTRIB_COL(ENTITY* = NULL, int = 0, BODY* = NULL);


int color() const {return color_data;}

void set_color(int);


BODY* the_body() const { return my_body; }

void set_the_body(BODY*);

// Functions called to aid attribute migration during modeling
// operations.


virtual void split_owner(ENTITY*);

// The owner of this attribute is about to be split in two - the
// argument is the new piece. The owner of this attribute is
// about to be merged with the given entity. The logical argument
// is TRUE if the owner is to be deleted in the merge.


virtual void merge_owner(


ENTITY*,


// "other entity"


logical



// deleting_owner

);


ATTRIB_FUNCTIONS (ATTRIB_COL, KERN);
};
#endif

Example 3-8. Complex Color Attribute Header File
PDF/KERN/03ATT.PDF
HTM/DATA/KERN/KERN/03ATT/0021.HTM