Public Member Functions
CBase Class Reference

## Detailed Description

CBase is the base class of all API classes and provides access to Softimage objects through generic CRef objects. The class defines a runtime type information sytem (RTTI) and CRef attachment support for API classes.

The RTTI is a mechanism that allows API classes to determine the type of reference objects during program execution. The API classes must be attached to compatible CRef objects in order to operate on Softimage objects (CRef). A CRef object can only map to one Softimage object at a time, and an API class can only have one API class type. However, a CRef object can be compatible with many API classes. This compatibility model follows the hierarchy class, thus an CRef object of type siPolygonMeshID would be compatible with PolygonMesh, Geometry and SIObject API classes.

CRef objects expose the following functions for querying its underlying object class type and to determine its compatibility with a given API class: CRef::GetClassID and CRef::IsA.

CBase provides functions similar to CRef to determine if an API class is compatible with a given Softimage object type or a specific CRef instance:

            virtual bool IsA( siClassID in_ClassID ) const;
            bool IsA( CRef& in_ref ) const;

All API classes derive from CBase class. The virtual CBase::IsA function must be implemented by the derived classes.

Example:
  Demonstrates the use of the RTTI system by walking through a list of objects and getting the geometry of each primitive.

            using namespace XSI;

            // Forward declaration
            void GetSomeObjects( CRefArray& io_array, const Application& in_app );

            Application app;

            CRefArray array;
            GetSomeObjects( array, app );

            Geometry geom;
            Primitive prim;
            for ( LONG i=0; i<array.GetCount(); ++i )
            {
                if ( array[i].IsA(siPrimitiveID) )
                {
                    prim.SetObject(array[i]);
                    geom = prim.GetGeometry();

                    app.LogMessage( geom.GetName() + L" is a valid Geometry object: " + CValue(geom.IsValid()).GetAsText() );
                    app.LogMessage( L"Number of points on " + geom.GetName() + L": " + CValue(geom.GetPoints().GetCount()).GetAsText() );
                }
            }

            //INFO : PolygonMesh is a valid Geometry object: true
            //INFO : Number of points on PolygonMesh: 8
            //INFO : PolygonMesh is a valid Geometry object: true
            //INFO : Number of points on PolygonMesh: 26

            // Fills an array with CRef objects
            void GetSomeObjects( CRefArray& io_array, const Application& in_app )
            {
                X3DObject myCube;
                X3DObject myCone;
                Material myPhong;

                Model root = in_app.GetActiveSceneRoot();

                root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube );
                root.AddGeometry( L"Cone", L"MeshSurface", L"", myCone );
                myCone.AddMaterial( L"Phong", false, L"", myPhong );

                // Add CRef items to the input array
                io_array.Add( myCube.GetActivePrimitive().GetRef() );
                io_array.Add( myCone.GetActivePrimitive().GetRef() );
                io_array.Add( myPhong.GetRef() );
            }

API classes can also accept any kind of object without knowing how to operate on it. In such a case if the reference object passed to CBase::SetObject is incompatible then the API class will be put in an invalid state and all its functions would return an error.

Example:
  Demonstrates how the code continues working even though the reference object is incompatible

              using namespace XSI;
              Application app;

              CRefArray array;
              GetSomeObjects( array, app );       // use function defined in Example 1

              Geometry geom;
              Primitive prim;
              for (LONG i = 0; i < array.GetCount(); ++i )
              {
                  prim.SetObject(array[i]);
                  geom = prim.GetGeometry();

                  SIObject obj(array[i]);
                  app.LogMessage( obj.GetName() + L" is a valid Geometry object: " +
                      CValue(geom.IsValid()).GetAsText() );
                  app.LogMessage( L"Number of points on " + obj.GetName() + L": " +
                      CValue(geom.GetPoints().GetCount()).GetAsText() );
              }

`#include <xsi_base.h>`

Inheritance diagram for CBase:
[legend]

List of all members.

## Public Member Functions
| CBase ()
virtual | ~CBase ()
CString | GetClassIDName () const
virtual siClassID | GetClassID () const =0
virtual bool | IsA (siClassID in_ClassID) const
bool | IsA (const CRef &in_ref) const
CStatus | SetObject (const CRef &in_obj)
bool | IsValid () const
void | ResetObject ()
| operator CRef & ()
bool | operator== (const CBase &in_obj) const
bool | operator!= (const CBase &in_obj) const
const CRef & | GetRef () const

## Constructor & Destructor Documentation

CBase | ( |  | ) |

Default constructor.

virtual ~CBase | ( |  | ) | `[virtual]`

Default destructor.

## Member Function Documentation

CString GetClassIDName | ( |  | ) | const

Returns the type of the API class in a text string,

Returns:
  The class type in a text string..

virtual siClassID GetClassID | ( |  | ) | const `[pure virtual]`

Returns the type of the API class.

Returns:
  The class type.

Implemented in ActionDelta, ActionDeltaItem, ActionSource, AnimationSourceItem, AnimationSource, Annotation, Application, Argument, ArgumentArray, ArgumentHandler, ArrayParameter, Camera, CameraRig, ChainBone, ChainEffector, ChainElement, ChainRoot, Clip, ClipContainer, ClipEffect, ClipEffectItem, ClipRelation, Cluster, ClusterProperty, CClusterPropertyBuilder, Command, CommandArray, ConstructionHistory, Constraint, Context, ControlPoint, CustomOperator, CustomProperty, Delta, Desktop, Dictionary, Directed, Edge, Envelope, EnvelopeWeight, EventInfo, Expression, Facet, Factory, FCurve, FCurveKey, FileReference, Filter, Framebuffer, Geometry, CGeometryAccessor, GraphicDriver, GraphicSequencerContext, GridData, GridWidget, Group, HairPrimitive, HardwareShaderContext, HardwareSurface, ICEAttribute, ICECompoundNode, ICEDataModifierNode, ICEDataProviderNode, ICENode, ICENodeContainer, ICENodeContext, ICENodeDef, ICENodeInputPort, ICENodeOutputPort, ICENodePort, ICETree, Image, ImageClip, ImageClip2, InputPort, Joint, Kinematics, KinematicState, CKnotArray, Layer, Layout, Library, Light, LightRig, MappedItem, Material, MaterialLibrary, MemoCamera, Menu, MenuItem, CMeshBuilder, MetaShaderRendererDef, Mixer, Model, Null, NurbsCurve, NurbsCurveList, NurbsSample, NurbsSurface, NurbsSurfaceMesh, OGLLight, OGLMaterial, OGLTexture, Operator, OperatorContext, OutputPort, Override, Parameter, Particle, ParticleAttribute, ParticleCloud, ParticleCloudPrimitive, ParticleType, Partition, Pass, PassContainer, PickBuffer, Plugin, PluginItem, PluginRegistrar, Point, PointLocatorData, PolygonFace, PolygonMesh, PolygonNode, Port, PortGroup, PPGEventContext, PPGItem, PPGLayout, Preferences, Primitive, ProgressBar, Project, ProjectItem, Property, ProxyParameter, RenderChannel, Renderer, RendererContext, CRenderHairAccessor, Rig, CRigidBodyAccessor, CRigidConstraintAccessor, Sample, Scene, SceneItem, SceneRenderProperty, Schematic, SchematicNode, Segment, Selection, Shader, ShaderArrayParamDef, ShaderArrayParameter, ShaderballOptions, ShaderDef, ShaderParamDef, ShaderParamDefContainer, ShaderParamDefOptions, ShaderParameter, ShaderStructParamDef, ShapeClip, ShapeKey, SimulationEnvironment, SIObject, Source, StaticKinematicState, StaticSource, SubComponent, Texture, TextureLayer, TextureLayerPort, TimeControl, TimerEvent, ToolContext, Track, Transition, Triangle, TriangleVertex, UIObject, UIPersistable, UIToolkit, UpdateContext, UserDataBlob, UserDataMap, UVProperty, ValueMap, Vertex, View, ViewContext, and X3DObject.

virtual bool IsA | ( | siClassID | in_ClassID | ) | const `[virtual]`

Returns true if a given class type is compatible with this API class.

Parameters:

  in_ClassID | Class type.

Returns:
  True if the class is compatible, false otherwise.

Reimplemented in ActionDelta, ActionDeltaItem, ActionSource, AnimationSourceItem, AnimationSource, Annotation, Application, Argument, ArgumentArray, ArgumentHandler, ArrayParameter, Camera, CameraRig, ChainBone, ChainEffector, ChainElement, ChainRoot, Clip, ClipContainer, ClipEffect, ClipEffectItem, ClipRelation, Cluster, ClusterProperty, CClusterPropertyBuilder, Command, CommandArray, ConstructionHistory, Constraint, Context, ControlPoint, CustomOperator, CustomProperty, Delta, Desktop, Dictionary, Directed, Edge, Envelope, EnvelopeWeight, EventInfo, Expression, Facet, Factory, FCurve, FCurveKey, FileReference, Filter, Framebuffer, Geometry, CGeometryAccessor, GraphicDriver, GraphicSequencerContext, GridData, GridWidget, Group, HairPrimitive, HardwareShaderContext, HardwareSurface, ICEAttribute, ICECompoundNode, ICEDataModifierNode, ICEDataProviderNode, ICENode, ICENodeContainer, ICENodeContext, ICENodeDef, ICENodeInputPort, ICENodeOutputPort, ICENodePort, ICETree, Image, ImageClip, ImageClip2, InputPort, Joint, Kinematics, KinematicState, CKnotArray, Layer, Layout, Library, Light, LightRig, MappedItem, Material, MaterialLibrary, MemoCamera, Menu, MenuItem, CMeshBuilder, MetaShaderRendererDef, Mixer, Model, Null, NurbsCurve, NurbsCurveList, NurbsSample, NurbsSurface, NurbsSurfaceMesh, OGLLight, OGLMaterial, OGLTexture, Operator, OperatorContext, OutputPort, Override, Parameter, Particle, ParticleAttribute, ParticleCloud, ParticleCloudPrimitive, ParticleType, Partition, Pass, PassContainer, PickBuffer, Plugin, PluginItem, PluginRegistrar, Point, PointLocatorData, PolygonFace, PolygonMesh, PolygonNode, Port, PortGroup, PPGEventContext, PPGItem, PPGLayout, Preferences, Primitive, ProgressBar, Project, ProjectItem, Property, ProxyParameter, RenderChannel, Renderer, RendererContext, CRenderHairAccessor, Rig, CRigidBodyAccessor, CRigidConstraintAccessor, Sample, Scene, SceneItem, SceneRenderProperty, Schematic, SchematicNode, Segment, Selection, Shader, ShaderArrayParamDef, ShaderArrayParameter, ShaderballOptions, ShaderDef, ShaderParamDef, ShaderParamDefContainer, ShaderParamDefOptions, ShaderParameter, ShaderStructParamDef, ShapeClip, ShapeKey, SimulationEnvironment, SIObject, Source, StaticKinematicState, StaticSource, SubComponent, Texture, TextureLayer, TextureLayerPort, TimeControl, TimerEvent, ToolContext, Track, Transition, Triangle, TriangleVertex, UIObject, UIPersistable, UIToolkit, UpdateContext, UserDataBlob, UserDataMap, UVProperty, ValueMap, Vertex, View, ViewContext, and X3DObject.

bool IsA | ( | const CRef & | in_ref | ) | const

Returns true if a given CRef object is compatible with this API class.

Parameters:

  in_ref | CRef object.

Returns:
  True if the class is compatible, false otherwise.

CStatus SetObject | ( | const CRef & | in_obj | ) |

Sets this API class object with a reference object.

Parameters:

  in_obj | CRef object.

Returns:
  CStatus::OK success
  CStatus::Fail Failure

bool IsValid | ( |  | ) | const

Returns true if the object is valid.

Returns:
  True of the object is valid; false otherwise.

void ResetObject | ( |  | ) |

Resets this API class by deleting its CRef object.

operator CRef & | ( |  | ) |

Converts from CBase to a CRef reference object..

Returns:
  A reference to a CRef object.

bool operator== | ( | const CBase & | in_obj | ) | const

Equality operator

Parameters:

  in_obj | API class object to compare.

Returns:
  true if both API class objects are identical, false otherwise.

Since:
  4.0

bool operator!= | ( | const CBase & | in_obj | ) | const

Inequality operator

Parameters:

  in_obj | API class object to compare.

Returns:
  true if the objects are not identical, false otherwise.

Since:
  4.0

const CRef& GetRef | ( |  | ) | const

Converts from CBase to a constant CRef reference object.

Returns:
  A constant reference to a CRef object.

The documentation for this class was generated from the following file:

- xsi_base.h