#include <xsi_base.h>
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:
All API classes derive from CBase class. The virtual CBase::IsA function must be implemented by the derived classes.
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.
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() ); }
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 |
CBase | ( | ) |
Default constructor.
virtual ~CBase | ( | ) | [virtual] |
Default destructor.
CString GetClassIDName | ( | ) | const |
Returns the type of the API class in a text string,
virtual siClassID GetClassID | ( | ) | const [pure virtual] |
Returns the type of the API class.
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, CustomPrimitive, CustomPrimitiveContext, 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.
in_ClassID | Class type. |
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, CustomPrimitive, CustomPrimitiveContext, 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 |
Sets this API class object with a reference object.
in_obj | CRef object. |
bool IsValid | ( | ) | const |
Returns true if the object is valid.
void ResetObject | ( | ) |
Resets this API class by deleting its CRef object.
operator CRef & | ( | ) |
bool operator== | ( | const CBase & | in_obj | ) | const |
Equality operator
in_obj | API class object to compare. |
bool operator!= | ( | const CBase & | in_obj | ) | const |
Inequality operator
in_obj | API class object to compare. |
const CRef& GetRef | ( | ) | const |