#ifndef __GALLERY_MODEL_GALLERY_H__
#define __GALLERY_MODEL_GALLERY_H__
-#include "IMediaAlbum.h"
+#include "types.h"
namespace gallery {
class Gallery final : public ucl::NonCopyable {
public:
- Gallery();
+ static GallerySRef newInstance();
~Gallery();
- IMediaAlbum &getAlbum();
+ IMediaAlbumSRef getAlbum();
+
+ private:
+ friend class ucl::RefCountObj<Gallery>;
+ Gallery();
+
+ ucl::Result prepare();
+
+ private:
+ IMediaAlbumSRef m_album;
+ bool m_isMediaDbConnected;
};
}
class IMediaAlbum : public ucl::Polymorphic {
public:
- using EachCb = ucl::Delegate<void(MediaItemUPtr item)>;
+ using EachCb = ucl::Delegate<bool(MediaItemUPtr media)>;
public:
virtual ucl::Result forEachMedia(EachCb cb) const = 0;
class MediaItem : public ucl::Polymorphic {
public:
using ThumbnailPathGetCb =
- std::function<void(ucl::Result, const std::string &path)>;
+ ucl::Delegate<void(ucl::Result, const std::string &path)>;
public:
- MediaItem(media_info_h info);
+ static MediaItemUPtr newInstance(media_info_h media);
virtual ~MediaItem();
bool isValid() const;
const std::string &getFilePath() const;
- ucl::Result getThumbnailPath(ThumbnailPathGetCb cb) const;
+ ucl::Result getThumbnailPath(const ThumbnailPathGetCb &cb) const;
void cancelThumbnailPathGet() const;
ucl::Result removeFile();
+ protected:
+ MediaItem(MediaType type);
+
+ ucl::Result prepare(media_info_h media);
+
+ private:
+ ucl::Result initThumbPath(media_info_h media) const;
+ void freeMediaInfo() const;
+
+ private:
+ // XXX This proxy is needed to deal with cases when
+ // media_thumbnail_completed_cb can't be cancelled
+ struct ThumbCbProxy {
+ const MediaItem *item;
+ ThumbnailPathGetCb callback;
+
+ void completeCb(media_content_error_e error, const char *path);
+ };
+
private:
const MediaType m_type;
- media_info_h m_info;
- mutable ThumbnailPathGetCb m_thumbGetCb;
- mutable std::string m_filePath;
+ std::string m_mediaId;
+ std::string m_filePath;
+ mutable media_info_h m_media;
mutable std::string m_thumbPath;
+ mutable std::unique_ptr<ThumbCbProxy> m_thumbCbProxy;
+ bool m_isValid;
};
}
VIDEO,
SOUND,
MUSIC,
- OTHER
+ OTHERS
};
+ UCL_DECLARE_REF_ALIASES(Gallery);
+
+ UCL_DECLARE_REF_ALIASES(IMediaAlbum);
+
class MediaItem;
using MediaItemUPtr = std::unique_ptr<MediaItem>;
}
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __GALLERY_COMMON_H__
#define __GALLERY_COMMON_H__
#include "model/Gallery.h"
-#include "../common.h"
+#include "GalleryAlbum.h"
+
+#include "common.h"
namespace gallery {
using namespace ucl;
- Gallery::Gallery()
+ Gallery::Gallery() :
+ m_isMediaDbConnected(false)
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
}
Gallery::~Gallery()
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ if (m_isMediaDbConnected) {
+ const int ret = media_content_disconnect();
+ if (ret != 0) {
+ WLOG("media_content_disconnect() failed: %d", ret);
+ }
+ }
+ }
+
+ GallerySRef Gallery::newInstance()
+ {
+ auto result = makeShared<Gallery>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result Gallery::prepare()
+ {
+ const int ret = media_content_connect();
+ if (ret != 0) {
+ LOG_RETURN(RES_FAIL, "media_content_connect() failed: %d", ret);
+ }
+
+ m_isMediaDbConnected = true;
+
+ m_album = GalleryAlbum::newInstance();
+ if (!m_album) {
+ LOG_RETURN(RES_FAIL, "GalleryAlbum::newInstance() failed!");
+ }
+
+ return RES_OK;
}
- IMediaAlbum &Gallery::getAlbum()
+ IMediaAlbumSRef Gallery::getAlbum()
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ return m_album;
}
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "GalleryAlbum.h"
+
+#include "model/MediaItem.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+ using namespace ucl;
+
+ const auto CONDITION = TString("%s=%d OR %s=%d").format(
+ MEDIA_TYPE, MEDIA_CONTENT_TYPE_IMAGE,
+ MEDIA_TYPE, MEDIA_CONTENT_TYPE_VIDEO);
+}}}
+
+namespace gallery {
+
+ using namespace ucl;
+
+ GalleryAlbum::GalleryAlbum() :
+ m_filter(nullptr)
+ {
+ }
+
+ GalleryAlbum::~GalleryAlbum()
+ {
+ if (m_filter) {
+ const int ret = media_filter_destroy(m_filter);
+ if (ret != 0) {
+ WLOG("media_filter_destroy() failed: %d", ret);
+ }
+ }
+ }
+
+ GalleryAlbumSRef GalleryAlbum::newInstance()
+ {
+ auto result = makeShared<GalleryAlbum>();
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+ return result;
+ }
+
+ Result GalleryAlbum::prepare()
+ {
+ int ret = 0;
+
+ ret = media_filter_create(&m_filter);
+ if (ret != 0) {
+ ELOG("media_filter_create() failed: %d", ret);
+ m_filter = nullptr;
+ return RES_FAIL;
+ }
+
+ ret = media_filter_set_condition(m_filter, impl::CONDITION,
+ MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != 0) {
+ ELOG("media_filter_set_condition() failed: %d", ret);
+ return RES_FAIL;
+ }
+
+ ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC,
+ MEDIA_ADDED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != 0) {
+ ELOG("media_filter_set_order() failed: %d", ret);
+ return RES_FAIL;
+ }
+
+ return RES_OK;
+ }
+
+ Result GalleryAlbum::forEachMedia(EachCb cb) const
+ {
+ const int ret = media_info_foreach_media_from_db(m_filter,
+ [](media_info_h media, void *user_data)
+ {
+ auto item = MediaItem::newInstance(media);
+ if (!item) {
+ ELOG("MediaItem::newInstance() failed! Skipping");
+ return true;
+ }
+ return (*static_cast<EachCb *>(user_data))(std::move(item));
+ },
+ &cb);
+
+ if (ret != 0) {
+ ELOG("media_info_foreach_media_from_db() failed: %d", ret);
+ return RES_FAIL;
+ }
+
+ return RES_OK;
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __GALLERY_MODEL_GALLERY_ALBUM_H__
+#define __GALLERY_MODEL_GALLERY_ALBUM_H__
+
+#include "model/IMediaAlbum.h"
+
+namespace gallery {
+
+ UCL_DECLARE_REF_ALIASES(GalleryAlbum);
+
+ class GalleryAlbum final : public IMediaAlbum {
+ public:
+ static GalleryAlbumSRef newInstance();
+ virtual ~GalleryAlbum();
+
+ // IMediaAlbum //
+
+ virtual ucl::Result forEachMedia(EachCb cb) const final override;
+
+ private:
+ friend class ucl::RefCountObj<GalleryAlbum>;
+ GalleryAlbum();
+
+ ucl::Result prepare();
+
+ private:
+ filter_h m_filter;
+ };
+}
+
+#endif // __GALLERY_MODEL_GALLERY_ALBUM_H__
#include "model/MediaItem.h"
-#include "../common.h"
+#include "common.h"
namespace gallery {
using namespace ucl;
- MediaItem::MediaItem(media_info_h info) :
- m_type(MediaType::OTHER)
+ MediaItem::MediaItem(const MediaType type) :
+ m_type(type),
+ m_media(nullptr),
+ m_isValid(false)
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
}
MediaItem::~MediaItem()
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ cancelThumbnailPathGet();
+ freeMediaInfo();
+ }
+
+ MediaItemUPtr MediaItem::newInstance(const media_info_h media)
+ {
+ media_content_type_e contentType = MEDIA_CONTENT_TYPE_OTHERS;
+ const int ret = media_info_get_media_type(media, &contentType);
+ if (ret != 0) {
+ LOG_RETURN_VALUE(RES_FAIL, {},
+ "media_info_get_media_type() failed: %d", ret);
+ }
+
+ MediaItemUPtr result{new MediaItem(toMediaType(contentType))};
+
+ FAIL_RETURN_VALUE(result->prepare(media), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ Result MediaItem::prepare(const media_info_h media)
+ {
+ FAIL_RETURN(initThumbPath(media), "initThumbPath() failed!");
+
+ if (isEmpty(m_thumbPath)) {
+ const int ret = media_info_clone(&m_media, media);
+ if (ret != 0) {
+ m_media = nullptr;
+ LOG_RETURN(RES_FAIL, "media_info_clone() failed: %d", ret);
+ }
+ }
+
+ if (!getProperty(media, media_info_get_media_id, m_mediaId)) {
+ LOG_RETURN(RES_FAIL, "getProperty(media_id) failed!");
+ }
+
+ if (!getProperty(media, media_info_get_file_path, m_filePath)) {
+ LOG_RETURN(RES_FAIL, "getProperty(file_path) failed!");
+ }
+
+ m_isValid = true;
+
+ return RES_OK;
+ }
+
+ Result MediaItem::initThumbPath(media_info_h media) const
+ {
+ if (!getProperty(media, media_info_get_thumbnail_path,
+ m_thumbPath, true)) {
+ LOG_RETURN(RES_FAIL, "getProperty(thumbnail_path) failed!");
+ }
+ return RES_OK;
+ }
+
+ void MediaItem::freeMediaInfo() const
+ {
+ if (m_media) {
+ const int ret = media_info_destroy(m_media);
+ if (ret != 0) {
+ WLOG("media_info_destroy() failed: %d", ret);
+ }
+ m_media = nullptr;
+ }
}
bool MediaItem::isValid() const
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ return m_isValid;
}
MediaType MediaItem::getType() const
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ return m_type;
}
const std::string &MediaItem::getFilePath() const
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ return m_filePath;
+ }
+
+ Result MediaItem::removeFile()
+ {
+ if (!ecore_file_can_write(m_filePath.c_str())) {
+ LOG_RETURN(RES_FAIL, "File can't be removed!");
+ }
+
+ const int ret = media_info_delete_from_db(m_mediaId.c_str());
+ if (ret != 0) {
+ LOG_RETURN(RES_FAIL, "media_info_delete_from_db() failed: %d", ret);
+ }
+
+ freeMediaInfo();
+ m_isValid = false;
+
+ if (!ecore_file_remove(m_filePath.c_str())) {
+ FLOG("ecore_file_remove() failed! Attemting to rescan....");
+ const int ret = media_content_scan_file(m_filePath.c_str());
+ if (ret != 0) {
+ ELOG("media_content_scan_file() failed: %d", ret);
+ }
+ return RES_FATAL;
+ }
+
+ return RES_OK;
}
- Result MediaItem::getThumbnailPath(ThumbnailPathGetCb cb) const
+ Result MediaItem::getThumbnailPath(const ThumbnailPathGetCb &cb) const
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ if (!cb) {
+ return RES_INVALID_ARGUMENTS;
+ }
+
+ if (isNotEmpty(m_thumbPath)) {
+ cb(RES_OK, m_thumbPath);
+ return RES_OK;
+ }
+
+ if (m_thumbCbProxy) {
+ m_thumbCbProxy->callback = cb;
+ return RES_FALSE;
+ }
+
+ auto cbProxy = util::makeUnique(new ThumbCbProxy{this, cb});
+
+ const int ret = media_info_create_thumbnail(m_media,
+ CALLBACK_B(ThumbCbProxy::completeCb), cbProxy.get());
+ if (ret != 0) {
+ LOG_RETURN(RES_FAIL, "media_info_clone() failed: %d", ret);
+ }
+
+ m_thumbCbProxy = std::move(cbProxy);
+
+ return RES_FALSE;
}
void MediaItem::cancelThumbnailPathGet() const
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ if (!m_thumbCbProxy) {
+ return;
+ }
+
+ const int ret = media_info_cancel_thumbnail(m_media);
+ if (ret != 0) {
+
+ // XXX In this case complete callback will be called anyway
+ // We need to report this issue to the platform
+ m_thumbCbProxy->item = nullptr;
+ m_thumbCbProxy.release();
+
+ if (ret == MEDIA_CONTENT_ERROR_INVALID_OPERATION) {
+ ILOG("Can't cancel. Thumbnail is already created.");
+ FAIL_RETURN_VOID(initThumbPath(m_media),
+ "initThumbPath() failed!");
+ return;
+ }
+
+ LOG_RETURN_VOID(RES_FAIL,
+ "media_info_cancel_thumbnail() failed: %d", ret);
+ }
+
+ m_thumbCbProxy.reset();
}
- Result MediaItem::removeFile()
+ // ThumbCbProxy //
+
+ void MediaItem::ThumbCbProxy::completeCb(
+ media_content_error_e error, const char *path)
{
- UCL_ASSERT(0, "!!! NOT IMPLEMENTED !!!");
+ if (!item) {
+ delete this;
+ return;
+ }
+
+ Result result = RES_OK;
+
+ if ((error != MEDIA_CONTENT_ERROR_NONE) || !path) {
+ ELOG("Thumbnail generation failed: %d", error);
+ result = RES_FAIL;
+ } else {
+ item->m_thumbPath = path;
+ item->freeMediaInfo();
+ }
+
+ const auto proxy = std::move(*item->m_thumbCbProxy);
+
+ item->m_thumbCbProxy.reset();
+
+ proxy.callback(result, proxy.item->m_thumbPath);
}
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __GALLERY_MODEL_COMMON_H__
+#define __GALLERY_MODEL_COMMON_H__
+
+#include "../common.h"
+
+#include "helpers.h"
+
+#endif // __GALLERY_MODEL_COMMON_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "helpers.h"
+
+#include "common.h"
+
+namespace gallery {
+
+ bool getProperty(media_info_h media,
+ int (*get)(media_info_h media, char **value),
+ std::string &result, const bool optional)
+ {
+ char *value = nullptr;
+ const int ret = get(media, &value);
+ if ((ret != 0) || (!optional && !value)) {
+ ELOG("get() failed: %d", ret);
+ return false;
+ }
+
+ if (value) {
+ result = value;
+ free(value);
+ } else {
+ result.clear();
+ }
+
+ return true;
+ }
+}
+
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __GALLERY_MODEL_HELPERS_H__
+#define __GALLERY_MODEL_HELPERS_H__
+
+#include "model/types.h"
+
+namespace gallery {
+
+ MediaType toMediaType(media_content_type_e contentType);
+
+ bool getProperty(media_info_h media,
+ int (*get)(media_info_h media, char **value),
+ std::string &result, bool optional = false);
+}
+
+#include "helpers.hpp"
+
+#endif // __GALLERY_MODEL_HELPERS_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+namespace gallery {
+
+ inline MediaType toMediaType(const media_content_type_e contentType)
+ {
+ switch (contentType) {
+ case MEDIA_CONTENT_TYPE_IMAGE: return MediaType::IMAGE;
+ case MEDIA_CONTENT_TYPE_VIDEO: return MediaType::VIDEO;
+ case MEDIA_CONTENT_TYPE_SOUND: return MediaType::SOUND;
+ case MEDIA_CONTENT_TYPE_MUSIC: return MediaType::MUSIC;
+ default:
+ break;
+ }
+ return MediaType::OTHERS;
+ }
+}
HcombInfo(const int totalLength,
const std::array<LayoutTheme, 2> &slotThemes) :
- Info(slotThemes, {(totalLength / 2), ceilDiv<2>(totalLength)},
+ Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
(totalLength - 1), true),
totalLength(totalLength)
{
switch (type) {
case Type::HCOMB_3X3:
default: {
- static HcombInfo info{3, {
- LayoutTheme(
- "layout", "gallery_image_grid", "hcomb_3x3_even"),
- LayoutTheme(
- "layout", "gallery_image_grid", "hcomb_3x3_odd")}};
+ static HcombInfo info{3, {{
+ {"layout", "gallery_image_grid", "hcomb_3x3_even"},
+ {"layout", "gallery_image_grid", "hcomb_3x3_odd"}}}};
return info;
}
}
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.gallery" version="1.0.0">
- <profile name="wearable"/>
- <ui-application appid="org.tizen.gallery" exec="gallery" hw-acceleration="on" multiple="false" nodisplay="false" splash-screen-display="false" taskmanage="true" type="capp">
- <label>gallery</label>
- <icon>org.tizen.gallery.png</icon>
- </ui-application>
-</manifest>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.gallery" version="1.0.0">\r
+ <profile name="wearable"/>\r
+ <ui-application appid="org.tizen.gallery" exec="gallery" hw-acceleration="on" multiple="false" nodisplay="false" splash-screen-display="false" taskmanage="true" type="capp">\r
+ <label>gallery</label>\r
+ <icon>org.tizen.gallery.png</icon>\r
+ </ui-application>\r
+ <privileges>\r
+ <privilege>http://tizen.org/privilege/mediastorage</privilege>\r
+ <privilege>http://tizen.org/privilege/externalstorage</privilege>\r
+ <privilege>http://tizen.org/privilege/content.write</privilege>\r
+ </privileges>\r
+</manifest>\r
template <class T>
inline SharedRef<T> RefCountAware::asShared(T &obj)
{
- return obj.asShared<typename std::remove_cv<T>::type>();
+ return obj.template asShared<typename std::remove_cv<T>::type>();
}
template <class T>
inline WeakRef<T> RefCountAware::asWeak(T &obj)
{
- return obj.asWeak<typename std::remove_cv<T>::type>();
+ return obj.template asWeak<typename std::remove_cv<T>::type>();
}
inline bool RefCountAware::isShared() const
constexpr const T &max(const T &a, const T &b);
template <class T>
- constexpr bool isPot(T value);
+ constexpr bool isPot(T value)
+ {
+ return (((value - 1) & value) == 0);
+ }
template <uint MULTIPLE, class T>
constexpr T ceilDiv(T value);
return (value ? value : zValue);
}
+ template <class T>
+ constexpr bool isNotEmpty(T &&value)
+ {
+ return !isEmpty(std::forward<T>(value));
+ }
+
constexpr const char *ne(const char *const value, const char *const eValue)
{
return (isNotEmpty(value) ? value : eValue);
return (!value || (value[0] == '\0'));
}
- template <class T>
- constexpr bool isNotEmpty(T &&value)
- {
- return !isEmpty(std::forward<T>(value));
- }
-
template <class T>
constexpr bool isNotValid(T &&value)
{
return ((a > b) ? a : b);
}
- template <class T>
- constexpr bool isPot(const T value)
- {
- return (((value - 1) & value) == 0);
- }
-
template <uint MULTIPLE, class T>
constexpr T ceilDiv(T value)
{
const ::ucl::Result __RESULT__ = (result); \
if (isBad(__RESULT__)) { \
UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
- return (value); \
+ return value; \
} \
} while (false)
do { \
const ::ucl::Result __RESULT__ = (result); \
UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \
- return (value); \
+ return value; \
} while (false)
#define UCL_LOG_RETURN_VOID(result, msg, ...) \
RES_IO_ERROR = -5,
RES_NOT_SUPPORTED = -6,
RES_INVALID_DATA = -7,
+ RES_FATAL = -8,
// TODO MUST match previous item!
- _RES_BEGIN = RES_INVALID_DATA
+ _RES_BEGIN = RES_FATAL
};
}
namespace ucl { namespace { namespace impl {
constexpr ResultData RESUT_DATA[] = {
+ {"RES_FATAL", DLOG_FATAL},
{"RES_INVALID_DATA", DLOG_ERROR},
{"RES_NOT_SUPPORTED", DLOG_ERROR},
{"RES_IO_ERROR", DLOG_ERROR},