response_callback.hpp \
glib_traits.hpp \
json_glib_traits.hpp \
- smart_ptr.hpp \
+ unique_ptr.hpp \
dbus_signal_callback.hpp
* The appropriate "header" information will be prepended to the
* event.
*/
- smart_ptr<JsonBuilder> begin_event();
+ unique_ptr<JsonBuilder> begin_event();
/**
* End the JSON formatted event to the Settings app request.
*/
- void end_event(smart_ptr<JsonBuilder> const & builder);
+ void end_event(unique_ptr<JsonBuilder> const & builder);
private:
*
* @param[in] result @c "succeeded" or @c "failed"
*/
- smart_ptr<JsonBuilder> begin_response(char const * result);
+ unique_ptr<JsonBuilder> begin_response(char const * result);
/**
* End the JSON formatted response to the Settings app request.
*/
- void end_response(smart_ptr<JsonBuilder> const & builder);
+ void end_response(unique_ptr<JsonBuilder> const & builder);
private:
#define IVI_SETTINGS_SEND_CALLBACK_HPP
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <libwebsockets.h>
* pre-marshalled (in-memory) payload.
*/
bool send_payload(char const * send_type,
- smart_ptr<JsonBuilder> const & builder);
+ unique_ptr<JsonBuilder> const & builder);
/**
* Check if the WebSocket instance @a wsi corresponds to this
/**
- * @file smart_ptr.hpp
+ * @file unique_ptr.hpp
*
- * @brief C++11 style smart pointer for use by settings plug-ins.
+ * @brief C++11 style @c unique_ptr for use by settings plug-ins.
*
* @author Ossama Othman @<ossama.othman@@intel.com@>
*
* Boston, MA 02110-1301 USA
*/
-#ifndef IVI_SETTINGS_SMART_PTR_HPP
-#define IVI_SETTINGS_SMART_PTR_HPP
+#ifndef IVI_SETTINGS_UNIQUE_PTR_HPP
+#define IVI_SETTINGS_UNIQUE_PTR_HPP
#include <memory>
namespace settings
{
/**
- * @typedef smart_ptr
+ * @typedef unique_ptr
*
- * @brief C++11 style smart pointer for use by settings plug-ins.
+ * @brief C++11 style unique pointer for use by settings plug-ins.
*
- * This type alias exposes a C++11-style smart pointer interface
+ * This type alias exposes a C++11-style @c unique_ptr interface
* to allow RAII based handling of resources provided by third
* party libraries, such as Glib. Core functionality is
* implemented in traits that this type alias leverages.
*/
- template<typename T> using smart_ptr =
+ template<typename T> using unique_ptr =
::std::unique_ptr<T,
typename traits<T>::delete_functor>;
}
}
-#endif /* IVI_SETTINGS_SMART_PTR_HPP */
+#endif /* IVI_SETTINGS_UNIQUE_PTR_HPP */
// Local Variables:
#include <settingsd/event_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include "manager.hpp"
ivi::settings::event_callback::send_event(
std::function<void(JsonBuilder *)> event_builder)
{
- smart_ptr<JsonBuilder> const builder = begin_event();
+ unique_ptr<JsonBuilder> const builder = begin_event();
// Append settings type-specific JSON formatted events.
event_builder(builder.get());
return manager_.send_event(builder);
}
-ivi::settings::smart_ptr<JsonBuilder>
+ivi::settings::unique_ptr<JsonBuilder>
ivi::settings::event_callback::begin_event()
{
// Construct JSON event string.
- smart_ptr<JsonBuilder> safe_builder(json_builder_new());
+ unique_ptr<JsonBuilder> safe_builder(json_builder_new());
JsonBuilder * const builder = safe_builder.get();
json_builder_begin_object(builder);
void
ivi::settings::event_callback::end_event(
- ivi::settings::smart_ptr<JsonBuilder> const & builder)
+ ivi::settings::unique_ptr<JsonBuilder> const & builder)
{
json_builder_end_object(builder.get());
}
#include <settingsd/plugin.hpp>
#include <settingsd/response_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <gmodule.h>
return;
}
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
JsonReader * const reader = json_reader_new(json_parser_get_root(parser.get()));
- smart_ptr<JsonReader> const safe_reader(reader);
+ unique_ptr<JsonReader> const safe_reader(reader);
// Retrieve setting name and transcation ID from the JSON request
// string.
bool
ivi::settings::manager::send_event(
- smart_ptr<JsonBuilder> const & builder)
+ unique_ptr<JsonBuilder> const & builder)
{
bool success = true;
*
* @return @c true on success.
*/
- bool send_event(smart_ptr<JsonBuilder> const & builder);
+ bool send_event(unique_ptr<JsonBuilder> const & builder);
private:
#include <settingsd/response_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
ivi::settings::response_callback::response_callback(
ivi::settings::response_callback::send_response(
std::function<void(JsonBuilder *)> response_builder)
{
- smart_ptr<JsonBuilder> const builder = begin_response("succeeded");
+ unique_ptr<JsonBuilder> const builder = begin_response("succeeded");
// Append successful Settings app results to the JSON formatted
// response.
bool
ivi::settings::response_callback::send_error(std::string error_message)
{
- smart_ptr<JsonBuilder> builder = begin_response("failed");
+ unique_ptr<JsonBuilder> builder = begin_response("failed");
json_builder_set_member_name(builder.get(), "reason");;
json_builder_add_string_value(builder.get(), error_message.c_str());
json_builder_add_string_value(builder, value.c_str());
}
-ivi::settings::smart_ptr<JsonBuilder>
+ivi::settings::unique_ptr<JsonBuilder>
ivi::settings::response_callback::begin_response(char const * result)
{
// Construct JSON response.
- smart_ptr<JsonBuilder> safe_builder(json_builder_new());
+ unique_ptr<JsonBuilder> safe_builder(json_builder_new());
JsonBuilder * const builder = safe_builder.get();
json_builder_begin_object(builder);
void
ivi::settings::response_callback::end_response(
- ivi::settings::smart_ptr<JsonBuilder> const & builder)
+ ivi::settings::unique_ptr<JsonBuilder> const & builder)
{
json_builder_end_object(builder.get());
}
#include <settingsd/send_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <vector>
bool
ivi::settings::send_callback::send_payload(
char const * send_type,
- smart_ptr<JsonBuilder> const & builder)
+ unique_ptr<JsonBuilder> const & builder)
{
- smart_ptr<JsonGenerator> const generator(json_generator_new());
- smart_ptr<JsonNode> const root(json_builder_get_root(builder.get()));
+ unique_ptr<JsonGenerator> const generator(json_generator_new());
+ unique_ptr<JsonNode> const root(json_builder_get_root(builder.get()));
json_generator_set_root(generator.get(), root.get());
gchar * const data =
json_generator_to_data(generator.get(), nullptr);
- smart_ptr<gchar> safe_data(data);
+ unique_ptr<gchar> safe_data(data);
if (data == nullptr) {
g_critical("Unable to generate JSON formatted %s payload:\n",
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <boost/lexical_cast.hpp>
ivi::settings::clock::handle_request(std::string request,
response_callback response)
{
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
JsonReader * const reader =
json_reader_new(json_parser_get_root(parser.get()));
- smart_ptr<JsonReader> safe_reader(reader);
+ unique_ptr<JsonReader> safe_reader(reader);
char const * name = nullptr;
if (json_reader_read_member(reader, "name")) {
"Unrecognized " + id() + " request name: " + name);
}
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (success) {
? "<invalid_string>"
: updates));
} else {
- smart_ptr<GVariant> const current_value(get_property(name, error));
+ unique_ptr<GVariant> const current_value(get_property(name, error));
if (current_value != nullptr) {
char const * value =
return;
}
- smart_ptr<GVariant> const current_value(get_property(name, error));
+ unique_ptr<GVariant> const current_value(get_property(name, error));
if (current_value != nullptr) {
char const * value =
response_callback /* response */,
GError *& error)
{
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
connman_.set_property(name, value, error));
return ret.get() != nullptr;
{
constexpr gint const timeout = 5000; // milliseconds
- smart_ptr<GVariant> const dictionary(
+ unique_ptr<GVariant> const dictionary(
g_dbus_proxy_call_sync(connman_.proxy(),
"GetProperties",
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GVariant> value;
+ unique_ptr<GVariant> value;
if (dictionary != nullptr) {
GVariantIter * i = nullptr;
g_variant_get(dictionary.get(), "(a{sv})", &i);
- smart_ptr<GVariantIter> const iter(i);
+ unique_ptr<GVariantIter> const iter(i);
gchar * pname = nullptr;
GVariant * pvalue = nullptr;
while (g_variant_iter_next(i, "{sv}", &pname, &pvalue)) {
- smart_ptr<gchar> const name(pname);
+ unique_ptr<gchar> const name(pname);
value.reset(pvalue);
// Check if this is the property we want.
#include "connman.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <settingsd/dbus_signal_callback.hpp>
#include <cstring>
nullptr, // GCancellable
&error);
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (proxy_ == nullptr) {
g_printerr("Unable to create D-Bus proxy for (\"%s\", \"%s\"): %s\n",
#include <settingsd/dbus_signal_callback.hpp>
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
{
constexpr gint const timeout = 5000; // milliseconds
- smart_ptr<GVariant> const dictionary(
+ unique_ptr<GVariant> const dictionary(
g_dbus_proxy_call_sync(connman_.proxy(),
"GetTechnologies",
nullptr, // No parameters
if (dictionary != nullptr) {
GVariantIter * i = nullptr;
g_variant_get(dictionary.get(), "(a(oa{sv}))", &i);
- smart_ptr<GVariantIter> const safe_i(i);
+ unique_ptr<GVariantIter> const safe_i(i);
- for (smart_ptr<GVariant> child(g_variant_iter_next_value(i));
+ for (unique_ptr<GVariant> child(g_variant_iter_next_value(i));
child != nullptr;
child.reset(g_variant_iter_next_value(i))) {
// The object path is the first tuple element.
- smart_ptr<GVariant> const tmp(
+ unique_ptr<GVariant> const tmp(
g_variant_get_child_value(child.get(), 0));
char const * object =
#include "service.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <settingsd/response_callback.hpp>
#include <chrono>
constexpr gint const timeout = 10000; // milliseconds
GError * error = nullptr;
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
g_dbus_proxy_call_sync(connman_.proxy(),
name, // "Connect", "Disconect", ...
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GError> safe_error;
+ unique_ptr<GError> safe_error;
if (ret != nullptr) {
// Nothing to add to successful response.
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <chrono>
ivi::settings::technology::handle_request(std::string request,
response_callback response)
{
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
- smart_ptr<JsonReader> const safe_reader(
+ unique_ptr<JsonReader> const safe_reader(
json_reader_new(json_parser_get_root(parser.get())));
JsonReader * const reader = safe_reader.get();
return;
}
- smart_ptr<GVariant> const property(
+ unique_ptr<GVariant> const property(
get_property("Powered", G_VARIANT_TYPE_BOOLEAN, response));
if (property != nullptr) {
GError * error = nullptr;
- smart_ptr<GVariant> ret(
+ unique_ptr<GVariant> ret(
connman_.set_property(name,
g_variant_new_boolean(enable),
error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (ret != nullptr) {
// Nothing to add to successful response.
constexpr gint const timeout = 10000; // milliseconds
GError * error = nullptr;
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
g_dbus_proxy_call_sync(connman_.proxy(),
"Scan",
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (ret != nullptr) {
send_services(response, error);
ivi::settings::technology::send_services(response_callback response,
GError *& error)
{
- smart_ptr<GVariant> const services(manager_.get_services(error));
+ unique_ptr<GVariant> const services(manager_.get_services(error));
if (services != nullptr) {
response.send_response(
{
GError * error = nullptr;
- smart_ptr<GVariant> const properties(
+ unique_ptr<GVariant> const properties(
manager_.get_properties(technology_, error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
- smart_ptr<GVariant> property;
+ unique_ptr<GVariant> property;
if (properties != nullptr) {
property.reset(
g_variant_lookup_value(properties.get(), name, type));
#include "websocket_server.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <glib.h>
#include <iostream>
// Glib related events, including GDbus related signal handlers,
// will handled in this (main) thread.
- settings::smart_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
+ settings::unique_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
g_main_loop_run(loop.get());
}
catch (std::exception & e) {