0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

moving DBDirectClient to instance.* b/c it only make sense there and cleans linking

This commit is contained in:
Eliot Horowitz 2009-01-02 16:41:13 -05:00
parent 7dde088721
commit ce95083dc2
5 changed files with 49 additions and 42 deletions

View File

@ -361,32 +361,3 @@ BSONObj DBClientPaired::findOne(const char *a, BSONObj b, BSONObj *c, int d) {
}
auto_ptr<DBClientCursor> DBDirectClient::query(const char *ns, BSONObj query, int nToReturn , int nToSkip ,
BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c( new DBClientCursor( new DirectConnector() , ns ,
query , nToReturn , nToSkip , fieldsToReturn , queryOptions ));
if ( c->init() )
return c;
return auto_ptr< DBClientCursor >( 0 );
}
BSONObj DBDirectClient::findOne(const char *ns, BSONObj query, BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c =
this->query(ns, query, 1, 0, fieldsToReturn, queryOptions);
if ( ! c->more() )
return BSONObj();
return c->next().copy();
}
bool DirectConnector::send( Message &toSend, Message &response, bool assertOk ){
DbResponse dbResponse;
assembleResponse( toSend, dbResponse );
assert( dbResponse.response );
response = *dbResponse.response;
return true;
}

View File

@ -263,16 +263,3 @@ public:
};
class DBDirectClient : public DBClientInterface {
public:
virtual auto_ptr<DBClientCursor> query(const char *ns, BSONObj query, int nToReturn = 0, int nToSkip = 0,
BSONObj *fieldsToReturn = 0, int queryOptions = 0);
virtual BSONObj findOne(const char *ns, BSONObj query, BSONObj *fieldsToReturn = 0, int queryOptions = 0);
};
class DirectConnector : public DBClientCursor::Connector {
virtual bool send( Message &toSend, Message &response, bool assertOk=true );
};

View File

@ -21,6 +21,7 @@
#include "db.h"
#include "repl.h"
#include "replset.h"
#include "instance.h"
extern int port;
extern const char *replInfo;

View File

@ -505,3 +505,34 @@ void dbexit(int rc, const char *why) {
log() << " dbexit: really exiting now" << endl;
exit(rc);
}
auto_ptr<DBClientCursor> DBDirectClient::query(const char *ns, BSONObj query, int nToReturn , int nToSkip ,
BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c( new DBClientCursor( new DirectConnector() , ns ,
query , nToReturn , nToSkip , fieldsToReturn , queryOptions ));
if ( c->init() )
return c;
return auto_ptr< DBClientCursor >( 0 );
}
BSONObj DBDirectClient::findOne(const char *ns, BSONObj query, BSONObj *fieldsToReturn , int queryOptions ){
auto_ptr<DBClientCursor> c =
this->query(ns, query, 1, 0, fieldsToReturn, queryOptions);
if ( ! c->more() )
return BSONObj();
return c->next().copy();
}
bool DirectConnector::send( Message &toSend, Message &response, bool assertOk ){
DbResponse dbResponse;
assembleResponse( toSend, dbResponse );
assert( dbResponse.response );
response = *dbResponse.response;
return true;
}

View File

@ -86,3 +86,20 @@ void receivedInsert(Message& m, stringstream& ss);
void receivedGetMore(DbResponse& dbresponse, /*AbstractMessagingPort& dbMsgPort, */Message& m, stringstream& ss);
void receivedQuery(DbResponse& dbresponse, /*AbstractMessagingPort& dbMsgPort, */Message& m, stringstream& ss, bool logit);
void getDatabaseNames( vector< string > &names );
// --- local client ---
class DBDirectClient : public DBClientInterface {
public:
virtual auto_ptr<DBClientCursor> query(const char *ns, BSONObj query, int nToReturn = 0, int nToSkip = 0,
BSONObj *fieldsToReturn = 0, int queryOptions = 0);
virtual BSONObj findOne(const char *ns, BSONObj query, BSONObj *fieldsToReturn = 0, int queryOptions = 0);
};
class DirectConnector : public DBClientCursor::Connector {
virtual bool send( Message &toSend, Message &response, bool assertOk=true );
};