From f485e25f82b9d96e0cf7173615eaa85cd93cbe5e Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Tue, 16 Feb 2010 16:23:52 -0500 Subject: [PATCH] clean plugin stuff --- db/index.cpp | 5 ++--- db/index.h | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/db/index.cpp b/db/index.cpp index 6ad3f43cebf..ddd97bb91ac 100644 --- a/db/index.cpp +++ b/db/index.cpp @@ -98,7 +98,6 @@ namespace mongo { } void IndexSpec::_init(){ - _indexType = 0; assert( keyPattern.objsize() ); string pluginName = ""; @@ -130,14 +129,14 @@ namespace mongo { log() << "warning: can't find plugin [" << pluginName << "]" << endl; } else { - assert(0); + _indexType.reset( plugin->generate( this ) ); } } } void IndexSpec::getKeys( const BSONObj &obj, BSONObjSetDefaultOrder &keys ) const { - if ( _indexType ){ + if ( _indexType.get() ){ _indexType->getKeys( obj , keys ); return; } diff --git a/db/index.h b/db/index.h index 9af4702c64e..7708afd644c 100644 --- a/db/index.h +++ b/db/index.h @@ -53,7 +53,7 @@ namespace mongo { IndexPlugin( const string& name ); virtual ~IndexPlugin(){} - virtual IndexType* generate( const IndexSpec& spec ) const = 0; + virtual IndexType* generate( const IndexSpec * spec ) const = 0; static IndexPlugin* get( const string& name ){ if ( ! _plugins ) @@ -104,7 +104,9 @@ namespace mongo { void getKeys( const BSONObj &obj, BSONObjSetDefaultOrder &keys ) const; - private: + BSONElement missingField() const { return _nullElt; } + + protected: void _getKeys( vector fieldNames , vector fixed , const BSONObj &obj, BSONObjSetDefaultOrder &keys ) const; vector _fieldNames; @@ -114,9 +116,11 @@ namespace mongo { BSONObj _nullObj; BSONElement _nullElt; - IndexType * _indexType; + shared_ptr _indexType; void _init(); + + friend class IndexType; }; /* Details about a particular index. There is one of these effectively for each object in