00001 00003 /* Copyright 2009 10gen 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #pragma once 00019 00020 #include "dbclient.h" 00021 #include "redef_macros.h" 00022 00023 namespace mongo { 00024 00036 class Model { 00037 public: 00038 Model() { } 00039 virtual ~Model() { } 00040 00041 virtual const char * getNS() = 0; 00042 virtual void serialize(BSONObjBuilder& to) = 0; 00043 virtual void unserialize(const BSONObj& from) = 0; 00044 virtual BSONObj toObject(); 00045 virtual void append( const char * name , BSONObjBuilder& b ); 00046 00047 virtual string modelServer() = 0; 00048 00052 virtual bool load(BSONObj& query); 00053 virtual void save( bool safe=false ); 00054 virtual void remove( bool safe=false ); 00055 00056 protected: 00057 BSONObj _id; 00058 }; 00059 00060 } // namespace mongo 00061 00062 #include "undef_macros.h"