protected:
ucl::StyledWidgetSRef m_popup;
+ private:
+ DialogSRef m_selfRef;
bool m_isDismissed;
};
}
UCL_FAIL_RETURN(onPrepare(), "onPrepare() failed!");
- m_rc->ref();
+ m_selfRef = asShared(*this);
return ucl::RES_OK;
}
const ucl::NaviframeSRef m_navi;
const ExitRequestHandler m_onExitRequest;
ucl::NaviItem m_item;
+ PageSRef m_selfRef;
};
// Non-member functions //
DismissHandler m_dismissHandler;
Ecore_Timer *m_timer;
State m_state;
+ ProcessingPresenterSRef m_selfRef;
bool m_mayComplete;
bool m_isComplete;
bool m_isDismissed;
deactivateBy(m_popup.get());
m_popup.reset();
- m_rc->unref();
+ m_selfRef.reset();
broadcastActivate();
}
m_item.setData(this);
m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
- m_rc->ref();
+ m_selfRef = asShared(*this);
if (!m_navi->isInTransition() && isAtTop()) {
dispatchTopPageChanged();
void Page::onItemDel(Evas_Object *obj, void *eventInfo)
{
m_item = nullptr;
- m_rc->unref();
+ m_selfRef.reset();
}
void Page::exit()
deactivateBy(m_popup.get());
broadcastActivate();
m_popup.reset();
- if (m_isComplete) {
- m_rc->unref();
- }
+ m_selfRef.reset();
}
}
FAIL_LOG(createIcon(), "createIcon() failed!");
}
- m_rc->ref();
+ m_selfRef = asShared(*this);
tryShowPopup();
}
GenlistItem append(const Elm_Genlist_Item_Class *itc,
const void *data, SmartCbHandler onSelect = nullptr,
- GenlistItem parent = nullptr,
- GenlistItem::Type type = GenlistItem::Type::SIMPLE);
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
GenlistItem prepend(const Elm_Genlist_Item_Class *itc,
const void *data, SmartCbHandler onSelect = nullptr,
- GenlistItem parent = nullptr,
- GenlistItem::Type type = GenlistItem::Type::SIMPLE);
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
GenlistItem insertAfter(GenlistItem after,
const Elm_Genlist_Item_Class *itc, const void *data,
SmartCbHandler onSelect = nullptr,
- GenlistItem parent = nullptr,
- GenlistItem::Type type = GenlistItem::Type::SIMPLE);
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
GenlistItem insertBefore(GenlistItem before,
const Elm_Genlist_Item_Class *itc, const void *data,
SmartCbHandler onSelect = nullptr,
- GenlistItem parent = nullptr,
- GenlistItem::Type type = GenlistItem::Type::SIMPLE);
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
};
}
inline GenlistItem Genlist::append(const Elm_Genlist_Item_Class *const itc,
const void *const data, const SmartCbHandler onSelect,
- const GenlistItem parent, const GenlistItem::Type type)
+ const GenlistItem::Type type, const GenlistItem parent)
{
return GenlistItem(elm_genlist_item_append(
getEo(), itc, data, parent,
inline GenlistItem Genlist::prepend(const Elm_Genlist_Item_Class *const itc,
const void *const data, SmartCbHandler onSelect,
- const GenlistItem parent, const GenlistItem::Type type)
+ const GenlistItem::Type type, const GenlistItem parent)
{
return GenlistItem(elm_genlist_item_prepend(
getEo(), itc, data, parent,
inline GenlistItem Genlist::insertAfter(const GenlistItem after,
const Elm_Genlist_Item_Class *const itc, const void *const data,
- const SmartCbHandler onSelect, const GenlistItem parent,
- const GenlistItem::Type type)
+ const SmartCbHandler onSelect, const GenlistItem::Type type,
+ const GenlistItem parent)
{
return GenlistItem(elm_genlist_item_insert_after(
getEo(), itc, data, parent, after,
inline GenlistItem Genlist::insertBefore(const GenlistItem before,
const Elm_Genlist_Item_Class *itc, const void *data,
- const SmartCbHandler onSelect, const GenlistItem parent,
- const GenlistItem::Type type)
+ const SmartCbHandler onSelect, const GenlistItem::Type type,
+ const GenlistItem parent)
{
return GenlistItem(elm_genlist_item_insert_before(
getEo(), itc, data, parent, before,
private:
Evas_Object *m_eo;
EventProxies m_eventProxies;
- bool m_isOwner: 1;
- bool m_isBoundToEo: 1;
- bool m_isEoRefKept: 1;
- bool m_isSelfRefKept: 1;
- bool m_isSelfRefUnique: 1;
+ WidgetSRef m_selfRef;
+ bool m_isOwner;
+ bool m_isBoundToEo;
+ bool m_isEoRefKept;
+ bool m_isSelfRefUnique;
};
// Non-member functions //
// Widget casting functions from Evas_Object //
template <class WIDGET_TYPE>
- inline auto staticCast(Evas_Object *eo) ->
+ inline auto staticWidgetCast(Evas_Object *eo) ->
decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return static_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto staticCast(const Evas_Object *eo) ->
+ inline auto staticWidgetCast(const Evas_Object *eo) ->
decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return static_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicCast(Evas_Object *eo) ->
+ inline auto dynamicWidgetCast(Evas_Object *eo) ->
decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicCast(const Evas_Object *eo) ->
+ inline auto dynamicWidgetCast(const Evas_Object *eo) ->
decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto staticRefCast(Evas_Object *eo) ->
- decltype(asShared(staticCast<WIDGET_TYPE>(eo)))
+ inline auto staticWidgetRefCast(Evas_Object *eo) ->
+ decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(staticCast<WIDGET_TYPE>(eo));
+ return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto staticRefCast(const Evas_Object *eo) ->
- decltype(asShared(staticCast<WIDGET_TYPE>(eo)))
+ inline auto staticWidgetRefCast(const Evas_Object *eo) ->
+ decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(staticCast<WIDGET_TYPE>(eo));
+ return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicRefCast(Evas_Object *eo) ->
- decltype(asShared(dynamicCast<WIDGET_TYPE>(eo)))
+ inline auto dynamicWidgetRefCast(Evas_Object *eo) ->
+ decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(dynamicCast<WIDGET_TYPE>(eo));
+ return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicRefCast(const Evas_Object *eo) ->
- decltype(asShared(dynamicCast<WIDGET_TYPE>(eo)))
+ inline auto dynamicWidgetRefCast(const Evas_Object *eo) ->
+ decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(dynamicCast<WIDGET_TYPE>(eo));
+ return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
}
}
#include "ucl/misc/Aspect.h"
#include "ucl/misc/TString.h"
+#include "ucl/misc/ConstCString.h"
#include "ucl/misc/Variant.h"
namespace ucl {
class RefCountAware : public Polymorphic {
public:
bool isShared() const;
+ UInt getUseCount() const;
+ const void *getObjPtr() const;
template <class T>
SharedRef<T> asSharedThis(T *thisAlias) const;
// Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
enum { _IS_REF_COUNT_AWARE };
- protected:
+ private:
IRefCountObj *const m_rc;
};
return !!m_rc;
}
+ inline UInt RefCountAware::getUseCount() const
+ {
+ if (!isShared()) {
+ UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+ return 0;
+ }
+ return m_rc->getUseCount();
+ }
+
+ inline const void *RefCountAware::getObjPtr() const
+ {
+ if (!isShared()) {
+ UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+ return nullptr;
+ }
+ return m_rc->getObjPtr();
+ }
+
template <class T>
inline SharedRef<T> RefCountAware::asSharedThis(T *const thisAlias) const
{
friend class WeakRef;
public:
- int getUseCount() const noexcept;
+ UInt getUseCount() const noexcept;
protected:
constexpr BaseRef() noexcept;
}
template <class T>
- inline int BaseRef<T>::getUseCount() const noexcept
+ inline UInt BaseRef<T>::getUseCount() const noexcept
{
return (m_rc ? m_rc->getUseCount() : 0);
}
virtual bool refNz() noexcept = 0;
virtual void refWeak() noexcept = 0;
virtual void unrefWeak() noexcept = 0;
- virtual unsigned getUseCount() const noexcept = 0;
+ virtual UInt getUseCount() const noexcept = 0;
virtual const void *getObjPtr() const noexcept = 0;
protected:
virtual ~IRefCountObj() = default;
virtual bool refNz() noexcept final override;
virtual void refWeak() noexcept final override;
virtual void unrefWeak() noexcept final override;
- virtual unsigned getUseCount() const noexcept final override;
+ virtual UInt getUseCount() const noexcept final override;
virtual const void *getObjPtr() const noexcept final override;
private:
}
template <class T, class C>
- inline unsigned RefCountObj<T, C>::getUseCount() const noexcept
+ inline UInt RefCountObj<T, C>::getUseCount() const noexcept
{
return m_useCounter.get();
}
Window *ElmWidget::getWindow() const
{
- return dynamicCast<Window>(getTopWidget());
+ return dynamicWidgetCast<Window>(getTopWidget());
}
}
void NaviItem::popTo() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
void NaviItem::promote() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
m_isOwner(isOwner),
m_isBoundToEo(false),
m_isEoRefKept(false),
- m_isSelfRefKept(false),
m_isSelfRefUnique(false)
{
UCL_ASSERT(m_eo, "m_eo is NULL!");
- if (m_rc) {
+ if (isShared()) {
evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL,
EO_CALLBACK_PRIORITY_AFTER,
CALLBACK_A(Widget::onEoDel), this);
unbindFromEo();
}
- if (m_rc) {
+ if (isShared()) {
evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
CALLBACK_A(Widget::onEoDel), this);
}
{
updateEoRef();
- if (m_rc) {
+ if (isShared()) {
updateSelfRef();
}
}
void Widget::updateSelfRef()
{
- if (needKeepSelfRef()) {
- if (!m_isSelfRefKept) {
- m_isSelfRefKept = true;
- m_rc->ref();
- }
- } else if (m_isSelfRefKept) {
- m_isSelfRefKept = false;
- m_rc->unref();
+ if (!needKeepSelfRef()) {
+ m_selfRef.reset();
+ } else if (!m_selfRef) {
+ m_selfRef = asShared(*this);
}
}
void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info)
{
- if (!m_isSelfRefKept) {
- FLOG("UNEXPECTED! m_isSelfRefKept: %d;", m_isSelfRefKept);
+ if (!m_selfRef) {
+ FLOG("UNEXPECTED! m_selfRef is NULL!");
m_eo = nullptr;
return;
}
m_isOwner, m_isEoRefKept, m_isSelfRefUnique);
m_eo = nullptr;
}
- m_isSelfRefKept = false;
- m_rc->unref();
+ m_selfRef.reset();
}
void Widget::onUniqueChanged(bool isUnique)
}
if (flags & PF_ADD_SELF_EXCEPT) {
- addDeactivatorException(m_rc->getObjPtr());
+ addDeactivatorException(getObjPtr());
}
m_isPrepared = true;
}
if (flags & PF_ADD_SELF_EXCEPT) {
- addDeactivatorException(m_rc->getObjPtr());
+ addDeactivatorException(getObjPtr());
}
m_window = parent.m_window;
void GuiPresenter::sendActivate(Widget &sender)
{
- sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr());
+ sendDeactivator(sender, impl::ACTIVATE_BY, getObjPtr());
}
void GuiPresenter::sendDeactivate(Widget &sender)
{
- sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr());
+ sendDeactivator(sender, impl::DEACTIVATE_BY, getObjPtr());
}
void GuiPresenter::broadcastActivate()
{
- broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr());
+ broadcastDeactivator(impl::ACTIVATE_BY, getObjPtr());
}
void GuiPresenter::broadcastDeactivate()
{
- broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr());
+ broadcastDeactivator(impl::DEACTIVATE_BY, getObjPtr());
}
void GuiPresenter::sendDeactivator(Widget &sender,