00001 // strategy.h 00002 /* 00003 * Copyright (C) 2010 10gen Inc. 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU Affero General Public License, version 3, 00007 * as published by the Free Software Foundation. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Affero General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Affero General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 00019 #pragma once 00020 00021 #include "../pch.h" 00022 #include "chunk.h" 00023 #include "request.h" 00024 00025 namespace mongo { 00026 00027 class Strategy { 00028 public: 00029 Strategy() {} 00030 virtual ~Strategy() {} 00031 virtual void queryOp( Request& r ) = 0; 00032 virtual void getMore( Request& r ) = 0; 00033 virtual void writeOp( int op , Request& r ) = 0; 00034 00035 protected: 00036 void doWrite( int op , Request& r , const Shard& shard , bool checkVersion = true ); 00037 void doQuery( Request& r , const Shard& shard ); 00038 00039 void insert( const Shard& shard , const char * ns , const BSONObj& obj ); 00040 00041 }; 00042 00043 extern Strategy * SINGLE; 00044 extern Strategy * SHARDED; 00045 00046 } 00047