Skip to content

Commit efa6881

Browse files
committed
added sqliteloader, refs #12
1 parent 1275829 commit efa6881

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

cmake/CompileOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set(DEFAULT_PROJECT_OPTIONS
2727

2828
find_package(Boost COMPONENTS system filesystem REQUIRED)
2929
find_package(OpenCV REQUIRED)
30-
find_package(Poco COMPONENTS Foundation Util Data Net DataMySQL REQUIRED)
30+
find_package(Poco COMPONENTS Foundation Util Data Net DataSQLite DataMySQL REQUIRED)
3131
find_package(Qt5Core REQUIRED)
3232
find_package(Qt5Xml REQUIRED)
3333

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2016 Annotator Team
2+
#ifndef ANNOTATOR_ANNOTATORLIB_LOADER_SQLITELOADER_H
3+
#define ANNOTATOR_ANNOTATORLIB_LOADER_SQLITELOADER_H
4+
5+
/************************************************************
6+
MySQLLoader class header
7+
************************************************************/
8+
#include <AnnotatorLib/Loader/AbstractLoader.h>
9+
#include <AnnotatorLib/Loader/Pkg_Loader.h>
10+
#include <AnnotatorLib/annotatorlib_api.h>
11+
#include <AnnotatorLib/Loader/MySQLLoader.h>
12+
13+
#include <Poco/Data/Session.h>
14+
15+
namespace AnnotatorLib {
16+
namespace Loader {
17+
18+
/************************************************************/
19+
/**
20+
* @brief The SQLiteLoader class
21+
* Loads saved data from sqlite database
22+
*/
23+
class ANNOTATORLIB_API SQLiteLoader : public MySQLLoader {
24+
public:
25+
StorageType getType() override;
26+
void loadSession(AnnotatorLib::Session *session) override;
27+
};
28+
/************************************************************/
29+
/* External declarations (package visibility) */
30+
/************************************************************/
31+
32+
/* Inline functions */
33+
34+
} // of namespace Loader
35+
} // of namespace AnnotatorLib
36+
37+
/************************************************************
38+
End of SQLiteLoader class header
39+
************************************************************/
40+
41+
#endif
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2016 Annotator Team
2+
#define Annotator_AnnotatorLib_Loader_SQLiteLoader_BODY
3+
4+
/************************************************************
5+
SQLiteLoader class body
6+
************************************************************/
7+
8+
// include associated header file
9+
#include <AnnotatorLib/Loader/SQLiteLoader.h>
10+
#include <AnnotatorLib/Object.h>
11+
#include <AnnotatorLib/Session.h>
12+
13+
#include <Poco/Data/SQLite/Connector.h>
14+
#include <Poco/Data/RecordSet.h>
15+
#include <Poco/Data/SessionPool.h>
16+
#include <Poco/Data/Statement.h>
17+
#include <Poco/Tuple.h>
18+
19+
using std::shared_ptr;
20+
using namespace Poco::Data::Keywords;
21+
22+
namespace AnnotatorLib {
23+
namespace Loader {
24+
25+
StorageType SQLiteLoader::getType() { return AnnotatorLib::StorageType::SQLITE; }
26+
27+
void SQLiteLoader::loadSession(Session *session) {
28+
Poco::Data::SQLite::Connector::registerConnector();
29+
Poco::Data::SessionPool pool("SQLite", this->path);
30+
31+
Poco::Data::Session sess(pool.get());
32+
33+
loadAttributes(sess, session);
34+
loadClasses(sess, session);
35+
loadObjects(sess, session);
36+
loadFrames(sess, session);
37+
loadAnnotations(sess, session);
38+
}
39+
40+
// static attributes (if any)
41+
42+
} // of namespace Loader
43+
} // of namespace AnnotatorLib
44+
45+
/************************************************************
46+
End of SQLiteLoader class body
47+
************************************************************/

0 commit comments

Comments
 (0)