Public Member Functions
CRefArray Class Reference

## Detailed Description

The CRefArray class holds generic CRef objects and acts as a base class for other specialized CRef array classes (CEdgeRefArray, CFacetRefArray, etc...). Like CRef class, the CRefArray class also provides a runtime type information system to help determining the object type during execution time.

The following example demonstrates several approaches for iterating the items of a CRefArray object. Although all of these methods below are more than adequate, the last one is the most effective.

Example:
  Demonstrates how to use the CRefArray class

              using namespace XSI;

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

              Application app;

              CRefArray array;
              GetSomeObjects( array, app );

              // Find all X3DObjects in the scene and adds them to the ref array
              CStringArray emptyArray;
              Model root = app.GetActiveSceneRoot();

              array += root.FindChildren( L"", L"", emptyArray, true );

              // Add grid's parameters to ref array
              X3DObject grid;
              root.AddGeometry( L"Grid", L"MeshSurface", L"", grid );

              array += grid.GetParameters();

              for ( LONG i=0; i<array.GetCount(); ++i )
              {
                  app.LogMessage(L"");

                  CRef ref(array[i]);
                  app.LogMessage( CString(L">>Reference object class type: ") + ref.GetClassIDName() );

                  if ( ref.IsA( siSIObjectID ) )
                  {
                      SIObject siobj(ref);
                      app.LogMessage( CString(L"\tObject name: ") + siobj.GetName() );
                  }

                  if ( ref.IsA( siX3DObjectID ) )
                  {
                      X3DObject xobj(ref);
                      app.LogMessage( L"\tNumber of children : " +
                                      CValue(xobj.GetChildren().GetCount()).GetAsText() );
                  }

                  if ( ref.IsA( siParameterID ) )
                  {
                      Parameter param(ref);
                      app.LogMessage( L"\tParameter's value : " +
                                      param.GetValue().GetAsText() );
                  }
              }

              // 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() );
              }

See also:
  CEdgeRefArray, CFacetRefArray, CParameterRefArray, CPointRefArray, CPolygonFaceRefArray, CPolygonNodeRefArray, CSampleRefArray, CSegmentRefArray, CTriangleRefArray, CTriangleVertexRefArray, CVertexRefArray, CSIObjectRefArray

`#include <xsi_ref.h>`

Inheritance diagram for CRefArray:
[legend]

List of all members.

## Public Member Functions
| CRefArray (LONG in_lSize=0)
| CRefArray (const CRefArray &in_refArray)
virtual | ~CRefArray ()
CRefArray & | operator= (const CRefArray &in_refArray)
CRefArray & | operator+= (const CRefArray &in_refArray)
const CRef & | operator[] (LONG in_index) const
CRef & | operator[] (LONG in_index)
virtual CRef | GetItem (LONG in_index) const
virtual CRef | GetItem (const CString &in_name) const
virtual void | Add (const CRef &in_item)
virtual LONG | GetCount () const
bool | IsA (siClassID in_classID) const
siClassID | GetClassID () const
CString | GetClassIDName () const
virtual bool | IsValid () const
| operator bool () const
CStatus | Filter (const CString &in_strType, const CStringArray &in_strFam, const CString &in_strObjName, CRefArray &io_array) const
CStatus | Find (const CString &in_strType, CRef &io_obj) const
LONG | Set (const CValueArray &in_valarray)
LONG | Set (const CString &in_strarray, const CString &in_sep=L",")
LONG | Remove (const CRef &in_ref)
void | Clear (void)
CString | GetAsText () const
CStatus | Resize (LONG in_size)

## Constructor & Destructor Documentation

CRefArray | ( | LONG | in_lSize = `0` | ) |

Constructs a CRefArray object and optionally initializes the vector to a known size.

Parameters:

  in_lSize | Size of array, defaults to 0.

CRefArray | ( | const CRefArray & | in_refArray | ) |

Constructs a CRefArray object from another CRefArray object.

Parameters:

  in_refArray | constant CRefArray object.

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

Default destructor.

## Member Function Documentation

CRefArray& operator= | ( | const CRefArray & | in_refArray | ) |

Assigns a CRefArray object to this one.

Parameters:

  in_refArray | A constant CRefArray object.

Returns:
  A new reference object.

CRefArray& operator+= | ( | const CRefArray & | in_refArray | ) |

Appends the content of a CRefArray object to this one.

Parameters:

  in_refArray | A constant CRefArray object.

Returns:
  A new reference object.

const CRef& operator[] | ( | LONG | in_index | ) | const

Accessor to elements at a given index. This function can only be called by constant objects, the returned value is read-only.

Parameters:

  in_index | constant CRef object

Returns:
  A new reference object.

CRef& operator[] | ( | LONG | in_index | ) |

Accessor to elements at a given index.

Parameters:

  in_index | CRef object

Returns:
  A new reference object.

virtual CRef GetItem | ( | LONG | in_index | ) | const `[virtual]`

Returns a CRef object contained in the list given an index number.

Parameters:

  in_index | A number index

Returns:
  A new CRef object.

Reimplemented in CControlPointRefArray, CEdgeRefArray, CFacetRefArray, CNurbsCurveRefArray, CNurbsSampleRefArray, CNurbsSurfaceRefArray, CPointRefArray, CPolygonFaceRefArray, CPolygonNodeRefArray, CSampleRefArray, CSegmentRefArray, CTriangleRefArray, CTriangleVertexRefArray, and CVertexRefArray.

virtual CRef GetItem | ( | const CString & | in_name | ) | const `[virtual]`

Returns a CRef object contained in the list given an object string name.

Parameters:

  in_name | The name of an object to retrieve.

Returns:
  A new CRef object.

Reimplemented in CControlPointRefArray, CEdgeRefArray, CFacetRefArray, CNurbsCurveRefArray, CNurbsSampleRefArray, CNurbsSurfaceRefArray, CParameterRefArray, CPointRefArray, CPolygonFaceRefArray, CPolygonNodeRefArray, CSampleRefArray, CSegmentRefArray, CSIObjectRefArray, CTriangleRefArray, CTriangleVertexRefArray, and CVertexRefArray.

virtual void Add | ( | const CRef & | in_item | ) | `[virtual]`

Adds a CRef object at the end of this array.

Parameters:

  in_item | CRef object.

Reimplemented in CFCurveKeyRefArray, CParameterRefArray, and CSIObjectRefArray.

virtual LONG GetCount | ( |  | ) | const `[virtual]`

Returns the number of items in CRefArray

Returns:
  Size of the array

Reimplemented in CControlPointRefArray, CEdgeRefArray, CFacetRefArray, CNurbsCurveRefArray, CNurbsSampleRefArray, CNurbsSurfaceRefArray, CPointRefArray, CPolygonFaceRefArray, CPolygonNodeRefArray, CSampleRefArray, CSegmentRefArray, CTriangleRefArray, CTriangleVertexRefArray, and CVertexRefArray.

bool IsA | ( | siClassID | in_classID | ) | const

Returns true if a given class type is compatible with the underlying reference object.

Parameters:

  in_classID | Class type.

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

siClassID GetClassID | ( |  | ) | const

Returns the class type of this array

Returns:
  siClassID Class type of this array.

CString GetClassIDName | ( |  | ) | const

Returns the type of the referenced object in text format.

Returns:
  The text string.

virtual bool IsValid | ( |  | ) | const `[virtual]`

Returns true if this array is a valid object or false otherwise.

Returns:
  true if valid, false otherwise.

Reimplemented in CControlPointRefArray, CEdgeRefArray, CFacetRefArray, CNurbsCurveRefArray, CNurbsSampleRefArray, CNurbsSurfaceRefArray, CPointRefArray, CPolygonFaceRefArray, CPolygonNodeRefArray, CSampleRefArray, CSegmentRefArray, CTriangleRefArray, CTriangleVertexRefArray, and CVertexRefArray.

operator bool | ( |  | ) | const

Bool converter operator that returns true if this array is a valid object or false otherwise.

Returns:
  true if object is valid; false if not valid.

Since:
  4.0

CStatus Filter | ( | const CString & | in_strType,
|  | const CStringArray & | in_strFam,
|  | const CString & | in_strObjName,
|  | CRefArray & | io_array
| ) |  | const

Searches this array and return a new array of CRef objects that match a given set of criterias. If no objects are found, the function returns an empty array.

Parameters:

  in_strType | Type of object e.g. siPolyMeshType, siBendOpType, etc..
  in_strFam | Array of families e.g. siGroupFamily, si3DObjectFamily, etc...
  in_strObjName | Object name
  io_array | Array of objects found.

Returns:
  CStatus::OK success
  CStatus::False Didn't find any objects meeting the criterias.
  CStatus::Fail failure

CStatus Find | ( | const CString & | in_strType,
|  | CRef & | io_obj
| ) |  | const

Searches this array and return the first object that matches a given type. If no object is found, the method returns an empty object.

Parameters:

  in_strType | Type of object e.g. siPolyMeshType, siBendOpType, etc..
  io_obj | Object found.

Returns:
  CStatus::OK success
  CStatus::False Didn't find any objects meeting the criterias.
  CStatus::Fail failure

LONG Set | ( | const CValueArray & | in_valarray | ) |

Sets from a CValueArray where each item can be a CString containing the object's path or a CRef object.

Parameters:

  in_valarray | string array of objects either as CString (object's path) or CRef objects.

Returns:
  The number of objects set. Returns -1 on failure.

LONG Set | ( | const CString & | in_strarray,
|  | const CString & | in_sep = `L","`
| ) |  |

Sets from a string array of object paths, where the item separator is a comma. If an empty string is passed then a count of 0 is returned.

Parameters:

  in_strarray | string array of object paths for example, "null,null1,null2"
  in_sep | single character representing item separator.

Returns:
  The number of objects set. Returns -1 on failure.

LONG Remove | ( | const CRef & | in_ref | ) |

Removes a CRef from ref array.

Parameters:

  in_ref | reference to remove

Returns:
  The number of items removed

void Clear | ( | void |  | ) |

Removes all items from ref array.

CString GetAsText | ( |  | ) | const

Return comma delimited list of string paths for all the objects in the array.

Returns:
  The string path list string.

CStatus Resize | ( | LONG | in_size | ) |

Reallocates memory for the array, preserves its contents if new size is larger than existing size.

Parameters:

  in_size | New size of the array.

Returns:
  CStatus::OK success
  CStatus::InvalidArgument in_size < 0

Since:
  5.0

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

- xsi_ref.h