Public Member Functions
CDataArray2D< T >::Accessor Class Reference

Detailed Description

template<class T>
class XSI::CDataArray2D< T >::Accessor

A class for accessing the sub-array data of CDataArray2D objects.

Since:
7.0
See also:
CIndexSet, CDataArray, CDataArray2D

#include <xsi_dataarray2D.h>

List of all members.

Public Member Functions

 Accessor ()
 Accessor (const Accessor &in_accessor)
Accessoroperator= (const Accessor &in_accessor)
ULONG GetCount () const
const T & operator[] (ULONG in_nIndex) const
T & operator[] (ULONG in_nIndex)

Constructor & Destructor Documentation

Accessor ( ) [inline]

Constructor.

Accessor ( const Accessor in_accessor) [inline]

Constructs an Accessor object from another Accessor object.

Parameters:
in_accessorconstant Accessor object.

Member Function Documentation

Accessor& operator= ( const Accessor in_accessor) [inline]

Assignment operator.

Parameters:
in_accessorconstant class object.
Returns:
A reference to this Accessor.
ULONG GetCount ( void  ) const [inline]

Returns the number of elements in the array.

Returns:
Number of elements.
const T& operator[] ( ULONG  in_nIndex) const [inline]

Accessor to elements at a given index. This operator is called when reading the data so the return value is read-only.

Parameters:
in_nIndexIndex in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredicted.
Returns:
A read-only reference to the indexed item.
T& operator[] ( ULONG  in_nIndex) [inline]

Accessor to elements at a given index. This operator can also be used to access and modify the sub-array stored at the in_nIndex position.

Parameters:
in_nIndexIndex in this zero-based array. The index must be smaller than the number of elements in the array, otherwise the results are unpredicted.
Returns:
A reference to the indexed item.
Example:
            // Demonstrates how to access/modify the CDataArray2D<T> sub-arrays from the CDataArray2D<T>::Accessor class.
            using namespace XSI;

            XSIPLUGINCALLBACK CStatus UnionArrayNode_Evaluate( ICENodeContext& in_ctxt )
            {
                // The current output port being evaluated...
                ULONG out_portID = in_ctxt.GetEvaluatedOutputPortID( );

                switch( out_portID )
                {
                    case ID_OUT_result:
                    {
                        // Get the output port array ...
                        CDataArray2DLong outData( in_ctxt );

                        // Get the input data buffers for each port
                        CDataArray2DLong InArray1Data( in_ctxt, ID_IN_InArray1 );
                        CDataArray2DLong InArray2Data( in_ctxt, ID_IN_InArray2 );

                        // We need a CIndexSet to iterate over the data
                        CIndexSet indexSet( in_ctxt );
                        for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next())
                        {
                            CDataArray2DLong::Accessor a1 = InArray1Data[it];
                            CDataArray2DLong::Accessor a2 = InArray2Data[it];

                            // Sort arrays in place
                            ULONG nCount1 = a1.GetCount();
                            ULONG nCount2 = a2.GetCount();
                            std::sort( &a1[0], &a1[0]+nCount1 );
                            std::sort( &a2[0], &a2[0]+nCount2 );

                            // Resize out to max array
                            CDataArray2DLong::Accessor out = outData.Resize( it, nCount1 + nCount2 );

                            // Union of a1 + a2
                            LONG* pLast = std::set_union( &a1[0], &a1[0]+nCount1, &a2[0], &a2[0]+nCount2, &out[0]);

                            // resize out with number of elements in union
                            ULONG nOutCount = (ULONG)(pLast - &out[0]);
                            outData.Resize( it, nOutCount );
                        }
                    }
                    break;
                };

                return CStatus::OK;
            }

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