Overview

The RoseType class captures C++ type information and makes it available to the ROSE library. The library uses these descriptions to match C++ definitions to EXPRESS definitions. Applications also have access to this information, but should not need it in the course of normal STEP programming.

Each C++ type used for EXPRESS data has a RoseType definition. Applications refer to this through a special intelligent RoseTypePtr pointer object. There is one static instance of a for each C++ class and built in type. These static instances make sure that the type information is created and registered with the ROSE library.

The C++ type information for a given class can be found using ROSE_TYPE() macro. This is similar to the ROSE_DOMAIN() macro, which finds the EXPRESS definition for a type.

RoseTypePtr (class)

RoseTypePtr ROSE_TYPE(classname);

The RoseTypePtr() class acts as a smart pointer that wraps a RoseType reference. It is typically created as a static global instance with a constructor that initializes the C++ run time type information used by the ROSE library and registers it with an internal dictionary.

There is usually one instance for each RoseObject-derived class and one for each of the primitive types. The static instance is named using a token-pasting convention that is handled by the ROSE_TYPE macro.

if (obj-> isa(ROSE_TYPE(stp_cartesian_point)))
    printf (Object uses the point C++ class\n);

domain()

RoseDomain * domain();

The domain() function returns the EXPRESS definition that has been matched to the C++ type. This function returns the exact match, although there may be other domains that have been best-fit matched with the same C++ type. This function is used by the ROSE_DOMAIN() macro.

Both of the following expressions return the EXPRESS data definition for the C++ Point class:

ROSE_DOMAIN(Point);             /* equivalent */
ROSE_TYPE(Point)-> domain();    /* equivalent */

isa()

RoseBoolean isa(
	const char * class_name
	);

RoseBoolean isa(
	RoseTypePtr& class_type
	);

The isa() functions return true if the RoseType is the same as, or more specific than the given type.

The following example tests an object to see if it is an instance of a particular C++ type:

RoseObject * obj;
if (obj-> roseType()-> isa (ROSE_TYPE(Point)) {
    printf (Object is an instance of the C++ Point class\n);

/* simpler alternative using RoseObject::isa() */
if (obj-> isa (ROSE_TYPE(Point)) {
    printf (Object is an instance of the C++ Point class\n);

isPrimitive()

RoseBoolean isPrimitive();

The isPrimitive() function returns true if the RoseType describes one of the built in C++ primitive types like int or double. It returns false if the type describes one of the C++ classes like RoseObject or RoseStructure.

name()

char * name();

The name() function returns the name of the C++ type described by the RoseType object.

nodeType()

RoseNodeType nodeType();

The nodeType() function returns an enumeration value that indicates the general C++ type described by the RoseType object.

roseTypePtr()

RoseTypePtr& roseTypePtr();

The roseTypePtr() function returns a reference to the RoseTypePtr object that corresponds to the RoseType object.