Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Srinivasan Ramesh
sonata
Commits
511eab1e
Commit
511eab1e
authored
Mar 26, 2020
by
Matthieu Dorier
Browse files
started Unqlite backend
parent
d26b43b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/sonata/Backend.hpp
View file @
511eab1e
...
...
@@ -2,9 +2,13 @@
#define __SONATA_BACKEND_HPP
#include <sonata/RequestResult.hpp>
#include <unordered_map>
#include <functional>
#include <json/json.h>
template
<
typename
BackendType
>
class
__SonataBackendRegistration
;
namespace
sonata
{
class
Backend
{
...
...
@@ -65,6 +69,9 @@ class Backend {
class
BackendFactory
{
template
<
typename
BackendType
>
friend
class
::
__SonataBackendRegistration
;
public:
BackendFactory
()
=
delete
;
...
...
@@ -78,23 +85,23 @@ class BackendFactory {
std
::
function
<
std
::
unique_ptr
<
Backend
>
(
const
Json
::
Value
&
)
>>
factories
;
};
}
// namespace sonata
#define SONATA_REGISTER_BACKEND(__backend_name, __backend_type) \
static __BackendRegistration<__backend_type> __sonata ## __backend_name ## _backend( #__backend_name )
;
static __
Sonata
BackendRegistration<__backend_type> __sonata ## __backend_name ## _backend( #__backend_name )
template
<
typename
BackendType
>
class
__BackendRegistration
{
class
__
Sonata
BackendRegistration
{
public:
template
<
typename
FactoryType
>
__BackendRegistration
(
const
std
::
string
&
backend_name
)
__SonataBackendRegistration
(
const
std
::
string
&
backend_name
)
{
BackendFactory
::
factories
[
backend_name
]
=
[](
const
Json
::
Value
&
config
)
{
return
BackendType
::
New
(
config
);
sonata
::
BackendFactory
::
factories
[
backend_name
]
=
[](
const
Json
::
Value
&
config
)
{
return
std
::
make_unique
<
BackendType
>
(
config
);
};
}
};
}
#endif
include/sonata/RequestResult.hpp
View file @
511eab1e
#ifndef __REQUEST_RESULT_HPP
#define __REQUEST_RESULT_HPP
#include <string>
namespace
sonata
{
template
<
typename
T
>
...
...
src/CMakeLists.txt
View file @
511eab1e
# list of source files
set
(
sonata-client-src Client.cpp Database.cpp Collection.cpp
)
set
(
sonata-server-src Provider.cpp
)
set
(
sonata-server-src Provider.cpp
UnQLiteBackend.cpp
)
set
(
sonata-admin-src Admin.cpp
)
# load package helper for generating cmake CONFIG packages
...
...
src/UnQLiteBackend.cpp
0 → 100644
View file @
511eab1e
#include "sonata/Backend.hpp"
#include <json/json.h>
namespace
sonata
{
class
UnQLiteBackend
:
public
Backend
{
public:
UnQLiteBackend
(
const
Json
::
Value
&
config
);
UnQLiteBackend
(
UnQLiteBackend
&&
)
=
delete
;
UnQLiteBackend
(
const
UnQLiteBackend
&
)
=
delete
;
UnQLiteBackend
&
operator
=
(
UnQLiteBackend
&&
)
=
delete
;
UnQLiteBackend
&
operator
=
(
const
UnQLiteBackend
&
)
=
delete
;
virtual
~
UnQLiteBackend
()
=
default
;
virtual
RequestResult
<
bool
>
createCollection
(
const
std
::
string
&
coll_name
)
override
;
virtual
RequestResult
<
bool
>
dropCollection
(
const
std
::
string
&
coll_name
)
override
;
virtual
RequestResult
<
uint64_t
>
store
(
const
std
::
string
&
coll_name
,
const
std
::
string
&
record
)
override
;
virtual
RequestResult
<
std
::
string
>
fetch
(
const
std
::
string
&
coll_name
,
uint64_t
record_id
)
override
;
virtual
RequestResult
<
std
::
string
>
filter
(
const
std
::
string
&
coll_name
,
const
std
::
string
&
filter_code
)
override
;
virtual
RequestResult
<
bool
>
update
(
const
std
::
string
&
coll_name
,
uint64_t
record_id
,
const
std
::
string
&
new_content
)
override
;
virtual
RequestResult
<
std
::
string
>
all
(
const
std
::
string
&
coll_name
)
override
;
virtual
RequestResult
<
uint64_t
>
lastID
(
const
std
::
string
&
coll_name
)
override
;
virtual
RequestResult
<
size_t
>
size
(
const
std
::
string
&
coll_name
)
override
;
virtual
RequestResult
<
bool
>
erase
(
const
std
::
string
&
coll_name
,
uint64_t
record_id
)
override
;
virtual
RequestResult
<
bool
>
destroy
()
override
;
};
SONATA_REGISTER_BACKEND
(
unqlite
,
UnQLiteBackend
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment