See Also: PCLArray, PCLTree, PCLBag, PCLObject, PCLIter
TBool IsEmpty() const;This function is equivelent to testing if GetCount() == 0 on the same object. The following example is used to report an error if no items are passed to a processing function.
if( poBag->IsEmpty() )
IMPError( 11, ERRTYP_PFATAL,
"No objects passed to function PCLDoIt()\n");
int GetCount() const;Verify that a modest number of elements are in the group to be processed.
IMPAssert( poBag->GetCount() < 1000 );
int IsMember( poTestObject );
PCLObject * poTestObject;
The object to test for in the container.
The following adds a new vector to the list if it is not already
present.
if( !poWin->poVectorList->IsMember( poThisLayer ) )
{
poWin->poVectorList->Add( poThisLayer );
}
void Add( poObject );
PCLObject * poObject;
The PCLObject to be added to the container.
The following adds a new vector to the list if it is not already
present.
if( !poWin->poVectorList->IsMember( poThisLayer ) )
{
poWin->poVectorList->Add( poThisLayer );
}
TBool Remove( poObject );
PCLObject * poObject;
The object to search for, and remove if found.
Remove an object, and emit a debug message if it is not found.
if( !poBag->Remove( poThisLayer ) )
Debug( "Unable to remove layer %s in display list\n",
poThisLayer->GetName() );
void AddContainer( poBag );
PCLContainer * poBag;
The container from which object references are to be
copied.
void DestroyContents();The DestroyMatchingEvents() function uses the FetchMatchingEvents() method to get a container of events matching a given criteria. DestroyContents is used to destroy all the events, and then the container itself is destroyed.
PCLContainer * poEvents;
IMPAssert( gpoDispatcher != NULL );
poEvents =
gpoDispatcher->FetchMatchingEvents( ePriority, nCode,
poObject, poRequestor,
pfnCBProc, pCBData );
poEvents->DestroyContents();
delete poEvents;
void Empty();See Also: IsEmpty()
TBool Validate() const;The validate method is inherited from PCLObject. The default PCLContainer implementation does do much with the container itself, but it does also attempt to validate each of the objects in the container.
See Also: PCLObject
PCLIter objects should be restarted with Start() before further access if an object is added to, or deleted from the container class being scanned.
The PCLIter is derived from PCLObject, and so can be stored in containers and so forth.
PCLIter( poContainer );
const PCLContainer * poContainer;
Pointer to the container for which an iterator is
to be created. It can be NULL if the selection of
container is to be deferred till the call to Start().
The Start() method is position the iterator at the first item in a
container. It will return the pointer to the first object. It is
also optionally possible to pass a container to retarget the
iterator on a new container.
PCLObject * Start( poNewContainer );
const PCLContainer *poNewContainer;
Optional new container which defaults to NULL to indicate
that the current container should containue to be used.
The Next() method is used to advance an iterator to the next item in
a container. Calling this method repeatedly will advance the
iterator through each of the elements in the container till all have
been visited, at which point NULL will be returned.
PCLObject * Next();The Current() method is used to fetch the PCLObject currently refered to by the iterator. This will be the same value as the most recent call to Start() or Next() returned. Invoking the Current() method does not affect the PCLIter object.
PCLObject * Current();
{
PCLIter oIter( poStack );
for( oIter.Start(); oIter.Current() != NULL; oIter.Next() )
{
oIter.Current()->Dump( stdout );
}
}
The IsMember(), Add() and Remove() methods are adequately described above; however the Start() and Next() methods require further elaboration.
These are used to implement support for the PCLIter friend class. The Start() and Next() method take a (PCLIter *) as an argument. These methods are permitted to update the public pState data item in the PCLIter to keep track of the location of that iterator. The Start() method should return the "first" object in the container, while the Next() method should return the object after the Current() one in the iterator.
Maintaining the protected nCount data item inheirited from the PCLContainer class is also a reponsibility of each derived container class. The nCount field is expected to contain the current number of items in the container and is used to implement the IsEmpty() and GetCount() methods on the container. This field is automatically initialized to zero on container construction.