Union Classes
 
Unions are interface-like objects. Every union has a discriminator method with the pre-defined name Getdiscr(). This method returns a value identifying the type of data that the union objects holds. For each union member, a pair of Get/Set methods are used to access the different data types. It is illegal to call any Get method except the one that matches the value returned from Getdiscr(). However, any Set method can be called. This switches the discriminator to the new value.
The following is an example of the Creo Object TOOLKIT C++ union:
class pfcParamValue : public xobject
{
xsdeclare (pfcParamValue)
public:
pfcParamValueType Getdiscr ();
xstring GetStringValue ();
void SetStringValue (xrstring value);
xint GetIntValue ();
void SetIntValue (xint value);
xbool GetBoolValue ();
void SetBoolValue (xbool value);
xreal GetDoubleValue ();
void SetDoubleValue (xreal value);
xint GetNoteId ();
void SetNoteId (xint value);

private:
pfcParamvalueValue mProParamvalue;

public:
pfcParamValue (const pfcParamvalueValue &inProParamvalue);
pfcParamValue ();

public:
const pfcParamvalueValue &GetProParamvalue();
};
Was this helpful?