22 #ifndef SQLITEDATABASE_H_
23 #define SQLITEDATABASE_H_
46 SQL_TABLE_ROUTING = 2,
47 SQL_TABLE_BUNDLE_ROUTING_INFO = 3,
48 SQL_TABLE_NODE_ROUTING_INFO = 4,
49 SQL_TABLE_PROPERTIES = 5,
59 GET_DISTINCT_DESTINATIONS,
62 EXPIRE_BUNDLE_FILENAMES,
64 EXPIRE_NEXT_TIMESTAMP,
72 BUNDLE_UPDATE_CUSTODIAN,
85 static const int DBSCHEMA_FRESH_VERSION;
86 static const int DBSCHEMA_VERSION;
87 static const std::string QUERY_SCHEMAVERSION;
88 static const std::string SET_SCHEMAVERSION;
90 static const std::string _select_names[2];
92 static const std::string _tables[SQL_TABLE_END];
95 static const std::string _sql_queries[SQL_QUERIES_END];
98 static const std::string _db_structure[11];
100 static const std::string TAG;
126 virtual const std::string
getWhere()
const throw () = 0;
134 virtual int bind(sqlite3_stmt*,
int offset)
const throw ()
151 Statement(sqlite3 *database,
const std::string&);
156 void reset()
throw ();
162 const std::string _query;
165 typedef std::list<std::pair<int, const ibrcommon::File> >
blocklist;
191 void vacuum() throw (SQLiteQueryException);
198 void update(
UPDATE_VALUES, const dtn::data::BundleID &
id, const dtn::data::EID&) throw (SQLiteQueryException);
204 void remove(const dtn::data::BundleID &
id) throw (SQLiteQueryException);
216 void get(const dtn::data::BundleID &
id, dtn::data::MetaBundle &meta) const throw (SQLiteQueryException, NoBundleFoundException);
223 void get(const dtn::data::BundleID &
id, dtn::data::Bundle &bundle,
blocklist &blocks) const throw (SQLiteQueryException, NoBundleFoundException);
229 void store(const dtn::data::Bundle &bundle) throw (SQLiteQueryException);
230 void store(const dtn::data::BundleID &
id,
int index, const dtn::data::Block &block, const ibrcommon::File &file) throw (SQLiteQueryException);
232 void rollback() throw (SQLiteQueryException);
233 void commit() throw (SQLiteQueryException);
235 bool empty() const throw (SQLiteQueryException);
237 dtn::data::
Size count() const throw (SQLiteQueryException);
239 void clear() throw (SQLiteQueryException);
249 void iterateAll() throw (SQLiteQueryException);
268 void get(
Statement &st, dtn::data::MetaBundle &bundle,
int offset = 0) const throw (SQLiteQueryException);
276 void get(
Statement &st, dtn::data::Bundle &bundle, const
int offset = 0) const throw (SQLiteQueryException);
285 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);
290 void update_expire_time() throw (SQLiteQueryException);
296 void new_expire_time(const dtn::data::
Timestamp &ttl) throw ();
297 void reset_expire_time() throw ();
298 const dtn::data::
Timestamp& get_expire_time() const throw ();
300 void set_bundleid(
Statement &st, const dtn::data::BundleID &
id,
int offset = 0) const throw (SQLiteQueryException);
301 void get_bundleid(
Statement &st, dtn::data::BundleID &
id,
int offset = 0) const throw (SQLiteQueryException);
306 int getVersion() throw (SQLiteQueryException);
312 void setVersion(
int version) throw (SQLiteQueryException);
319 void doUpgrade(
int oldVersion,
int newVersion) throw (ibrcommon::Exception);
321 ibrcommon::File _file;