Define ContextStore C++ internal API (skeleton) 01/116301/6
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 23 Feb 2017 13:54:34 +0000 (22:54 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 3 Mar 2017 11:36:37 +0000 (03:36 -0800)
Change-Id: I3b2f701932d8d27e21013b29bf8e20103b2b9c40
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
22 files changed:
include/ContextStore.h
include/ContextStoreManager.h [new file with mode: 0644]
include/ContextStoreSearchQuery.h [new file with mode: 0644]
src/client-dummy/ContextStore.cpp
src/client-dummy/ContextStoreManager.cpp [new file with mode: 0644]
src/client-dummy/ContextStoreSearchQuery.cpp [new file with mode: 0644]
src/client/AppManagedLocalStore.cpp [new file with mode: 0644]
src/client/AppManagedLocalStore.h [new file with mode: 0644]
src/client/AppManagedSharedStore.cpp [new file with mode: 0644]
src/client/AppManagedSharedStore.h [new file with mode: 0644]
src/client/AppManagedStore.cpp [new file with mode: 0644]
src/client/AppManagedStore.h [new file with mode: 0644]
src/client/ContextStore.cpp
src/client/ContextStoreManager.cpp [new file with mode: 0644]
src/client/ContextStoreSearchQuery.cpp [new file with mode: 0644]
src/client/PlatformManagedStore.cpp [new file with mode: 0644]
src/client/PlatformManagedStore.h [new file with mode: 0644]
src/client/Schema.cpp [new file with mode: 0644]
src/client/Schema.h [new file with mode: 0644]
src/client/SchemaConf.cpp [new file with mode: 0644]
src/client/SchemaConf.h [new file with mode: 0644]
src/shared/ContextStoreTypesPrivate.h

index e68578a..cfe97d1 100644 (file)
 #ifndef __CONTEXT_STORE_H__
 #define __CONTEXT_STORE_H__
 
+#include <vector>
+#include <Tuple.h>
 #include <ContextStoreTypes.h>
+#include <ContextStoreSearchQuery.h>
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+namespace ctx {
 
-/* TEST CODE */
-int context_store_test();
+       class EXPORT_API ContextStore {
+       public:
+               virtual ~ContextStore();
+
+               virtual int insert(const std::vector<std::string>& columns, Tuple& record);
+               virtual int insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records);
+               virtual int retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result);
+               virtual int remove(const std::string& selection);
+
+       protected:
+               ContextStore();
+       };
 
-#ifdef __cplusplus
 }
-#endif
 
-#endif
+#endif /* __CONTEXT_STORE_H__ */
diff --git a/include/ContextStoreManager.h b/include/ContextStoreManager.h
new file mode 100644 (file)
index 0000000..4fbdcdc
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_MANAGER_H__
+#define __CONTEXT_STORE_MANAGER_H__
+
+#include <string>
+#include <ContextStoreTypes.h>
+#include <ContextStore.h>
+
+namespace ctx {
+
+       class EXPORT_API ContextStoreManager {
+       public:
+               ContextStoreManager();
+               ~ContextStoreManager();
+
+               int getStore(const std::string& uri, ContextStore** contextStore);
+               int removeStore(const std::string& uri);
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_MANAGER_H__ */
diff --git a/include/ContextStoreSearchQuery.h b/include/ContextStoreSearchQuery.h
new file mode 100644 (file)
index 0000000..2c0d187
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_SEARCH_QUERY_H__
+#define __CONTEXT_STORE_SEARCH_QUERY_H__
+
+#include <string>
+#include <ContextStoreTypes.h>
+
+namespace ctx {
+
+       class EXPORT_API ContextStoreSearchQuery {
+       public:
+               ContextStoreSearchQuery();
+               ContextStoreSearchQuery(
+                               const std::string& projection,
+                               const std::string& selection,
+                               const std::string& sortOrder,
+                               unsigned int limit);
+
+               ~ContextStoreSearchQuery();
+
+               ContextStoreSearchQuery& setProjection(const std::string& projection);
+               ContextStoreSearchQuery& setSelection(const std::string& selection);
+               ContextStoreSearchQuery& setSortOrder(const std::string& sortOrder);
+               ContextStoreSearchQuery& setLimit(unsigned int limit);
+
+               bool valid();
+
+       private:
+               std::string __projection;
+               std::string __selection;
+               std::string __sortOrder;
+               unsigned int __limit;
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_SEARCH_QUERY_H__ */
index c526a34..47eca13 100644 (file)
 
 using namespace ctx;
 
-/* TODO: Remove this test code */
-EXPORT_API int context_store_test()
+ContextStore::ContextStore()
+{
+}
+
+ContextStore::~ContextStore()
+{
+}
+
+int ContextStore::insert(const std::vector<std::string>& columns, Tuple& record)
+{
+       return E_SUPPORT;
+}
+
+int ContextStore::insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records)
+{
+       return E_SUPPORT;
+}
+
+int ContextStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result)
+{
+       return E_SUPPORT;
+}
+
+int ContextStore::remove(const std::string& selection)
 {
        return E_SUPPORT;
 }
diff --git a/src/client-dummy/ContextStoreManager.cpp b/src/client-dummy/ContextStoreManager.cpp
new file mode 100644 (file)
index 0000000..f19a6dc
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreManager.h>
+
+using namespace ctx;
+
+ContextStoreManager::ContextStoreManager()
+{
+}
+
+ContextStoreManager::~ContextStoreManager()
+{
+}
+
+int ContextStoreManager::getStore(const std::string& uri, ContextStore** store)
+{
+       return E_SUPPORT;
+}
+
+int ContextStoreManager::removeStore(const std::string& uri)
+{
+       return E_SUPPORT;
+}
diff --git a/src/client-dummy/ContextStoreSearchQuery.cpp b/src/client-dummy/ContextStoreSearchQuery.cpp
new file mode 100644 (file)
index 0000000..25f60d4
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreSearchQuery.h>
+
+using namespace ctx;
+
+ContextStoreSearchQuery::ContextStoreSearchQuery() :
+       __limit(0)
+{
+}
+
+ContextStoreSearchQuery::ContextStoreSearchQuery(const std::string& projection,
+               const std::string& selection, const std::string& sortOrder,
+               unsigned int limit) :
+       __limit(0)
+{
+}
+
+ContextStoreSearchQuery::~ContextStoreSearchQuery()
+{
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setProjection(const std::string& projection)
+{
+       __projection = projection;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setSelection(const std::string& selection)
+{
+       __selection = selection;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setSortOrder(const std::string& sortOrder)
+{
+       __sortOrder = sortOrder;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setLimit(unsigned int limit)
+{
+       __limit = limit;
+       return *this;
+}
+
+bool ContextStoreSearchQuery::valid()
+{
+       return false;
+}
diff --git a/src/client/AppManagedLocalStore.cpp b/src/client/AppManagedLocalStore.cpp
new file mode 100644 (file)
index 0000000..9480c4f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AppManagedLocalStore.h"
+
+using namespace ctx;
+
+AppManagedLocalStore::AppManagedLocalStore(ServiceProxy* proxy) :
+       AppManagedStore(proxy)
+{
+}
+
+AppManagedLocalStore::~AppManagedLocalStore()
+{
+}
+
+int AppManagedLocalStore::init(Schema& schema)
+{
+       //TODO
+       return E_SUPPORT;
+}
+
+int AppManagedLocalStore::insert(const std::vector<std::string>& columns, Tuple& record)
+{
+       //TODO
+       return E_SUPPORT;
+}
+
+int AppManagedLocalStore::insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records)
+{
+       //TODO
+       return E_SUPPORT;
+}
+
+int AppManagedLocalStore::remove(const std::string& selection)
+{
+       //TODO
+       return E_SUPPORT;
+}
+
+int AppManagedLocalStore::destroy(const std::string& uri, ServiceProxy* proxy)
+{
+       //TODO
+       return E_NONE;
+}
diff --git a/src/client/AppManagedLocalStore.h b/src/client/AppManagedLocalStore.h
new file mode 100644 (file)
index 0000000..8ae4cc1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_APP_MANAGED_LOCAL_STORE_H__
+#define __CONTEXT_STORE_APP_MANAGED_LOCAL_STORE_H__
+
+#include <ServiceProxy.h>
+#include <ContextStore.h>
+#include <ContextStoreTypesPrivate.h>
+#include "AppManagedStore.h"
+#include "Schema.h"
+
+namespace ctx {
+
+       class AppManagedLocalStore : public AppManagedStore {
+       public:
+               AppManagedLocalStore(ServiceProxy* proxy);
+               ~AppManagedLocalStore();
+
+               int init(Schema& schema);
+
+               int insert(const std::vector<std::string>& columns, Tuple& record);
+               int insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records);
+               int remove(const std::string& selection);
+
+               static int destroy(const std::string& uri, ServiceProxy* proxy);
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_APP_MANAGED_LOCAL_STORE_H__ */
diff --git a/src/client/AppManagedSharedStore.cpp b/src/client/AppManagedSharedStore.cpp
new file mode 100644 (file)
index 0000000..0943d6b
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AppManagedSharedStore.h"
+
+using namespace ctx;
+
+AppManagedSharedStore::AppManagedSharedStore(ServiceProxy* proxy) :
+       AppManagedStore(proxy)
+{
+}
+
+AppManagedSharedStore::~AppManagedSharedStore()
+{
+}
+
+int AppManagedSharedStore::init(Schema& schema)
+{
+       //TODO
+       return E_SUPPORT;
+}
+
+int AppManagedSharedStore::insert(const std::vector<std::string>& columns, Tuple& record)
+{
+       return E_PRIVIL;
+}
+
+int AppManagedSharedStore::insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records)
+{
+       return E_PRIVIL;
+}
+
+int AppManagedSharedStore::remove(const std::string& selection)
+{
+       return E_PRIVIL;
+}
diff --git a/src/client/AppManagedSharedStore.h b/src/client/AppManagedSharedStore.h
new file mode 100644 (file)
index 0000000..26168ba
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_APP_MANAGED_SHARED_STORE_H__
+#define __CONTEXT_STORE_APP_MANAGED_SHARED_STORE_H__
+
+#include <ServiceProxy.h>
+#include <ContextStore.h>
+#include <ContextStoreTypesPrivate.h>
+#include "AppManagedStore.h"
+#include "Schema.h"
+
+namespace ctx {
+
+       class AppManagedSharedStore : public AppManagedStore {
+       public:
+               AppManagedSharedStore(ServiceProxy* proxy);
+               ~AppManagedSharedStore();
+
+               int init(Schema& schema);
+
+               int insert(const std::vector<std::string>& columns, Tuple& record);
+               int insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records);
+               int remove(const std::string& selection);
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_APP_MANAGED_SHARED_STORE_H__ */
diff --git a/src/client/AppManagedStore.cpp b/src/client/AppManagedStore.cpp
new file mode 100644 (file)
index 0000000..3ba01fd
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AppManagedStore.h"
+
+using namespace ctx;
+
+AppManagedStore::AppManagedStore(ServiceProxy* proxy) :
+       __proxy(proxy)
+{
+}
+
+AppManagedStore::~AppManagedStore()
+{
+}
+
+int AppManagedStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result)
+{
+       // TODO
+       return E_SUPPORT;
+}
diff --git a/src/client/AppManagedStore.h b/src/client/AppManagedStore.h
new file mode 100644 (file)
index 0000000..6fd1035
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_APP_MANAGED_STORE_H__
+#define __CONTEXT_STORE_APP_MANAGED_STORE_H__
+
+#include <ServiceProxy.h>
+#include <ContextStore.h>
+#include <ContextStoreTypesPrivate.h>
+#include "Schema.h"
+
+namespace ctx {
+
+       class AppManagedStore : public ContextStore {
+       public:
+               AppManagedStore(ServiceProxy* proxy);
+               virtual ~AppManagedStore();
+
+               int retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result);
+
+       private:
+               ServiceProxy* __proxy;
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_APP_MANAGED_STORE_H__ */
index 051a48d..47eca13 100644 (file)
  */
 
 #include <ContextStoreTypesPrivate.h>
-#include <ServiceProxy.h>
 #include <ContextStore.h>
 
 using namespace ctx;
 
-/* TODO: Remove this test code */
-EXPORT_API int context_store_test()
+ContextStore::ContextStore()
 {
-       // ServiceProxy object can be maintained as a static object.
-       ServiceProxy proxy(CTX_CONTEXT_STORE);
+}
 
-       GVariant* output = NULL;
+ContextStore::~ContextStore()
+{
+}
 
-       int err = proxy.call("test", g_variant_new("(i)", 100), &output);
+int ContextStore::insert(const std::vector<std::string>& columns, Tuple& record)
+{
+       return E_SUPPORT;
+}
 
-       _I(YELLOW("Return: %d (%s)"), err, CTX_ERROR_STR(err));
+int ContextStore::insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records)
+{
+       return E_SUPPORT;
+}
 
-       if (output)
-               g_variant_unref(output);
+int ContextStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result)
+{
+       return E_SUPPORT;
+}
 
-       return err;
+int ContextStore::remove(const std::string& selection)
+{
+       return E_SUPPORT;
 }
diff --git a/src/client/ContextStoreManager.cpp b/src/client/ContextStoreManager.cpp
new file mode 100644 (file)
index 0000000..692c582
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ServiceProxy.h>
+#include <IServiceResultListener.h>
+#include <IServiceSignalListener.h>
+#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreManager.h>
+#include "SchemaConf.h"
+#include "AppManagedLocalStore.h"
+#include "AppManagedSharedStore.h"
+#include "PlatformManagedStore.h"
+
+using namespace ctx;
+
+static SchemaConf __schemaConf;
+
+static ServiceProxy* __getServiceProxy()
+{
+       static ServiceProxy proxy(CTX_CONTEXT_STORE);
+       return &proxy;
+}
+
+template<typename StoreType>
+static ContextStore* __createStore(Schema& schema, int* error)
+{
+       StoreType* store = new(std::nothrow) StoreType(__getServiceProxy());
+
+       if (!store) {
+               *error = E_NO_MEM;
+               _E("Memory allocation failed");
+               return NULL;
+       }
+
+       *error = store->init(schema);
+
+       if (*error != E_NONE) {
+               delete store;
+               return NULL;
+       }
+
+       return store;
+}
+
+ContextStoreManager::ContextStoreManager()
+{
+}
+
+ContextStoreManager::~ContextStoreManager()
+{
+}
+
+int ContextStoreManager::getStore(const std::string& uri, ContextStore** store)
+{
+       IF_FAIL_RETURN(store, E_PARAM);
+       IF_FAIL_RETURN(__schemaConf.init(), E_FAILED);
+
+       Schema& schema = __schemaConf.getSchema(uri);
+
+       int error = E_NONE;
+       ContextStore* _store = NULL;
+
+       _store = __createStore<AppManagedLocalStore>(schema, &error);
+
+       if (error == E_PARAM)
+               _store = __createStore<PlatformManagedStore>(schema, &error);
+
+       if (error == E_PARAM)
+               _store = __createStore<AppManagedSharedStore>(schema, &error);
+
+       IF_FAIL_RETURN(_store, error);
+
+       *store = _store;
+       return E_NONE;
+}
+
+int ContextStoreManager::removeStore(const std::string& uri)
+{
+       int error = AppManagedLocalStore::destroy(uri, __getServiceProxy());
+
+       if (error == E_PARAM)
+               error = PlatformManagedStore::destroy(uri, __getServiceProxy());
+
+       return error;
+}
diff --git a/src/client/ContextStoreSearchQuery.cpp b/src/client/ContextStoreSearchQuery.cpp
new file mode 100644 (file)
index 0000000..995f92d
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreSearchQuery.h>
+
+using namespace ctx;
+
+ContextStoreSearchQuery::ContextStoreSearchQuery() :
+       __limit(0)
+{
+}
+
+ContextStoreSearchQuery::ContextStoreSearchQuery(const std::string& projection,
+               const std::string& selection, const std::string& sortOrder,
+               unsigned int limit) :
+       __limit(0)
+{
+}
+
+ContextStoreSearchQuery::~ContextStoreSearchQuery()
+{
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setProjection(const std::string& projection)
+{
+       __projection = projection;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setSelection(const std::string& selection)
+{
+       __selection = selection;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setSortOrder(const std::string& sortOrder)
+{
+       __sortOrder = sortOrder;
+       return *this;
+}
+
+ContextStoreSearchQuery& ContextStoreSearchQuery::setLimit(unsigned int limit)
+{
+       __limit = limit;
+       return *this;
+}
+
+bool ContextStoreSearchQuery::valid()
+{
+       // TODO
+       return true;
+}
diff --git a/src/client/PlatformManagedStore.cpp b/src/client/PlatformManagedStore.cpp
new file mode 100644 (file)
index 0000000..bf856c8
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "PlatformManagedStore.h"
+
+using namespace ctx;
+
+PlatformManagedStore::PlatformManagedStore(ServiceProxy* proxy) :
+       __proxy(proxy)
+{
+}
+
+PlatformManagedStore::~PlatformManagedStore()
+{
+}
+
+int PlatformManagedStore::init(Schema& schema)
+{
+       // TODO
+       return E_SUPPORT;
+}
+
+int PlatformManagedStore::insert(const std::vector<std::string>& columns, Tuple& record)
+{
+       // TODO
+       return E_SUPPORT;
+}
+
+int PlatformManagedStore::insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records)
+{
+       // TODO
+       return E_SUPPORT;
+}
+
+int PlatformManagedStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result)
+{
+       // TODO
+       return E_SUPPORT;
+}
+
+int PlatformManagedStore::remove(const std::string& selection)
+{
+       // TODO
+       return E_SUPPORT;
+}
+
+int PlatformManagedStore::destroy(const std::string& uri, ServiceProxy* proxy)
+{
+       // TODO
+       return E_NONE;
+}
diff --git a/src/client/PlatformManagedStore.h b/src/client/PlatformManagedStore.h
new file mode 100644 (file)
index 0000000..990f951
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_PLATFORM_MANAGED_STORE_H__
+#define __CONTEXT_STORE_PLATFORM_MANAGED_STORE_H__
+
+#include <ServiceProxy.h>
+#include <ContextStore.h>
+#include <ContextStoreTypesPrivate.h>
+#include "Schema.h"
+
+namespace ctx {
+
+       class PlatformManagedStore : public ContextStore {
+       public:
+               PlatformManagedStore(ServiceProxy* proxy);
+               ~PlatformManagedStore();
+
+               int init(Schema& schema);
+
+               int insert(const std::vector<std::string>& columns, Tuple& record);
+               int insert(const std::vector<std::string>& columns, std::vector<Tuple*>& records);
+               int retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& result);
+               int remove(const std::string& selection);
+
+               static int destroy(const std::string& uri, ServiceProxy* proxy);
+
+       private:
+               ServiceProxy* __proxy;
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_PLATFORM_MANAGED_STORE_H__ */
diff --git a/src/client/Schema.cpp b/src/client/Schema.cpp
new file mode 100644 (file)
index 0000000..cfbe505
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Schema.h"
+
+using namespace ctx;
+
+Schema::Schema()
+{
+}
+
+Schema::~Schema()
+{
+}
diff --git a/src/client/Schema.h b/src/client/Schema.h
new file mode 100644 (file)
index 0000000..1e94e3b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_SCHEMA_H__
+#define __CONTEXT_STORE_SCHEMA_H__
+
+#include <string>
+#include <ContextStoreTypesPrivate.h>
+
+namespace ctx {
+
+       class Schema {
+       public:
+               ~Schema();
+
+       private:
+               Schema();
+
+               friend class SchemaConf;
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_SCHEMA_H__ */
diff --git a/src/client/SchemaConf.cpp b/src/client/SchemaConf.cpp
new file mode 100644 (file)
index 0000000..bccebdf
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SchemaConf.h"
+
+using namespace ctx;
+
+SchemaConf::SchemaConf()
+{
+}
+
+SchemaConf::~SchemaConf()
+{
+}
+
+bool SchemaConf::init()
+{
+       return true;
+}
+
+Schema& SchemaConf::getSchema(const std::string& uri)
+{
+       static Schema dummy;
+       return dummy;
+}
diff --git a/src/client/SchemaConf.h b/src/client/SchemaConf.h
new file mode 100644 (file)
index 0000000..3bb0674
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CONTEXT_STORE_SCHEMA_CONF_H__
+#define __CONTEXT_STORE_SCHEMA_CONF_H__
+
+#include <string>
+#include <ContextStoreTypesPrivate.h>
+#include "Schema.h"
+
+namespace ctx {
+
+       class SchemaConf {
+       public:
+               SchemaConf();
+               ~SchemaConf();
+
+               bool init();
+
+               Schema& getSchema(const std::string& uri);
+       };
+
+}
+
+#endif /* __CONTEXT_STORE_SCHEMA_CONF_H__ */
index abcbbe0..5322d5f 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <ContextTypes.h>
 #include <ContextErrorUtil.h>
+#include <ContextStoreTypes.h>
 
 #define CTX_CONTEXT_STORE      "ContextStore"
 #define CTX_CONTEXT_STORE_SPEC \