SQLStore.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef _SQL_STORE_H_
00018 #define _SQL_STORE_H_
00019 
00020 #include <vector>
00021 #include <sys/time.h>
00022 #include <oasys/debug/Log.h>
00023 #include <oasys/serialize/SQLSerialize.h>
00024 #include "BundleStore.h"
00025 #include "PersistentStore.h"
00026 
00027 namespace dtn {
00028 
00033 class SQLStore : public PersistentStore, public oasys::Logger  {
00034 public:
00035     
00041     SQLStore(const char* table_name, oasys::SQLImplementation *db);
00042     
00044 
00048     int close();
00049     
00054     int get(oasys::SerializableObject* obj, const int key);
00055  
00059     int put(oasys::SerializableObject* obj, const int key);
00060 
00065     int add(oasys::SerializableObject* obj, const int key);
00066     
00071     int update(oasys::SerializableObject* obj, const int key);
00072     
00077     int del(const int key);
00078 
00083     int num_elements();
00084 
00089     void keys(std::vector<int> * l);
00090 
00094     int exists(const int id);
00095     
00104     int elements(oasys::SerializableObjectVector* elements);
00105 
00109     const char* table_name();
00110 
00115     bool has_table(const char *name);
00116 
00122     int create_table(oasys::SerializableObject* obj);
00123 
00124 
00129     int exec_query(const char* query);
00130 
00136     void set_key_name(const char* name);
00137 
00138 private:
00139 
00143     const char* table_name_;    
00144     
00148     const char*  key_name_; 
00149 
00150     oasys::SQLImplementation*  sql_impl_;
00151 };
00152 
00153 } // namespace dtn
00154 
00155 #endif /* _SQL_STORE_H_ */

Generated on Sat Sep 8 08:43:34 2007 for DTN Reference Implementation by  doxygen 1.5.3