/** This interface is just available for testing. */
 shared_ptr<Cursor> newQueryOptimizerCursor
 ( const char *ns, const BSONObj &query, const BSONObj &order,
  const QueryPlanSelectionPolicy &planPolicy, bool requireOrder,
  const shared_ptr<const ParsedQuery> &parsedQuery ) {
     auto_ptr<MultiPlanScanner> mps( MultiPlanScanner::make( ns, query, order, parsedQuery ) );
     return newQueryOptimizerCursor( mps, planPolicy, requireOrder, false );
 }
 shared_ptr<Cursor> NamespaceDetailsTransient::getCursor( const char *ns, const BSONObj &query, const BSONObj &order ) {
     if ( query.isEmpty() && order.isEmpty() ) {
         // TODO This will not use a covered index currently.
         return theDataFileMgr.findAll( ns );
     }
     if ( isSimpleIdQuery( query ) ) {
         Database *database = cc().database();
         assert( database );
         NamespaceDetails *d = database->namespaceIndex.details(ns);
         if ( d ) {
             int idxNo = d->findIdIndex();
             if ( idxNo >= 0 ) {
                 IndexDetails& i = d->idx( idxNo );
                 BSONObj key = i.getKeyFromQuery( query );
                 return shared_ptr<Cursor>( BtreeCursor::make( d, idxNo, i, key, key, true, 1 ) );
             }
         }
     }
     auto_ptr<MultiPlanScanner> mps( new MultiPlanScanner( ns, query, order ) ); // mayYield == false
     shared_ptr<Cursor> single = mps->singleCursor();
     if ( single ) {
         if ( !query.isEmpty() && !single->matcher() ) {
             shared_ptr<CoveredIndexMatcher> matcher( new CoveredIndexMatcher( query, single->indexKeyPattern() ) );
             single->setMatcher( matcher );
         }
         return single;
     }
     return newQueryOptimizerCursor( mps );
 }
    shared_ptr<Cursor> CursorGenerator::generate() {

        setArgumentsHint();
        shared_ptr<Cursor> cursor = shortcutCursor();
        if ( cursor ) {
            return cursor;
        }
        
        setMultiPlanScanner();
        cursor = singlePlanCursor();
        if ( cursor ) {
            return cursor;
        }
        
        return newQueryOptimizerCursor( _mps, _planPolicy, isOrderRequired(), explain() );
    }
 /** This interface just available for testing. */
 shared_ptr<Cursor> newQueryOptimizerCursor( const char *ns, const BSONObj &query, const BSONObj &order ) {
     auto_ptr<MultiPlanScanner> mps( new MultiPlanScanner( ns, query, order ) ); // mayYield == false
     return newQueryOptimizerCursor( mps );
 }