本文整理汇总了C++中Aggregate::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Aggregate::Begin方法的具体用法?C++ Aggregate::Begin怎么用?C++ Aggregate::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aggregate
的用法示例。
在下文中一共展示了Aggregate::Begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_it
// Recursively print the hierarchy starting from the root.
// If there is only one aggregate object, the hierarchy will
// only be one level deep (i.e. the children of the one
// aggregate). However, if there are other aggregates nested
// within the top one, the printer will print each nested
// aggregate with further indentation.
void printer::print_it( std::ostream &out, Object *root )
{
if( root == NULL ) return;
if( root->PluginType() == aggregate_plugin )
{
Aggregate *agg = (Aggregate *)root;
out << indent() << "begin " << root->MyName() << endl;
indent_n += 4;
agg->Begin();
for( int n = 0; ; n++ )
{
Object *obj = agg->GetChild();
if( obj == NULL ) break;
if( limit > 0 && n == limit )
{
// Indicate that the list has been truncated.
out << indent() << "..." << endl;
break;
}
else print_it( out, obj );
}
indent_n -= 4;
out << indent() << "end" << endl;
}
else if( root->PluginType() == primitive_plugin )
{
out << indent() << root->MyName() << endl;
}
}
示例2: CountObjects
// Count the number of objects (either just primitives, or both primitives
// and aggregates) contained in a scene graph.
int CountObjects( const Object *root, bool just_primitives )
{
if( root == NULL ) return 0;
if( root->PluginType() != aggregate_plugin ) return 1;
Aggregate *agg = (Aggregate *)root;
agg->Begin();
int count = ( just_primitives ? 0 : 1 );
for(;;)
{
Object *obj = agg->GetChild();
if( obj == NULL ) break;
count += CountObjects( obj, just_primitives );
}
return count;
}