INCLUDE_DIRECTORIES(
${CMAKE_INSTALL_PREFIX}/${INCDIR}/private
- ${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/shared
)
SET(PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
INSTALL(
- FILES ${CMAKE_SOURCE_DIR}/include/ContextStoreService.h
- DESTINATION ${INCDIR}/private
-)
-INSTALL(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION ${INCDIR}
- FILES_MATCHING
- PATTERN "*.h"
- PATTERN "ContextStoreService.h" EXCLUDE
)
ADD_SUBDIRECTORY(src/client-dummy)
+++ /dev/null
-/*
- * 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);
-
- const std::string& getProjection() const;
- const std::string& getSelection() const;
- const std::string& getSortOrder() const;
- unsigned int getLimit() const;
-
- bool valid() const;
-
- private:
- std::string __projection;
- std::string __selection;
- std::string __sortOrder;
- unsigned int __limit;
- };
-
-}
-
-#endif /* __CONTEXT_STORE_SEARCH_QUERY_H__ */
--- /dev/null
+/*
+ * 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 __CAPI_CONTEXT_STORE_INTERNAL_H__
+#define __CAPI_CONTEXT_STORE_INTERNAL_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Handles */
+typedef struct _ctx_store_handle_s* ctx_store_h;
+
+typedef struct _ctx_store_record_s* ctx_store_record_h;
+
+typedef struct _ctx_store_cursor_s* ctx_store_cursor_h;
+
+
+/* Store object creation */
+int ctx_store_create(const char* uri, ctx_store_h* store);
+
+int ctx_store_destroy(ctx_store_h store);
+
+
+/* Data CRUD */
+int ctx_store_insert(ctx_store_h store, ctx_store_record_h record);
+
+int ctx_store_lazy_insert(ctx_store_h store, ctx_store_record_h record);
+
+int ctx_store_lazy_insert_flush(ctx_store_h store);
+
+int ctx_store_lazy_insert_reset(ctx_store_h store);
+
+int ctx_store_retrieve(ctx_store_h store,
+ const char* projection, const char* selection,
+ const char* sort_order, unsigned int limit,
+ ctx_store_cursor_h* cursor);
+
+int ctx_store_remove(ctx_store_h store, const char* selection);
+
+
+/* Tuple */
+int ctx_store_record_create(ctx_store_record_h* record);
+
+int ctx_store_record_destroy(ctx_store_record_h record);
+
+int ctx_store_record_set_int64(ctx_store_record_h record, const char* key, int64_t value);
+
+int ctx_store_record_set_double(ctx_store_record_h record, const char* key, double value);
+
+int ctx_store_record_set_string(ctx_store_record_h, const char* key, const char* value);
+
+
+/* Cursor */
+int ctx_store_cursor_destroy(ctx_store_cursor_h cursor);
+
+/* Cursor: Navigation */
+int ctx_store_cursor_get_count(ctx_store_cursor_h cursor, unsigned int* count);
+
+int ctx_store_cursor_get_position(ctx_store_cursor_h cursor, unsigned int* position);
+
+int ctx_store_cursor_set_position(ctx_store_cursor_h cursor, unsigned int position);
+
+int ctx_store_cursor_first(ctx_store_cursor_h cursor);
+
+int ctx_store_cursor_last(ctx_store_cursor_h cursor);
+
+int ctx_store_cursor_next(ctx_store_cursor_h cursor);
+
+int ctx_store_cursor_prev(ctx_store_cursor_h cursor);
+
+/* Cursor: Extraction */
+int ctx_store_cursor_get_int64(ctx_store_cursor_h cursor, const char* key, int64_t* value);
+
+int ctx_store_cursor_get_double(ctx_store_cursor_h cursor, const char* key, double* value);
+
+int ctx_store_cursor_get_string(ctx_store_cursor_h cursor, const char* key, char** value);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
/* This header SHOULD NOT be included by other headers in this directory. */
#include <ServiceBase.h>
-#include <ContextStoreTypes.h>
namespace ctx {
--- /dev/null
+/*
+ * 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_SIDE_GATE_H__
+#define __CONTEXT_STORE_SIDE_GATE_H__
+
+#include <Tuple.h>
+
+namespace ctx {
+
+ class ContextStoreService;
+
+ class EXPORT_API ContextStoreSideGate {
+ public:
+ ~ContextStoreSideGate();
+
+ int insert(const std::string& columns, std::vector<Tuple*>& tuples);
+
+ static ContextStoreSideGate getUserStore(const std::string& uri);
+ static ContextStoreSideGate getSystemStore(const std::string& uri);
+
+ private:
+ ContextStoreSideGate(const std::string& uri, bool isSystem);
+
+ std::string __uri;
+ bool __isSystem;
+
+ static ContextStoreService* __hostService;
+
+ friend class ContextStoreService;
+ };
+
+}
+
+#endif
CREATE TABLE IF NOT EXISTS ContextStoreSchema (
"uri" TEXT PRIMARY KEY,
+ "columns" TEXT NOT NULL,
"retention" INTEGER NOT NULL DEFAULT 0,
"limit" INTEGER NOT NULL DEFAULT 0,
"readPrivileges" TEXT NOT NULL,
SET(DEPS "${DEPS} context-common-client")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
FILE(GLOB_RECURSE SRCS *.cpp)
MESSAGE("Sources: ${SRCS}")
+++ /dev/null
-/*
- * 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;
-}
-
-const std::string& ContextStoreSearchQuery::getProjection() const
-{
- return __projection;
-}
-
-const std::string& ContextStoreSearchQuery::getSelection() const
-{
- return __selection;
-}
-
-const std::string& ContextStoreSearchQuery::getSortOrder() const
-{
- return __sortOrder;
-}
-
-unsigned int ContextStoreSearchQuery::getLimit() const
-{
- return __limit;
-}
-
-bool ContextStoreSearchQuery::valid() const
-{
- return false;
-}
--- /dev/null
+/*
+ * 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 <context_store_internal.h>
+
+typedef struct _ctx_store_handle_s {
+ int dummy;
+} ctx_store_handle_s;
+
+typedef struct _ctx_store_record_s {
+ int dummy;
+} ctx_store_record_s;
+
+typedef struct _ctx_store_cursor_s {
+ int dummy;
+} ctx_store_cursor_s;
+
+EXPORT_API int ctx_store_create(const char* uri, ctx_store_h* store)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_destroy(ctx_store_h store)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_insert(ctx_store_h store, ctx_store_record_h record)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_lazy_insert(ctx_store_h store, ctx_store_record_h record)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_lazy_insert_flush(ctx_store_h store)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_lazy_insert_reset(ctx_store_h store)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_retrieve(ctx_store_h store, const char* projection,
+ const char* selection, const char* sort_order, unsigned int limit,
+ ctx_store_cursor_h* cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_remove(ctx_store_h store, const char* selection)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_record_create(ctx_store_record_h* record)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_record_destroy(ctx_store_record_h record)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_record_set_int64(ctx_store_record_h record, const char* key, int64_t value)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_record_set_double(ctx_store_record_h record, const char* key, double value)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_record_set_string(ctx_store_record_h record, const char* key, const char* value)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_destroy(ctx_store_cursor_h cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_get_count(ctx_store_cursor_h cursor, unsigned int* count)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_get_position(ctx_store_cursor_h cursor, unsigned int* position)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_set_position(ctx_store_cursor_h cursor, unsigned int position)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_first(ctx_store_cursor_h cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_last(ctx_store_cursor_h cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_next(ctx_store_cursor_h cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_prev(ctx_store_cursor_h cursor)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_get_int64(ctx_store_cursor_h cursor, const char* key, int64_t* value)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_get_double(ctx_store_cursor_h cursor, const char* key, double* value)
+{
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_cursor_get_string(ctx_store_cursor_h cursor, const char* key, char** value)
+{
+ return E_SUPPORT;
+}
SET(DEPS "${DEPS} context-common-client")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
FILE(GLOB_RECURSE SRCS *.cpp ../shared/*.cpp)
MESSAGE("Sources: ${SRCS}")
* limitations under the License.
*/
+#include <Database.h>
#include <ContextStoreTypesPrivate.h>
-#include <ContextStore.h>
+#include "ContextStore.h"
using namespace ctx;
+ContextStoreSearchQuery::ContextStoreSearchQuery(const char* proj, const char* sel, const char* srt, unsigned int lim) :
+ projection(proj ? proj : EMPTY_STR),
+ selection(sel ? sel : EMPTY_STR),
+ sortOrder(srt ? srt : EMPTY_STR),
+ limit(lim)
+{
+}
+
ContextStore::ContextStore()
{
}
{
return E_SUPPORT;
}
+
+DataType ContextStore::getColumnType(const std::string& columnName)
+{
+ size_t pos = __columns.find(columnName);
+ IF_FAIL_RETURN(pos != std::string::npos, DataType::UNKNOWN);
+
+ DataType type = DataType::UNKNOWN;
+
+ try {
+ char typeChar = __columns.at(pos + columnName.size() + 1);
+ if (typeChar == *COL_INT64) {
+ type = DataType::INT64;
+ } else if (typeChar == *COL_DOUBLE) {
+ type = DataType::DOUBLE;
+ } else if (typeChar == *COL_STRING) {
+ type = DataType::STRING;
+ }
+ } catch (std::exception& e) {
+ _E("%s", e.what());
+ }
+
+ return type;
+}
#include <vector>
#include <Tuple.h>
-#include <ContextStoreTypes.h>
-#include <ContextStoreSearchQuery.h>
+#include <ContextStoreTypesPrivate.h>
namespace ctx {
- class EXPORT_API ContextStore {
+ enum class DataType {
+ UNKNOWN = 0,
+ INT64 = 1,
+ DOUBLE,
+ STRING
+ };
+
+ struct ContextStoreSearchQuery {
+ std::string projection;
+ std::string selection;
+ std::string sortOrder;
+ unsigned int limit;
+ ContextStoreSearchQuery(const char* proj, const char* sel, const char* srt, unsigned int lim);
+ };
+
+ class ContextStore {
public:
virtual ~ContextStore();
virtual int retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& records);
virtual int remove(const std::string& selection);
+ DataType getColumnType(const std::string& columnName);
+
protected:
ContextStore();
+
+ std::string __columns;
};
}
#include <ServiceProxy.h>
#include <ContextStoreTypesPrivate.h>
-#include <ContextStoreManager.h>
#include "PlatformManagedStore.h"
+#include "ContextStoreManager.h"
using namespace ctx;
*store = _store;
return E_NONE;
}
+
+int ContextStoreManager::reloadUser()
+{
+ return __getServiceProxy()->call(METHOD_RELOAD_USER, NULL);
+}
+
+int ContextStoreManager::reloadSystem()
+{
+ return __getServiceProxy()->call(METHOD_RELOAD_SYSTEM, NULL);
+}
#define __CONTEXT_STORE_MANAGER_H__
#include <string>
-#include <ContextStoreTypes.h>
-#include <ContextStore.h>
+#include <ContextStoreTypesPrivate.h>
namespace ctx {
- class EXPORT_API ContextStoreManager {
+ class ContextStore;
+
+ class ContextStoreManager {
public:
ContextStoreManager();
~ContextStoreManager();
int getStore(const std::string& uri, ContextStore** contextStore);
+
+ int reloadUser();
+
+ int reloadSystem();
};
}
+++ /dev/null
-/*
- * 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(DEFAULT_QUERY_LIMIT)
-{
-}
-
-ContextStoreSearchQuery::ContextStoreSearchQuery(const std::string& projection,
- const std::string& selection, const std::string& sortOrder,
- unsigned int limit) :
- __projection(projection),
- __selection(selection),
- __sortOrder(sortOrder),
- __limit(limit)
-{
-}
-
-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;
-}
-
-const std::string& ContextStoreSearchQuery::getProjection() const
-{
- return __projection;
-}
-
-const std::string& ContextStoreSearchQuery::getSelection() const
-{
- return __selection;
-}
-
-const std::string& ContextStoreSearchQuery::getSortOrder() const
-{
- return __sortOrder;
-}
-
-unsigned int ContextStoreSearchQuery::getLimit() const
-{
- return __limit;
-}
-
-bool ContextStoreSearchQuery::valid() const
-{
- if (__projection.empty())
- return false;
-
- return true;
-}
int PlatformManagedStore::init(const std::string& uri)
{
- int error = __proxy->call(METHOD_GET_ACCESS, g_variant_new("(s)", uri.c_str()));
__uri = uri;
- return error;
+ GVariant* outParam = NULL;
+ int error = __proxy->call(METHOD_GET_ACCESS, g_variant_new("(s)", uri.c_str()), &outParam);
+ IF_FAIL_RETURN(error == E_NONE, error);
+
+ const char* columns = NULL;
+ g_variant_get(outParam, "(&s)", &columns);
+
+ __columns = (columns ? columns : EMPTY_STR);
+
+ g_variant_unref(outParam);
+
+ return E_NONE;
}
int PlatformManagedStore::insert(const std::string& columns, Tuple* record)
int PlatformManagedStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& records)
{
- IF_FAIL_RETURN(query.valid(), E_PARAM);
+ IF_FAIL_RETURN(!query.projection.empty(), E_PARAM);
GVariant* param = g_variant_new("(ssssu)", __uri.c_str(),
- query.getProjection().c_str(), query.getSelection().c_str(),
- query.getSortOrder().c_str(), static_cast<guint32>(query.getLimit()));
+ query.projection.c_str(), query.selection.c_str(),
+ query.sortOrder.c_str(), static_cast<guint32>(query.limit));
GVariant* outParam = NULL;
int error = __proxy->call(METHOD_RETRIEVE, param, &outParam);
g_variant_get(outParam, "(v)", &vals);
records = Tuple::buildFrom(vals);
+
+ g_variant_unref(outParam);
+
return E_NONE;
}
* limitations under the License.
*/
-#ifndef __CONTEXT_STORE_PLATFORM_MANAGED_STORE_H__
-#define __CONTEXT_STORE_PLATFORM_MANAGED_STORE_H__
+#ifndef __CONTEXT_PLATFORM_MANAGED_STORE_H__
+#define __CONTEXT_PLATFORM_MANAGED_STORE_H__
#include <ServiceProxy.h>
#include <IServiceResultListener.h>
#include <IServiceSignalListener.h>
-#include <ContextStore.h>
#include <ContextStoreTypesPrivate.h>
+#include "ContextStore.h"
namespace ctx {
--- /dev/null
+/*
+ * 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 <utility>
+#include <string>
+#include <map>
+#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreUtil.h>
+#include <context_store_internal.h>
+#include "ContextStore.h"
+#include "ContextStoreManager.h"
+
+#define COMMA ","
+
+using namespace ctx;
+
+typedef struct _ctx_store_handle_s {
+ std::string uri;
+ ContextStore* proxy;
+} ctx_store_handle_s;
+
+union DataValue {
+ int64_t i64;
+ double dbl;
+ char* str;
+};
+
+typedef struct _ctx_store_record_s {
+ std::map<std::string, std::pair<DataType, DataValue>> attributes;
+} ctx_store_record_s;
+
+typedef struct _ctx_store_cursor_s {
+ size_t index;
+ std::vector<std::string> keys;
+ std::vector<Tuple*> tuples;
+} ctx_store_cursor_s;
+
+static ContextStoreManager __storeManager;
+
+EXPORT_API int ctx_store_create(const char* uri, ctx_store_h* store)
+{
+ IF_FAIL_RETURN(uri && store, E_PARAM);
+
+ ContextStore* proxy;
+ int error = __storeManager.getStore(uri, &proxy);
+ IF_FAIL_RETURN(error == E_NONE, error);
+
+ ctx_store_h handle = new(std::nothrow) ctx_store_handle_s;
+ if (!handle) {
+ delete proxy;
+ return E_NO_MEM;
+ }
+
+ handle->uri = uri;
+ handle->proxy = proxy;
+ *store = handle;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_destroy(ctx_store_h store)
+{
+ IF_FAIL_RETURN(store, E_NONE);
+
+ delete store->proxy;
+ delete store;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_insert(ctx_store_h store, ctx_store_record_h record)
+{
+ IF_FAIL_RETURN(store && record, E_PARAM);
+
+ std::string columns;
+ Tuple::Builder builder;
+
+ for (auto& iter : record->attributes) {
+ if (store->proxy->getColumnType(iter.first) != iter.second.first) {
+ return E_PARAM;
+ }
+ columns.append(iter.first).append(COMMA);
+ if (iter.second.first == DataType::INT64) {
+ builder.add(iter.second.second.i64);
+ } else if (iter.second.first == DataType::DOUBLE) {
+ builder.add(iter.second.second.dbl);
+ } else {
+ builder.add(iter.second.second.str);
+ }
+ }
+
+ IF_FAIL_RETURN(!columns.empty(), E_PARAM);
+ columns.pop_back();
+
+ Tuple* tuple = builder.build();
+ IF_FAIL_RETURN(tuple, E_FAILED);
+
+ return store->proxy->insert(columns, tuple);
+}
+
+EXPORT_API int ctx_store_lazy_insert(ctx_store_h store, ctx_store_record_h record)
+{
+ // TODO
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_lazy_insert_flush(ctx_store_h store)
+{
+ // TODO
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_lazy_insert_reset(ctx_store_h store)
+{
+ // TODO
+ return E_SUPPORT;
+}
+
+EXPORT_API int ctx_store_retrieve(ctx_store_h store, const char* projection,
+ const char* selection, const char* sort_order, unsigned int limit,
+ ctx_store_cursor_h* cursor)
+{
+ IF_FAIL_RETURN(store && projection && cursor, E_PARAM);
+
+ ctx_store_cursor_s* csr = new(std::nothrow) ctx_store_cursor_s;
+ IF_FAIL_RETURN(csr, E_NO_MEM);
+
+ std::vector<Tuple*> tuples;
+ ContextStoreSearchQuery query(projection, selection, sort_order, limit);
+
+ int error = store->proxy->retrieve(query, tuples);
+ if (error != E_NONE) {
+ delete csr;
+ return error;
+ }
+
+ csr->index = 0;
+ csr->keys = util::tokenizeString(query.projection, ", ");
+ csr->tuples = tuples;
+
+ *cursor = csr;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_remove(ctx_store_h store, const char* selection)
+{
+ IF_FAIL_RETURN(store && selection, E_PARAM);
+
+ return store->proxy->remove(selection);
+}
+
+EXPORT_API int ctx_store_record_create(ctx_store_record_h* record)
+{
+ IF_FAIL_RETURN(record, E_PARAM);
+
+ ctx_store_record_h handle = new(std::nothrow) ctx_store_record_s;
+ IF_FAIL_RETURN(handle, E_NO_MEM);
+
+ *record = handle;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_record_destroy(ctx_store_record_h record)
+{
+ IF_FAIL_RETURN(record, E_NONE);
+
+ for (auto& iter : record->attributes) {
+ if (iter.second.first == DataType::STRING)
+ g_free(iter.second.second.str);
+ }
+
+ delete record;
+
+ return E_NONE;
+}
+
+static void __removeFromRecord(ctx_store_record_h record, const char* key)
+{
+ auto iter = record->attributes.find(key);
+ if (iter == record->attributes.end())
+ return;
+
+ if (iter->second.first == DataType::STRING)
+ g_free(iter->second.second.str);
+
+ record->attributes.erase(iter);
+}
+
+EXPORT_API int ctx_store_record_set_int64(ctx_store_record_h record, const char* key, int64_t value)
+{
+ IF_FAIL_RETURN(record && key, E_PARAM);
+
+ __removeFromRecord(record, key);
+
+ DataValue v;
+ v.i64 = value;
+ record->attributes[key] = std::make_pair(DataType::INT64, v);
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_record_set_double(ctx_store_record_h record, const char* key, double value)
+{
+ IF_FAIL_RETURN(record && key, E_PARAM);
+
+ __removeFromRecord(record, key);
+
+ DataValue v;
+ v.dbl = value;
+ record->attributes[key] = std::make_pair(DataType::DOUBLE, v);
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_record_set_string(ctx_store_record_h record, const char* key, const char* value)
+{
+ IF_FAIL_RETURN(record && key && value, E_PARAM);
+
+ __removeFromRecord(record, key);
+
+ DataValue v;
+ v.str = g_strdup(value);
+ IF_FAIL_RETURN(v.str, E_NO_MEM);
+
+ record->attributes[key] = std::make_pair(DataType::STRING, v);
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_destroy(ctx_store_cursor_h cursor)
+{
+ IF_FAIL_RETURN(cursor, E_NONE);
+
+ for (auto& tuple : cursor->tuples) {
+ delete tuple;
+ }
+
+ delete cursor;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_get_count(ctx_store_cursor_h cursor, unsigned int* count)
+{
+ IF_FAIL_RETURN(cursor && count, E_PARAM);
+
+ *count = cursor->tuples.size();
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_get_position(ctx_store_cursor_h cursor, unsigned int* position)
+{
+ IF_FAIL_RETURN(cursor && position, E_PARAM);
+
+ *position = cursor->index;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_set_position(ctx_store_cursor_h cursor, unsigned int position)
+{
+ IF_FAIL_RETURN(cursor && position < cursor->tuples.size(), E_PARAM);
+
+ cursor->index = position;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_first(ctx_store_cursor_h cursor)
+{
+ IF_FAIL_RETURN(cursor, E_PARAM);
+
+ cursor->index = 0;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_last(ctx_store_cursor_h cursor)
+{
+ IF_FAIL_RETURN(cursor, E_PARAM);
+
+ cursor->index = cursor->tuples.size() - 1;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_next(ctx_store_cursor_h cursor)
+{
+ IF_FAIL_RETURN(cursor, E_PARAM);
+ IF_FAIL_RETURN(cursor->index + 1 < cursor->tuples.size(), E_NO_DATA);
+
+ cursor->index += 1;
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_prev(ctx_store_cursor_h cursor)
+{
+ IF_FAIL_RETURN(cursor, E_PARAM);
+ IF_FAIL_RETURN(cursor->index != 0, E_NO_DATA);
+
+ cursor->index -= 1;
+
+ return E_NONE;
+}
+
+static unsigned int __getIndexOf(ctx_store_cursor_h cursor, const std::string& key)
+{
+ unsigned int i;
+ for (i = 0; i < cursor->keys.size(); ++i) {
+ if (cursor->keys[i] == key)
+ return i;
+ }
+ return i;
+}
+
+EXPORT_API int ctx_store_cursor_get_int64(ctx_store_cursor_h cursor, const char* key, int64_t* value)
+{
+ IF_FAIL_RETURN(cursor && key && value, E_PARAM);
+
+ unsigned int idx = __getIndexOf(cursor, key);
+ const char* valueStr = NULL;
+
+ if (!cursor->tuples[cursor->index]->getAt(idx, &valueStr))
+ return E_PARAM;
+
+ //TODO: Type checking & locale-invariant?
+ *value = std::atoll(valueStr);
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_get_double(ctx_store_cursor_h cursor, const char* key, double* value)
+{
+ //TODO: check whether a number with many digits can be handled.
+ IF_FAIL_RETURN(cursor && key && value, E_PARAM);
+
+ unsigned int idx = __getIndexOf(cursor, key);
+ const char* valueStr = NULL;
+
+ if (!cursor->tuples[cursor->index]->getAt(idx, &valueStr))
+ return E_PARAM;
+
+ //TODO: Type checking & locale-invariant?
+ *value = std::atof(valueStr);
+
+ return E_NONE;
+}
+
+EXPORT_API int ctx_store_cursor_get_string(ctx_store_cursor_h cursor, const char* key, char** value)
+{
+ IF_FAIL_RETURN(cursor && key && value, E_PARAM);
+
+ unsigned int idx = __getIndexOf(cursor, key);
+ const char* valueStr = NULL;
+
+ if (!cursor->tuples[cursor->index]->getAt(idx, &valueStr))
+ return E_PARAM;
+
+ char* buf = g_strdup(valueStr);
+ IF_FAIL_RETURN(buf, E_NO_MEM);
+
+ *value = buf;
+
+ return E_NONE;
+}
SET(DEPS "${DEPS} context-common-server")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/private)
+
FILE(GLOB_RECURSE SRCS *.cpp)
MESSAGE("Sources: ${SRCS}")
* limitations under the License.
*/
-#include <ContextStoreTypesPrivate.h>
-#include <ContextStore.h>
+#include <ContextStoreService.h>
+#include <ContextStoreSideGate.h>
using namespace ctx;
-ContextStore::ContextStore()
-{
-}
+ContextStoreService* ContextStoreSideGate::__hostService = NULL;
-ContextStore::~ContextStore()
+ContextStoreSideGate::ContextStoreSideGate(const std::string& uri, bool isSystem) :
+ __uri(uri),
+ __isSystem(isSystem)
{
}
-int ContextStore::insert(const std::string& columns, Tuple* record)
+ContextStoreSideGate::~ContextStoreSideGate()
{
- return E_SUPPORT;
}
-int ContextStore::insert(const std::string& columns, std::vector<Tuple*>& records)
+int ContextStoreSideGate::insert(const std::string& columns, std::vector<Tuple*>& tuples)
{
return E_SUPPORT;
}
-int ContextStore::retrieve(const ContextStoreSearchQuery& query, std::vector<Tuple*>& records)
+ContextStoreSideGate ContextStoreSideGate::getUserStore(const std::string& uri)
{
- return E_SUPPORT;
+ ContextStoreSideGate sideGate(uri, false);
+ return sideGate;
}
-int ContextStore::remove(const std::string& selection)
+ContextStoreSideGate ContextStoreSideGate::getSystemStore(const std::string& uri)
{
- return E_SUPPORT;
+ ContextStoreSideGate sideGate(uri, true);
+ return sideGate;
}
SET(DEPS "${DEPS} context-common-server")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/private)
+
FILE(GLOB_RECURSE SRCS *.cpp ../shared/*.cpp)
MESSAGE("Sources: ${SRCS}")
__remove(*store, *methodCall);
}
} catch (int error) {
+ _W("Catch: %s", CTX_ERROR_STR(error));
methodCall->reply(error);
} catch (std::exception& e) {
_E("Exception: %s", e.what());
if (!store.permitted(*this))
throw static_cast<int>(E_ACCESS);
- methodCall.reply(g_variant_new("(s)", store.getPath().c_str()));
+ methodCall.reply(g_variant_new("(s)", store.getColumns().c_str()));
}
void ContextStoreClient::__insert(Store& store, MethodCall& methodCall)
int error = store.retrieve(*this, projection, selection, sortOrder, limit, &tuples);
if (error != E_NONE)
throw error;
+ if (tuples.empty())
+ throw static_cast<int>(E_NO_DATA);
methodCall.reply(g_variant_new("(v)", Tuple::toGVariant(tuples)));
}
*/
#include <ContextStoreTypesPrivate.h>
+#include <ContextStoreSideGate.h>
#include <ContextStoreService.h>
#include "ContextStoreClient.h"
#include "StoreManager.h"
ServiceBase(conn, CTX_CONTEXT_STORE, CTX_CONTEXT_STORE_SPEC),
__storeManager(NULL)
{
+ ContextStoreSideGate::__hostService = this;
}
ContextStoreService::~ContextStoreService()
void ContextStoreService::onUserDeactivated()
{
DatabaseManager::closeUser();
+ if (__storeManager)
+ __storeManager->flushUserCache();
}
StoreManager& ContextStoreService::getStoreManager()
--- /dev/null
+/*
+ * 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 <ContextStoreService.h>
+#include <ContextStoreSideGate.h>
+
+using namespace ctx;
+
+ContextStoreService* ContextStoreSideGate::__hostService = NULL;
+
+ContextStoreSideGate::ContextStoreSideGate(const std::string& uri, bool isSystem) :
+ __uri(uri),
+ __isSystem(isSystem)
+{
+}
+
+ContextStoreSideGate::~ContextStoreSideGate()
+{
+}
+
+int ContextStoreSideGate::insert(const std::string& columns, std::vector<Tuple*>& tuples)
+{
+ //TODO: Switch to the thread-default mainloop, get the Store object, and insert.
+ return E_SUPPORT;
+}
+
+ContextStoreSideGate ContextStoreSideGate::getUserStore(const std::string& uri)
+{
+ ContextStoreSideGate sideGate(uri, false);
+ return sideGate;
+}
+
+ContextStoreSideGate ContextStoreSideGate::getSystemStore(const std::string& uri)
+{
+ ContextStoreSideGate sideGate(uri, true);
+ return sideGate;
+}
char* insertSql = NULL;
int length = 0;
+ std::string columns;
std::string readPrivil;
std::string writePrivil;
+ for (auto& attr : schema.attributes) {
+ columns.append(attr.first);
+ switch (attr.second) {
+ case Schema::AttributeType::INTEGER:
+ columns.append(" " COL_INT64 COLUMN_DELIM);
+ break;
+ case Schema::AttributeType::REAL:
+ columns.append(" " COL_DOUBLE COLUMN_DELIM);
+ break;
+ case Schema::AttributeType::TEXT:
+ default:
+ columns.append(" " COL_STRING COLUMN_DELIM);
+ break;
+ }
+ }
+
for (auto& item : schema.readPrivileges) {
readPrivil.append(item);
readPrivil.append(PRIVILEGE_DELIM);
length = asprintf(&updateSql,
"UPDATE ContextStoreSchema"
- " SET uri='%s', retention=%u, \"limit\"=%u, readPrivileges='%s', writePrivileges='%s'"
+ " SET uri='%s', columns='%s', retention=%u, \"limit\"=%u, readPrivileges='%s', writePrivileges='%s'"
" WHERE uri='%s'",
- schema.uri.c_str(), schema.retention, schema.limit, readPrivil.c_str(), writePrivil.c_str(),
- schema.uri.c_str());
+ schema.uri.c_str(), columns.c_str(), schema.retention, schema.limit,
+ readPrivil.c_str(), writePrivil.c_str(), schema.uri.c_str());
if (length <= 0) {
_E("Memory allocation failed");
return;
length = asprintf(&insertSql,
"INSERT OR IGNORE INTO ContextStoreSchema"
- " (uri, retention, \"limit\", readPrivileges, writePrivileges)"
- " VALUES ('%s', %u, %u, '%s', '%s')",
- schema.uri.c_str(), schema.retention, schema.limit, readPrivil.c_str(), writePrivil.c_str());
+ " (uri, columns, retention, \"limit\", readPrivileges, writePrivileges)"
+ " VALUES ('%s', '%s', %u, %u, '%s', '%s')",
+ schema.uri.c_str(), columns.c_str(), schema.retention, schema.limit,
+ readPrivil.c_str(), writePrivil.c_str());
if (length <= 0) {
g_free(updateSql);
_E("Memory allocation failed");
COL_OWNER_ID " TEXT NOT NULL DEFAULT ''";
for (auto& item : schema.attributes) {
- attr = attr + "," + item.first;
+ attr.append(",").append(item.first);
switch (item.second) {
case Schema::AttributeType::INTEGER:
- attr = attr + " INTEGER NOT NULL DEFAULT 0";
+ attr.append(" INTEGER NOT NULL DEFAULT 0");
break;
case Schema::AttributeType::REAL:
- attr = attr + " REAL NOT NULL DEFAULT 0";
+ attr.append(" REAL NOT NULL DEFAULT 0");
break;
+ case Schema::AttributeType::TEXT:
default:
- attr = attr + " TEXT NOT NULL DEFAULT ''";
+ attr.append(" TEXT NOT NULL DEFAULT ''");
break;
}
}
return __readable(client) || __writable(client);
}
-const std::string& Store::getPath()
+const std::string& Store::getColumns()
{
- return metadata.path;
+ return metadata.columns;
}
int Store::insert(ContextStoreClient& client, const std::string& columns, std::vector<Tuple*>& tuples)
_D("Inserting %u tuples of (%s) to %s", tuples.size(), columns.c_str(), metadata.uri.c_str());
int error = __getDatabase().insert(metadata.uri, columns, tuples) ? E_NONE : E_PARAM;
+ for (auto& tuple : tuples) {
+ delete tuple;
+ }
+ tuples.clear();
return error;
}
public:
Metadata();
- std::string path;
std::string uri;
+ std::string columns;
unsigned int retention;
unsigned int limit;
std::vector<std::string> readPrivileges;
bool permitted(ContextStoreClient& client);
- const std::string& getPath();
+ const std::string& getColumns();
int insert(ContextStoreClient& client, const std::string& columns, std::vector<Tuple*>& tuples);
* limitations under the License.
*/
+#include <ContextStoreUtil.h>
#include "DatabaseManager.h"
#include "UserStore.h"
#include "SystemStore.h"
StoreManager::~StoreManager()
{
+ flushUserCache();
+ flushSystemCache();
}
Store* StoreManager::__findStore(std::list<Store*>& stores, const std::string& uri)
return NULL;
}
-std::vector<std::string> __tokenize(std::string& in, const char* delim)
-{
- std::vector<std::string> tokens;
- std::size_t begin = 0;
- std::size_t end = in.find(delim, 0);
-
- while (end != std::string::npos) {
- tokens.push_back(in.substr(begin, end - begin));
- begin = end + 1;
- end = in.find(delim, begin);
- }
-
- return tokens;
-}
-
template<typename StoreType>
Store* StoreManager::__createStore(Database& database, std::list<Store*>& stores, const std::string& uri)
{
std::string query =
- "SELECT retention, \"limit\", readPrivileges, writePrivileges"
+ "SELECT columns, retention, \"limit\", readPrivileges, writePrivileges"
" FROM ContextStoreSchema"
" WHERE uri='" + uri + "'";
std::vector<Tuple*> tuples;
- if (!database.execute(query, COL_INT64 COL_INT64 COL_STRING COL_STRING, NULL, &tuples)) {
+ if (!database.execute(query, COL_STRING COL_INT64 COL_INT64 COL_STRING COL_STRING, NULL, &tuples)) {
_E("DB search failed");
return NULL;
}
return NULL;
}
+ std::string columns;
int64_t retention = 0;
int64_t limit = 0;
std::string readPrivil;
std::string writePrivil;
- tuples[0]->getAt(0, &retention);
- tuples[0]->getAt(1, &limit);
- tuples[0]->getAt(2, &readPrivil);
- tuples[0]->getAt(3, &writePrivil);
+ tuples[0]->getAt(0, &columns);
+ tuples[0]->getAt(1, &retention);
+ tuples[0]->getAt(2, &limit);
+ tuples[0]->getAt(3, &readPrivil);
+ tuples[0]->getAt(4, &writePrivil);
delete tuples[0];
_D("URI: %s, Retention: %u, Limit: %u", uri.c_str(), static_cast<unsigned int>(retention), static_cast<unsigned int>(limit));
+ _D("Columns: %s", columns.c_str());
_D("Read: %s", readPrivil.c_str());
_D("Write: %s", writePrivil.c_str());
IF_FAIL_RETURN_TAG(store, NULL, _E, "Memory allocation failed");
store->metadata.uri = uri;
+ store->metadata.columns = columns;
store->metadata.retention= static_cast<unsigned int>(retention);
store->metadata.limit = static_cast<unsigned int>(limit);
- store->metadata.readPrivileges = __tokenize(readPrivil, PRIVILEGE_DELIM);
- store->metadata.writePrivileges = __tokenize(writePrivil, PRIVILEGE_DELIM);
+ store->metadata.readPrivileges = util::tokenizeString(readPrivil, PRIVILEGE_DELIM);
+ store->metadata.writePrivileges = util::tokenizeString(writePrivil, PRIVILEGE_DELIM);
stores.push_front(store);
if (stores.size() > CACHE_SIZE) {
#include <ContextTypes.h>
#include <ContextErrorUtil.h>
-#include <ContextStoreTypes.h>
#define CTX_CONTEXT_STORE "ContextStore"
#define CTX_CONTEXT_STORE_SPEC \
+ "<method name='" METHOD_RELOAD_USER "'>" \
+ "</method>" \
+ "<method name='" METHOD_RELOAD_SYSTEM "'>" \
+ "</method>" \
"<method name='" METHOD_GET_ACCESS "'>" \
" <arg type='s' name='uri' direction='in'/>" \
- " <arg type='s' name='path' direction='out'/>" \
+ " <arg type='s' name='columns' direction='out'/>" \
"</method>" \
"<method name='" METHOD_INSERT "'>" \
" <arg type='s' name='uri' direction='in'/>" \
" <arg type='s' name='selection' direction='in'/>" \
"</method>"
+#define METHOD_RELOAD_USER "ReloadUser"
+#define METHOD_RELOAD_SYSTEM "ReloadSystem"
#define METHOD_GET_ACCESS "GetAccess"
#define METHOD_INSERT "Insert"
#define METHOD_RETRIEVE "Retrieve"
#define MAX_RETENTION 8760 // one year
#define MAX_LIMIT 100000
#define PRIVILEGE_DELIM ";"
+#define COLUMN_DELIM ";"
#define BASE_PATH "context-store"
* limitations under the License.
*/
-#include <ContextStoreTypesPrivate.h>
-#include <ContextStoreManager.h>
+#include "ContextStoreTypesPrivate.h"
+#include "ContextStoreUtil.h"
using namespace ctx;
-ContextStoreManager::ContextStoreManager()
+std::vector<std::string> util::tokenizeString(std::string& in, const char* delim)
{
-}
+ std::vector<std::string> tokens;
+ std::size_t begin = 0;
+ std::size_t end = in.find(delim, 0);
-ContextStoreManager::~ContextStoreManager()
-{
-}
+ while (end != std::string::npos) {
+ tokens.push_back(in.substr(begin, end - begin));
+ begin = end + 1;
+ end = in.find(delim, begin);
+ }
-int ContextStoreManager::getStore(const std::string& uri, ContextStore** store)
-{
- return E_SUPPORT;
+ return tokens;
}
* limitations under the License.
*/
-#ifndef __CONTEXT_STORE_TYPES_H__
-#define __CONTEXT_STORE_TYPES_H__
+#ifndef __CONTEXT_STORE_UTIL_H__
+#define __CONTEXT_STORE_UTIL_H__
-#include <tizen.h>
+#include <vector>
+#include <string>
+namespace ctx { namespace util {
+
+ std::vector<std::string> tokenizeString(std::string& in, const char* delim);
+
+} }
#endif