/* Forward Declaration */
class json;
class context_provider_iface;
+ class context_provider_info;
namespace context_manager {
/*
*/
- bool register_provider(const char* subject, ctx::context_provider_iface* cp);
+ bool register_provider(const char *subject, context_provider_info &provider_info);
/*
*/
- bool publish(const char* subject, ctx::json option, int error, ctx::json data_updated);
+ bool publish(const char *subject, ctx::json option, int error, ctx::json data_updated);
/*
*/
- bool reply_to_read(const char* subject, ctx::json option, int error, ctx::json data_read);
+ bool reply_to_read(const char *subject, ctx::json option, int error, ctx::json data_read);
} /* namespace ctx::context_manager */
} /* namespace ctx */
/* Forward Declaration */
class json;
class context_provider_iface;
+ class context_provider_info;
class context_manager_iface {
- public:
- virtual ~context_manager_iface() {}
- virtual bool register_provider(const char* subject, ctx::context_provider_iface* cp) = 0;
- virtual bool publish(const char* subject, ctx::json& option, int error, ctx::json& data_updated) = 0;
- virtual bool reply_to_read(const char* subject, ctx::json& option, int error, ctx::json& data_read) = 0;
+ public:
+ virtual ~context_manager_iface() {}
+ virtual bool register_provider(const char *subject, context_provider_info &provider_info) = 0;
+ virtual bool publish(const char *subject, ctx::json &option, int error, ctx::json &data_updated) = 0;
+ virtual bool reply_to_read(const char *subject, ctx::json &option, int error, ctx::json &data_read) = 0;
}; /* class context_manager_iface */
namespace context_manager {
class json;
class context_provider_iface {
- public:
- virtual ~context_provider_iface() {}
+ public:
+ virtual ~context_provider_iface() {}
+ virtual int subscribe(const char *subject, ctx::json option, ctx::json *request_result);
+ virtual int unsubscribe(const char *subject, ctx::json option);
+ virtual int read(const char *subject, ctx::json option, ctx::json *request_result);
+ virtual int write(const char *subject, ctx::json data, ctx::json *request_result);
- virtual bool init() = 0;
+ protected:
+ context_provider_iface() {}
- virtual bool is_supported(const char* subject) = 0;
-
- virtual int subscribe(const char* subject, ctx::json option, ctx::json* request_result) = 0;
-
- virtual int unsubscribe(const char* subject, ctx::json option) = 0;
+ }; /* class context_provider_iface */
- virtual int read(const char* subject, ctx::json option, ctx::json* request_result) = 0;
+ class context_provider_info {
+ typedef context_provider_iface *(*creator_t)(void *data);
+ typedef void (*destroyer_t)(void *data);
- virtual int write(const char* subject, ctx::json data, ctx::json* request_result) = 0;
+ public:
+ creator_t create;
+ destroyer_t destroy;
+ void *data;
+ const char *privilege;
- }; /* class context_provider_iface */
+ context_provider_info();
+ context_provider_info(creator_t cr, destroyer_t des, void *dat = NULL, const char *priv = NULL);
+ };
} /* namespace ctx */
_instance = mgr;
}
-bool ctx::context_manager::register_provider(const char* subject, ctx::context_provider_iface* cp)
+bool ctx::context_manager::register_provider(const char* subject, ctx::context_provider_info &provider_info)
{
IF_FAIL_RETURN_TAG(_instance, false, _E, "Not initialized");
- return _instance->register_provider(subject, cp);
+ return _instance->register_provider(subject, provider_info);
}
bool ctx::context_manager::publish(const char* subject, ctx::json option, int error, ctx::json data_updated)
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <types_internal.h>
+#include <json.h>
+#include <provider_iface.h>
+
+int ctx::context_provider_iface::subscribe(const char *subject, ctx::json option, ctx::json *request_result)
+{
+ return ERR_NOT_SUPPORTED;
+}
+
+int ctx::context_provider_iface::unsubscribe(const char *subject, ctx::json option)
+{
+ return ERR_NOT_SUPPORTED;
+}
+
+int ctx::context_provider_iface::read(const char *subject, ctx::json option, ctx::json *request_result)
+{
+ return ERR_NOT_SUPPORTED;
+}
+
+int ctx::context_provider_iface::write(const char *subject, ctx::json data, ctx::json *request_result)
+{
+ return ERR_NOT_SUPPORTED;
+}
+
+ctx::context_provider_info::context_provider_info()
+ : create(NULL)
+ , destroy(NULL)
+ , data(NULL)
+ , privilege(NULL)
+{
+}
+
+ctx::context_provider_info::context_provider_info(
+ ctx::context_provider_info::creator_t cr,
+ ctx::context_provider_info::destroyer_t des, void *dat, const char *priv)
+ : create(cr)
+ , destroy(des)
+ , data(dat)
+ , privilege(priv)
+{
+}