/*
- * 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.
/**
* @file src/client-async/api/client-async-api.cpp
* @author Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
* @version 1.0
* @brief Implementation of external libcynara-client-async API
*/
#include <log/log.h>
#include <api/ApiInterface.h>
+#include <configuration/Configuration.h>
#include <cynara-client-async.h>
#include <logic/Logic.h>
}
};
+struct cynara_async_configuration {
+ Cynara::Configuration* impl;
+
+ cynara_async_configuration(Cynara::Configuration *_impl) : impl(_impl) {}
+
+ ~cynara_async_configuration() {
+ delete impl;
+ }
+};
+
+CYNARA_API
+int cynara_async_configuration_create(cynara_async_configuration **pp_conf) {
+ if (!pp_conf)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ Cynara::ConfigurationUniquePtr ptr(new Cynara::Configuration());
+ *pp_conf = new cynara_async_configuration(ptr.get());
+ ptr.release();
+ LOGD("Cynara configuration initialized");
+ return CYNARA_API_SUCCESS;
+ });
+}
+
+CYNARA_API
+void cynara_async_configuration_destroy(cynara_async_configuration *p_conf) {
+ delete p_conf;
+}
+
+CYNARA_API
+int cynara_async_configuration_set_cache_size(cynara_async_configuration *p_conf,
+ size_t cache_size) {
+ if (!p_conf || !p_conf->impl)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ p_conf->impl->setCacheSize(cache_size);
+ return CYNARA_API_SUCCESS;
+ });
+}
+
CYNARA_API
int cynara_async_initialize(cynara_async **pp_cynara,
const cynara_async_configuration *p_conf UNUSED,
--- /dev/null
+/*
+ * Copyright (c) 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.
+ * 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
+ */
+/**
+ * @file src/client-common/configuration/Configuration.h
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
+ * @version 1.0
+ * @brief This file contains client configuration class.
+ */
+
+#ifndef SRC_CLIENT_COMMON_CONFIGURATION_CONFIGURATION_H_
+#define SRC_CLIENT_COMMON_CONFIGURATION_CONFIGURATION_H_
+
+#include <cstddef>
+#include <memory>
+
+#include <cache/CapacityCache.h>
+
+namespace Cynara {
+
+class Configuration;
+typedef std::unique_ptr<Configuration> ConfigurationUniquePtr;
+
+class Configuration {
+public:
+ Configuration() : m_cacheSize(CapacityCache::CACHE_DEFAULT_CAPACITY) {};
+
+ void setCacheSize(std::size_t size) {
+ m_cacheSize = size;
+ }
+ std::size_t getCacheSize(void) const {
+ return m_cacheSize;
+ }
+ ~Configuration() {}
+private:
+ std::size_t m_cacheSize;
+};
+
+} /* namespace Cynara */
+
+#endif /* SRC_CLIENT_COMMON_CONFIGURATION_CONFIGURATION_H_ */
/*
- * 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.
/**
* @file src/client/api/client-api.cpp
* @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @author Zofia Abramowska <z.abramowska@samsung.com>
* @version 1.0
* @brief Implementation of external libcynara-client API
*/
#include <exceptions/TryCatch.h>
#include <log/log.h>
+#include <configuration/Configuration.h>
#include <cynara-client.h>
#include <cynara-error.h>
#include <api/ApiInterface.h>
}
};
+struct cynara_configuration {
+ Cynara::Configuration* impl;
+
+ cynara_configuration(Cynara::Configuration *_impl) : impl(_impl) {}
+
+ ~cynara_configuration() {
+ delete impl;
+ }
+};
+
+CYNARA_API
+int cynara_configuration_create(cynara_configuration **pp_conf) {
+ if (!pp_conf)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ Cynara::ConfigurationUniquePtr ptr(new Cynara::Configuration());
+ *pp_conf = new cynara_configuration(ptr.get());
+ ptr.release();
+ LOGD("Cynara configuration initialized");
+ return CYNARA_API_SUCCESS;
+ });
+}
+
+CYNARA_API
+void cynara_configuration_destroy(cynara_configuration *p_conf) {
+ delete p_conf;
+}
+
+CYNARA_API
+int cynara_configuration_set_cache_size(cynara_configuration *p_conf, size_t cache_size) {
+ if (!p_conf || !p_conf->impl)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ p_conf->impl->setCacheSize(cache_size);
+ return CYNARA_API_SUCCESS;
+ });
+}
+
CYNARA_API
int cynara_initialize(cynara **pp_cynara, const cynara_configuration *p_conf UNUSED)
{
init_log();
return Cynara::tryCatch([&]() {
- *pp_cynara = new cynara(new Cynara::Logic);
+ *pp_cynara = new cynara(new Cynara::Logic());
LOGD("Cynara client initialized");