aboutsummaryrefslogtreecommitdiff
path: root/brep/shared-database
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-11 15:34:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-23 13:50:07 +0200
commita7e766e1aa77fff846d8426658befd9a01fe2861 (patch)
tree734e658aca46fa945994db85ea586d79c8933bcd /brep/shared-database
parent63aaad529c9ae9358f22fd9563aeabc679f4defd (diff)
Share DB object between modules
Diffstat (limited to 'brep/shared-database')
-rw-r--r--brep/shared-database24
1 files changed, 24 insertions, 0 deletions
diff --git a/brep/shared-database b/brep/shared-database
new file mode 100644
index 0000000..cad526f
--- /dev/null
+++ b/brep/shared-database
@@ -0,0 +1,24 @@
+// file : brep/shared-database -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BREP_SHARED_DATABASE
+#define BREP_SHARED_DATABASE
+
+#include <string>
+#include <memory> // shared_ptr
+
+#include <odb/forward.hxx> // database
+
+namespace brep
+{
+ // Returns pointer to the shared database instance, creating one on the
+ // first call. On subsequent calls ensures passed host and port equals
+ // to ones of the shared database instance throwing runtime_error otherwise.
+ // Is not thread-safe.
+ //
+ std::shared_ptr<odb::core::database>
+ shared_database (const std::string& host, unsigned int port);
+}
+
+#endif // BREP_SHARED_DATABASE