return Cynara::tryCatch([&]() {
try {
- *pp_cynara_admin = new cynara_admin(new Cynara::Logic);
+ Cynara::LogicUniquePtr ptr(new Cynara::Logic());
+ *pp_cynara_admin = new cynara_admin(ptr.get());
+ ptr.release();
} catch (const Cynara::FileLockAcquiringException &ex) {
LOGE("%s", ex.what());
return CYNARA_API_OPERATION_FAILED;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define SRC_ADMIN_LOGIC_LOGIC_H_
#include <functional>
+#include <memory>
#include <common/lock/FileLock.h>
namespace Cynara {
+class Logic;
+typedef std::unique_ptr<Logic> LogicUniquePtr;
+
class OnlineLogic;
class OfflineLogic;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
init_log();
return Cynara::tryCatch([&]() {
- *pp_cynara_agent = new cynara_agent(new Cynara::Logic(p_agent_type));
+ Cynara::LogicUniquePtr ptr(new Cynara::Logic(p_agent_type));
+ *pp_cynara_agent = new cynara_agent(ptr.get());
+ ptr.release();
LOGD("Cynara agent initialized");
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef SRC_AGENT_LOGIC_LOGIC_H_
#define SRC_AGENT_LOGIC_LOGIC_H_
+#include <memory>
+
#include <types/Agent.h>
#include <api/ApiInterface.h>
namespace Cynara {
+class Logic;
+typedef std::unique_ptr<Logic> LogicUniquePtr;
+
class Logic : public ApiInterface {
public:
Logic(const AgentType &agentType);
init_log();
return Cynara::tryCatch([&]() {
- if (p_conf && p_conf->impl)
- *pp_cynara = new cynara_async(new Cynara::Logic(callback, user_status_data,
- *(p_conf->impl)));
- else
- *pp_cynara = new cynara_async(new Cynara::Logic(callback, user_status_data));
+ Cynara::LogicUniquePtr ptr;
+ if (p_conf && p_conf->impl) {
+ ptr.reset(new Cynara::Logic(callback, user_status_data, *(p_conf->impl)));
+ } else {
+ ptr.reset(new Cynara::Logic(callback, user_status_data));
+ }
+ *pp_cynara = new cynara_async(ptr.get());
+ ptr.release();
LOGD("Cynara client async initialized");
#ifndef SRC_CLIENT_ASYNC_LOGIC_LOGIC_H_
#define SRC_CLIENT_ASYNC_LOGIC_LOGIC_H_
+#include <memory>
+
#include <cache/CacheInterface.h>
#include <configuration/Configuration.h>
#include <types/ProtocolFields.h>
#include <sockets/SocketClientAsync.h>
namespace Cynara {
+class Logic;
+typedef std::unique_ptr<Logic> LogicUniquePtr;
class Logic : public ApiInterface {
public:
init_log();
return Cynara::tryCatch([&]() {
- if (p_conf && p_conf->impl)
- *pp_cynara = new cynara(new Cynara::Logic(*(p_conf->impl)));
- else
- *pp_cynara = new cynara(new Cynara::Logic());
+ Cynara::LogicUniquePtr ptr;
+ if (p_conf && p_conf->impl) {
+ ptr.reset(new Cynara::Logic(*(p_conf->impl)));
+ } else {
+ ptr.reset(new Cynara::Logic());
+ }
+ *pp_cynara = new cynara(ptr.get());
+ ptr.release();
LOGD("Cynara client initialized");
#ifndef SRC_CLIENT_LOGIC_LOGIC_H_
#define SRC_CLIENT_LOGIC_LOGIC_H_
+#include <memory>
#include <string>
#include <sockets/SocketClient.h>
namespace Cynara {
+class Logic;
+typedef std::unique_ptr<Logic> LogicUniquePtr;
+
class Logic : public ApiInterface {
public:
explicit Logic(const Configuration &conf = Configuration());