22 #ifndef SQLITEDATABASE_H_
23 #define SQLITEDATABASE_H_
48 SQL_TABLE_ROUTING = 2,
49 SQL_TABLE_BUNDLE_ROUTING_INFO = 3,
50 SQL_TABLE_NODE_ROUTING_INFO = 4,
51 SQL_TABLE_PROPERTIES = 5,
52 SQL_TABLE_BUNDLE_SET = 6,
53 SQL_TABLE_BUNDLE_SET_NAME = 7,
64 GET_DISTINCT_DESTINATIONS,
67 EXPIRE_BUNDLE_FILENAMES,
69 EXPIRE_NEXT_TIMESTAMP,
77 BUNDLE_UPDATE_CUSTODIAN,
89 BUNDLE_SET_GET_EXPIRED,
93 BUNDLE_SET_EXPIRE_NEXT_TIMESTAMP,
97 BUNDLE_SET_NAME_GET_ID,
98 BUNDLE_SET_NAME_REMOVE,
104 static const int DBSCHEMA_FRESH_VERSION;
105 static const int DBSCHEMA_VERSION;
106 static const std::string QUERY_SCHEMAVERSION;
107 static const std::string SET_SCHEMAVERSION;
109 static const std::string _select_names[3];
111 static const std::string _where_filter[2];
113 static const std::string _tables[SQL_TABLE_END];
116 static const std::string _sql_queries[SQL_QUERIES_END];
119 static const int DB_STRUCTURE_END = 15;
120 static const std::string _db_structure[DB_STRUCTURE_END];
122 static const std::string TAG;
148 virtual const std::string
getWhere()
const throw () = 0;
156 virtual int bind(sqlite3_stmt*,
int offset)
const throw ()
173 Statement(sqlite3 *database,
const std::string&);
178 void reset()
throw ();
184 const std::string _query;
187 typedef std::list<std::pair<int, const ibrcommon::File> >
blocklist;
213 void vacuum() throw (SQLiteQueryException);
220 void update(
UPDATE_VALUES, const dtn::data::BundleID &
id, const dtn::data::EID&) throw (SQLiteQueryException);
227 dtn::data::
Length remove(const dtn::data::BundleID &
id) throw (SQLiteQueryException);
239 void get(const dtn::data::BundleID &
id, dtn::data::MetaBundle &meta) const throw (SQLiteQueryException, NoBundleFoundException);
246 void get(const dtn::data::BundleID &
id, dtn::data::Bundle &bundle,
blocklist &blocks) const throw (SQLiteQueryException, NoBundleFoundException);
252 void store(const dtn::data::Bundle &bundle, const dtn::data::
Length &size) throw (SQLiteQueryException);
253 void store(const dtn::data::BundleID &
id,
int index, const dtn::data::Block &block, const ibrcommon::File &file) throw (SQLiteQueryException);
255 void rollback() throw (SQLiteQueryException);
256 void commit() throw (SQLiteQueryException);
258 bool empty() const throw (SQLiteQueryException);
260 dtn::data::
Size count() const throw (SQLiteQueryException);
262 void clear() throw (SQLiteQueryException);
277 void iterateAll() throw (SQLiteQueryException);
296 void get(
Statement &st, dtn::data::MetaBundle &bundle,
int offset = 0) const throw (SQLiteQueryException);
304 void get(
Statement &st, dtn::data::Bundle &bundle, const
int offset = 0) const throw (SQLiteQueryException);
313 void __get(const
BundleSelector &cb,
Statement &st,
BundleResult &ret,
size_t &items_added, const
int bind_offset, const
size_t offset, const
size_t query_limit) const throw (SQLiteQueryException, NoBundleFoundException, BundleSelectorException);
318 void update_expire_time() throw (SQLiteQueryException);
324 void new_expire_time(const dtn::data::
Timestamp &ttl) throw ();
325 void reset_expire_time() throw ();
326 const dtn::data::
Timestamp& get_expire_time() const throw ();
328 void set_bundleid(
Statement &st, const dtn::data::BundleID &
id,
int offset = 0) const throw (SQLiteQueryException);
333 int getVersion() throw (SQLiteQueryException);
339 void setVersion(
int version) throw (SQLiteQueryException);
346 void doUpgrade(
int oldVersion,
int newVersion) throw (ibrcommon::Exception);
348 ibrcommon::File _file;