| 94 | |
| 95 | template<typename ObjectT> |
| 96 | std::shared_ptr<ObjectT> getDepthFirstObject( Object* root, const ObjectSelectivityType& type ) |
| 97 | { |
| 98 | if ( !root ) |
| 99 | return {}; |
| 100 | |
| 101 | std::stack<Object*> todo; |
| 102 | todo.push( root ); |
| 103 | while ( !todo.empty() ) |
| 104 | { |
| 105 | root = todo.top(); |
| 106 | todo.pop(); |
| 107 | const auto & children = root->children(); |
| 108 | for ( const auto& child : children ) |
| 109 | if ( auto visObj = asSelectivityType<ObjectT>( child, type ) ) |
| 110 | return visObj; |
| 111 | for ( auto it = children.rbegin(); it != children.rend(); ++it ) |
| 112 | { |
| 113 | if ( auto * child = it->get() ) |
| 114 | todo.push( child ); |
| 115 | } |
| 116 | } |
| 117 | return {}; |
| 118 | } |
| 119 | |
| 120 | } |
no test coverage detected