28.1 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 that is to be matched with an EXPRESS type has a RoseType definition. An application must refer to this type information using a special intelligent RoseTypePtr pointer object. There is one static instance of a RoseTypePtr for each C++ class and built in type. These static instances make sure that the type information is created and registered with the RoseInterface object. The list of all types in an application can be found using the RoseInterface workspaceClasses() and workspaceTypes() functions.
The RoseTypePtr for a given C++ type can be found using ROSE_TYPE() macro, and the ROSE_DOMAIN() macro can be used to find the EXPRESS definition for a type.
28.2 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.
Example
Both of the following expressions return the EXPRESS data definition for the C++ Point class:
ROSE_DOMAIN(Point); /* equivalent */
ROSE_TYPE(Point)-> domain(); /* equivalent */
28.3 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.
Example
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");
28.4 isPrimitive()
RoseBoolean isPrimitive();
The isPrimitive() function returns true if the RoseType represents 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 .
28.5 name()
char * name();
The name() function returns the name of the C++ type described by the RoseType object.
28.6 nodeType()
RoseNodeType nodeType();
The nodeType() function returns a RoseNodeType enumeration value indicating the general C++ type described by the RoseType object.
28.7 roseTypePtr()
RoseTypePtr& roseTypePtr();
The roseTypePtr() function returns a reference to the RoseTypePtr object that corresponds to the RoseType object.