2.2.4.3 Collection


Name

Collection

Remark

The Collection class provides a template for collections of various internal Origin objects such as "Pages" (the collection of all PageBase objects in a project file), etc. The Collection class has an implicit templatized type _TemplType, which is the type of one element of the collection. For example, for the Project class Pages collection (Collection<PageBase> Pages;) the templatized type is PageBase.

Each collection usually has a parent class which is the class whose data member is the collection. For example, Collection<PageBase> Pages is a member of the Project class because Project contains all the pages. Therefore, each collection can be attached to one internal object or be unattached.

The methods of the Collection class are common for all collections. One of the most useful ways to use a collection is in the foreach loop (see the Example).

Hierarchy

Examples

EX1

// This function demonstrates looping over all the members of a collection
// using a foreach loop
// Default constructor creates an unattached Collection object:

void Collection_ex1()
{
    Collection<PageBase> pbColl;
    
    // Attach to the collection of all the pages in the project:
    pbColl = Project.Pages;
    
    PageBase pb;

    foreach(pb in pbColl)
    {
        // Display the name of the page:
        out_str(pb.GetName());
    }
}

Header to Include

origin.h

Reference

Members

Name Brief Example
Collection The default constructor which constructs an uninitialized collection. Examples
Count Returns the count of all the objects in the collection. Examples
Item It returns the nIndex'th item of the collection. Examples