2#pragma warning(disable : 4251)
9#include <bsoncxx/builder/stream/document.hpp>
10#include <bsoncxx/json.hpp>
11#include <bsoncxx/builder/basic/document.hpp>
12#include <bsoncxx/types/value.hpp>
13#include <bsoncxx/document/value.hpp>
15#include <mongocxx/pool.hpp>
26class __declspec(dllexport) DataBase
32 static DataBase* GetDataBase();
34 bool InitializeConnection(
const std::string &serverURL,
const std::string &siteID);
35 void setProjectName(
const std::string &name) { projectName = name; };
36 std::string getProjectName(
void) {
return projectName; };
37 int getSiteID(
void) {
return serviceSiteID; };
40 void createIndexIfNecessary(
void);
42 std::string StoreDataItem(bsoncxx::builder::basic::document &storage);
43 std::string StorePlainDataItem(bsoncxx::builder::basic::document &storage);
46 bool GetDocumentFromObjectID(
const std::string &storageID, bsoncxx::builder::basic::document &doc);
49 bool GetDocumentFromEntityIDandVersion(
unsigned long long entityID,
unsigned long long version, bsoncxx::builder::basic::document &doc);
50 EntityBase* GetEntityFromEntityIDandVersion(
ot::UID _entityID,
ot::UID _version, ClassFactory* classFactory);
53 bool GetAllDocumentsFromFilter(std::map<std::string, bsoncxx::types::value> &filterPairs, std::vector<std::string> &columnNames, bsoncxx::builder::basic::document &doc);
55 void PrefetchDocumentsFromStorage(std::list<std::pair<unsigned long long, unsigned long long>> &prefetchIdandVersion);
56 void RemovePrefetchedDocument(
unsigned long long entityID);
58 static long long GetIntFromView(bsoncxx::document::view &doc_view,
const char *elementName);
59 static long long GetIntFromArrayViewIterator(bsoncxx::array::view::const_iterator &it)
61 if (it->type() == bsoncxx::type::k_int32)
return it->get_int32();
62 if (it->type() == bsoncxx::type::k_int64)
return it->get_int64();
66 static long long GetIntFromView(bsoncxx::document::view &doc_view,
const char *elementName,
long long defaultValue);
68 std::string getDataBaseServerURL(
void) {
return databaseServerURL; };
70 void setDataBaseServerURL(
const std::string &
url) { databaseServerURL =
url; };
71 void setSiteIDString(
const std::string &
id) { serviceSiteIDString = id; };
72 std::string getSiteIDString(
void) {
return serviceSiteIDString; }
74 std::string getTmpFileName(
void);
76 void queueWriting(
bool enableQueuedWriting);
77 void flushWritingQueue(
void);
78 bool isWritingQueue(
void) {
return queueWritingFlag; };
80 void DeleteDocuments(std::list<std::pair<unsigned long long, unsigned long long>> &deleteDocuments);
82 void setUserCredentials(
const std::string &_userName,
const std::string &_password) { userName = _userName; userPassword = _password; }
83 std::string getUserName(
void) {
return userName; }
84 std::string getUserPassword(
void) {
return userPassword; }
87 static void readBSON(bsoncxx::document::view &nodesObj, std::vector<Geometry::Node> &
nodes);
88 static void readBSON(bsoncxx::document::view &trianglesObj, std::list<Geometry::Triangle> &triangles);
89 static void readBSON(bsoncxx::document::view &edgesObj, std::list<Geometry::Edge> &
edges);
93 std::string projectName;
94 std::string databaseServerURL;
96 std::string serviceSiteIDString;
97 bool queueWritingFlag;
98 std::map<unsigned long long, bsoncxx::builder::basic::document *> prefetchedDocuments;
100 std::string userPassword;