<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.299151930" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/call-ui}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.287909858" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.850939844" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.66050065" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+ <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.66050065" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1977572256" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1003532466" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.58197076" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1780411914" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_llvm40.i386.core.app"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2060575755" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.27127097" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
- <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1049599195" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+ <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1049599195" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1400861396" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1157370620" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1654013693" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.551225658" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_llvm40.i386.core.app"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1481628386" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.890993403" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1743186514" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1743878166" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+ <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1743878166" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1017885244" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.219138009" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.588492684" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
public:
virtual unsigned int getCallId() const = 0;
virtual const std::string &getPhoneNumber() const = 0;
- virtual IContactInfoWCRef getContactInfo() const = 0;
+ virtual IContactInfoSCRef getContactInfo() const = 0;
};
}
virtual bool isDisposed() const final override;
private:
- friend class ucl::RefCountObj<AcceptDialog>;
- AcceptDialog(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<AcceptDialog>;
+ AcceptDialog(ucl::IRefCountObj &rc,
const AcceptDialogHandler &handler);
ucl::Result prepare(ucl::ElmWidget &parent);
void update(CallMask calls);
private:
- friend class ucl::RefCountObj<AcceptRejectPresenter>;
- AcceptRejectPresenter(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<AcceptRejectPresenter>;
+ AcceptRejectPresenter(ucl::IRefCountObj &rc,
const IIncomingCallSRef &call,
CallMask calls);
void setMuteControlDisabled(bool isDisabled);
private:
- friend class ucl::RefCountObj<AccessoryPresenter>;
- AccessoryPresenter(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<AccessoryPresenter>;
+ AccessoryPresenter(ucl::IRefCountObj &rc,
const ISoundManagerSRef &sm);
ucl::Result prepare(ucl::ElmWidget &parent, bool isMuteControlDisabled = false);
ucl::Result update(CallMode mode, const ICallManagerSRef &cm);
private:
- friend class ucl::RefCountObj<CallInfoPresenter>;
- CallInfoPresenter(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<CallInfoPresenter>;
+ CallInfoPresenter(ucl::IRefCountObj &rc,
const ICallManagerSRef &cm,
CallMode mode);
virtual ~CallStatus();
private:
- friend class ucl::RefCountObj<CallStatus>;
- CallStatus(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<CallStatus>;
+ CallStatus(ucl::IRefCountObj &rc,
const ucl::LayoutSRef &layout,
CallMode mode,
const ICallInfoWCRef &info,
ucl::Result setCpuLockState(bool lockState);
private:
- friend class ucl::RefCountObj<DeviceStatePresenter>;
- DeviceStatePresenter(ucl::RefCountObjBase &rc,
- const ucl::WindowSRef &window);
+ friend class ucl::ReffedObj<DeviceStatePresenter>;
+ DeviceStatePresenter(const ucl::WindowSRef &window);
~DeviceStatePresenter() = default;
ucl::Result prepare(DisplayState state,
ucl::Widget &getWidget();
private:
- friend class ucl::RefCountObj<Indicator>;
- Indicator(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<Indicator>;
+ Indicator(ucl::IRefCountObj &rc,
const IIndicatorStateProviderSRef &provider);
ucl::Result prepare(ucl::ElmWidget &parent);
#include "ucl/appfw/IInstance.h"
#include "ucl/appfw/IInstanceAppControlExt.h"
+#include "ucl/appfw/SysEventProvider.h"
#include "ucl/gui/Theme.h"
#include "ucl/gui/Naviframe.h"
namespace callui {
- class Instance :
+ class Instance final : public ucl::RefCountAware,
public ucl::IInstance,
public ucl::IInstanceAppControlExt {
public:
- Instance(ucl::SysEventProvider &sysEventProvider);
+ Instance(ucl::IRefCountObj &rc,
+ ucl::SysEventProvider &sysEventProvider);
virtual ~Instance();
// IInstance //
};
private:
- friend class ucl::RefCountObj<KeypadPage>;
- KeypadPage(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<KeypadPage>;
+ KeypadPage(ucl::IRefCountObj &rc,
const ucl::NaviframeSRef &navi,
const ExitRequestHandler onExitRequest);
virtual ~KeypadPage();
};
private:
- friend class ucl::RefCountObj<MainPage>;
- MainPage(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<MainPage>;
+ MainPage(ucl::IRefCountObj &rc,
const ucl::NaviframeSRef &navi,
const ExitRequestHandler handler,
const ICallSRef &call);
void update();
private:
- friend class ucl::RefCountObj<MoreOptionsPresenter>;
- MoreOptionsPresenter(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<MoreOptionsPresenter>;
+ MoreOptionsPresenter(ucl::IRefCountObj &rc,
const ICallManagerSRef &cm,
const ISoundManagerSRef &sm,
const ucl::NaviframeSRef &navi);
ICallManagerSRef m_cm;
ISoundManagerSRef m_sm;
- ucl::NaviframeWRef m_navi;
+ ucl::NaviframeSRef m_navi;
ICallInfoWCRef m_info;
ucl::NaviItem insertBefore(ARGS &&...args);
protected:
- Page(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
+ Page(ucl::IRefCountObj &rc, const ucl::NaviframeSRef &navi,
ExitRequestHandler onExitRequest);
virtual ~Page();
void deactivateBy(void *deactivator);
protected:
- Presenter(ucl::RefCountObjBase &rc);
+ Presenter(ucl::IRefCountObj &rc);
virtual ~Presenter();
ucl::Result prepare(ucl::ElmWidget &widget);
class RejectMsgItem;
private:
- friend class ucl::RefCountObj<RejectMsgPresenter>;
- RejectMsgPresenter(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<RejectMsgPresenter>;
+ RejectMsgPresenter(ucl::IRefCountObj &rc,
const IRejectMsgProviderSRef &provider,
const RejectMsgStateHandler &stateHandler,
const RejectMsgSelectHandler &selectHandler);
virtual void setMaxValue(int maxValue);
protected:
- friend class ucl::RefCountObj<Slider>;
- Slider(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<Slider>;
+ Slider(ucl::IRefCountObj &rc,
const ucl::LayoutSRef &layout,
int maxValue,
int curValue);
void prepare(int maxValue, int curValue);
protected:
- ucl::LayoutWRef m_layout;
+ ucl::Layout *m_layout;
ucl::Layout m_circleLy;
Eext_Circle_Surface *m_circleSurf;
ucl::ElmWidget m_slider;
#ifndef __CALLUI_VIEW_VOLUME_CONTROL_H__
#define __CALLUI_VIEW_VOLUME_CONTROL_H__
-#include <view/Slider.h>
+#include "view/Slider.h"
+
#include "ucl/gui/StyledWidget.h"
#include "ucl/gui/Layout.h"
virtual void setValue(int value) override final;
private:
- friend class ucl::RefCountObj<VolumeControl>;
- VolumeControl(ucl::RefCountObjBase &rc,
+ friend class ucl::ReffedObj<VolumeControl>;
+ VolumeControl(ucl::IRefCountObj &rc,
const ucl::LayoutSRef &layout,
const ucl::TString &info,
int maxValue,
Result ActiveCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(m_cm->getCallClient(),
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
callData,
- m_cm->getContactInfoProvider());
+ cm->getContactInfoProvider());
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
Result ActiveCall::hold()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_hold_call(m_cm->getCallClient()));
+
+ return convertCMResult(cm_hold_call(cm->getCallClient()));
}
Result ActiveCall::end()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
if (m_isDialing) {
- return m_cm->endCall(m_callInfo->getCallId(),
+ return cm->endCall(m_callInfo->getCallId(),
CallReleaseType::BY_CALL_HANDLE);
}
- return m_cm->endCall(0, CallReleaseType::ALL_ACTIVE);
+ return cm->endCall(0, CallReleaseType::ALL_ACTIVE);
}
Result ActiveCall::split(const IConferenceCallInfoSCRef &confCallInfo)
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return m_cm->splitCalls(m_callInfo, confCallInfo);
+ return cm->splitCalls(m_callInfo, confCallInfo);
}
}
virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
private:
- friend class ucl::RefCountObj<ActiveCall>;
+ friend class ucl::ReffedObj<ActiveCall>;
ActiveCall(CallManagerWRef cm, cm_call_data_h callData);
ucl::Result prepare(cm_call_data_h callData);
virtual void setStateChangeHandler(StateChangeHandler handler) override final;
private:
- friend class ucl::RefCountObj<BatteryStateSource>;
+ friend class ucl::ReffedObj<BatteryStateSource>;
BatteryStateSource();
ucl::Result prepare();
void setVolumeStateHandler(const BluetoothVolumeHandler &handler);
private:
- friend class ucl::RefCountObj<BluetoothVolume>;
+ friend class ucl::ReffedObj<BluetoothVolume>;
BluetoothVolume();
~BluetoothVolume();
using namespace ucl;
- Call::Call(RefCountObjBase &rc):
+ Call::Call(IRefCountObj &rc):
RefCountAware(&rc)
{
}
updateSimSlotStateSource();
updateHdVoiceStateSource();
- if (m_listener) {
- m_listener->onCallEvent(type);
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(type);
}
}
break;
}
- if (m_listener) {
- m_listener->onError(callErr);
+ if (const auto listener = m_listener.lock()) {
+ listener->onError(callErr);
}
}
private:
friend class CallBuilder;
- friend class ucl::RefCountObj<Call>;
- Call(ucl::RefCountObjBase &rc);
+ friend class ucl::ReffedObj<Call>;
+ Call(ucl::IRefCountObj &rc);
ucl::Result prepare();
operator cm_client_h() const;
private:
- friend class ucl::RefCountObj<CallClient>;
+ friend class ucl::ReffedObj<CallClient>;
CallClient();
ucl::Result prepare();
return m_phoneNum;
}
- IContactInfoWCRef CallInfo::getContactInfo() const
+ IContactInfoSCRef CallInfo::getContactInfo() const
{
return m_contactInfo;
}
virtual unsigned int getCallId() const override final;
virtual const std::string &getPhoneNumber() const override final;
- virtual IContactInfoWCRef getContactInfo() const override final;
+ virtual IContactInfoSCRef getContactInfo() const override final;
virtual struct tm getDuration() const override final;
virtual bool isEmergency() const override final;
virtual bool isHDVoice() const override final;
virtual const ConfMemberList &getConferenceMemberList() const override final;
private:
- friend class ucl::RefCountObj<CallInfo>;
+ friend class ucl::ReffedObj<CallInfo>;
CallInfo();
ucl::Result prepare(CallClient &client,
using namespace ucl;
- CallManager::CallManager(RefCountObjBase &rc,
+ CallManager::CallManager(IRefCountObj &rc,
const CallClientSRef &callClient,
ICallManagerListenerWRef listener):
RefCountAware(&rc),
return;
}
- if (m_listener) {
- m_listener->onCallEvent(type);
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(type);
}
}
break;
}
- if (m_listener) {
- m_listener->onError(err);
+ if (const auto listener = m_listener.lock()) {
+ listener->onError(err);
}
}
if (m_slot == SimSlot::UNDEFINED) {
m_slot = slot;
}
- if (m_listener) {
- m_listener->onCallEvent(CallEventType::INCOMING);
+ if (const auto listener = m_listener.lock()) {
+ listener->onCallEvent(CallEventType::INCOMING);
}
return RES_OK;
}
virtual CallMask getAvailableCalls() const override final;
private:
- friend class ucl::RefCountObj<CallManager>;
- CallManager(ucl::RefCountObjBase &rc, const CallClientSRef &callClient,
+ friend class ucl::ReffedObj<CallManager>;
+ CallManager(ucl::IRefCountObj &rc, const CallClientSRef &callClient,
ICallManagerListenerWRef listener);
ucl::Result prepare();
return m_phoneNum;
}
- IContactInfoWCRef ConferenceCallInfo::getContactInfo() const
+ IContactInfoSCRef ConferenceCallInfo::getContactInfo() const
{
return m_contactInfo;
}
virtual unsigned int getCallId() const override final;
virtual const std::string &getPhoneNumber() const override final;
- virtual IContactInfoWCRef getContactInfo() const override final;
+ virtual IContactInfoSCRef getContactInfo() const override final;
private:
- friend class ucl::RefCountObj<ConferenceCallInfo>;
+ friend class ucl::ReffedObj<ConferenceCallInfo>;
ConferenceCallInfo();
ucl::Result prepare(cm_conf_call_data_t *confCallData,
virtual void setStateChangeHandler(StateChangeHandler handler) override final;
private:
- friend class ucl::RefCountObj<ConnectionStateSource>;
+ friend class ucl::ReffedObj<ConnectionStateSource>;
ConnectionStateSource();
ucl::Result prepare();
virtual ContactNameSourceType getNameSourceType() const override final;
private:
- friend class ucl::RefCountObj<ContactInfo>;
+ friend class ucl::ReffedObj<ContactInfo>;
ContactInfo(int personId,
const std::string &name,
const std::string &imagePath,
ContactInfoSRef createContactInfo(int contactId);
private:
- friend class ucl::RefCountObj<ContactInfoProvider>;
+ friend class ucl::ReffedObj<ContactInfoProvider>;
ContactInfoProvider();
ucl::Result prepare();
LOG_RETURN(RES_OK, "Callback already in progress");
}
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- auto res = m_cm->dialVoiceCall(m_callInfo->getPhoneNumber());
+ auto res = cm->dialVoiceCall(m_callInfo->getPhoneNumber());
if (res == RES_OK) {
m_callbackInProgress = true;
}
virtual ucl::Result writeMessage() override final;
private:
- friend class ucl::RefCountObj<EndCall>;
+ friend class ucl::ReffedObj<EndCall>;
EndCall(CallManagerWRef cm, ICallInfoSCRef callInfo);
ucl::Result prepare();
Result HeldCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(m_cm->getCallClient(),
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
callData,
- m_cm->getContactInfoProvider());
+ cm->getContactInfoProvider());
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
Result HeldCall::unhold()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_unhold_call(m_cm->getCallClient()));
+ return convertCMResult(cm_unhold_call(cm->getCallClient()));
}
Result HeldCall::joinWithActive()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_join_call(m_cm->getCallClient()));
+ return convertCMResult(cm_join_call(cm->getCallClient()));
}
Result HeldCall::swapWithActive()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_swap_call(m_cm->getCallClient()));
+ return convertCMResult(cm_swap_call(cm->getCallClient()));
}
Result HeldCall::end()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return m_cm->endCall(0, CallReleaseType::ALL_HOLD);
+ return cm->endCall(0, CallReleaseType::ALL_HOLD);
}
Result HeldCall::split(const IConferenceCallInfoSCRef &confCallInfo)
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return m_cm->splitCalls(m_callInfo, confCallInfo);
+ return cm->splitCalls(m_callInfo, confCallInfo);
}
}
virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) override final;
private:
- friend class ucl::RefCountObj<HeldCall>;
+ friend class ucl::ReffedObj<HeldCall>;
HeldCall(CallManagerWRef cm, cm_call_data_h callData);
ucl::Result prepare(cm_call_data_h callData);
Result IncomingCall::prepare(cm_call_data_h callData)
{
- m_callInfo = CallInfo::newInstance(m_cm->getCallClient(),
+ const auto cm = m_cm.lock();
+ if (!cm) {
+ LOG_RETURN(RES_FAIL, "Call Manager is NULL");
+ }
+ m_callInfo = CallInfo::newInstance(cm->getCallClient(),
callData,
- m_cm->getContactInfoProvider());
+ cm->getContactInfoProvider());
if (!m_callInfo) {
LOG_RETURN_VALUE(RES_FAIL, RES_FAIL, "CallInfo::newInstance() failed!");
}
IRejectMsgProviderSRef IncomingCall::getRejectMsgProvider() const
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Call Manager is NULL");
}
- return m_cm->getRejectMsgProvider();
+ return cm->getRejectMsgProvider();
}
Result IncomingCall::answer(CallAnswerType type)
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_answer_call(m_cm->getCallClient(), convertCUICallAnswerType(type)));
+ return convertCMResult(cm_answer_call(cm->getCallClient(), convertCUICallAnswerType(type)));
}
Result IncomingCall::reject()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_reject_call(m_cm->getCallClient()));
+ return convertCMResult(cm_reject_call(cm->getCallClient()));
}
Result IncomingCall::rejectWithMessage(IRejectMsgSRef message)
LOG_RETURN(RES_FAIL, "message is not RejectMsg type!");
}
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return msg->send(m_callInfo->getPhoneNumber(), m_cm->getSimSlot());
+ return msg->send(m_callInfo->getPhoneNumber(), cm->getSimSlot());
}
Result IncomingCall::stopAlert()
{
- if (!m_cm) {
+ const auto cm = m_cm.lock();
+ if (!cm) {
LOG_RETURN(RES_FAIL, "Call Manager is NULL");
}
- return convertCMResult(cm_stop_alert(m_cm->getCallClient()));
+ return convertCMResult(cm_stop_alert(cm->getCallClient()));
}
}
virtual ucl::Result stopAlert() override final;
private:
- friend class ucl::RefCountObj<IncomingCall>;
+ friend class ucl::ReffedObj<IncomingCall>;
IncomingCall(CallManagerWRef cm, cm_call_data_h callData);
ucl::Result prepare(cm_call_data_h callData);
class IndicatorStateProvider::SourceHandler :
public RefCountAware {
public:
- SourceHandler(RefCountObjBase &rc,
+ SourceHandler(IRefCountObj &rc,
IndicatorStateProvider &provider,
IndicatorProperty property,
IIndicatorStateSourceSRef source):
void IndicatorStateProvider::dispatchStateChanged(IndicatorProperty property) const
{
- if (m_listener) {
- m_listener->onStateChanged(property);
+ if (const auto listener = m_listener.lock()) {
+ listener->onStateChanged(property);
}
}
virtual void setListener(IIndicatorStateListenerWRef listener) override final;
private:
- friend class ucl::RefCountObj<IndicatorStateProvider>;
+ friend class ucl::ReffedObj<IndicatorStateProvider>;
IndicatorStateProvider();
void dispatchStateChanged(IndicatorProperty property) const;
operator msg_handle_t() const;
private:
- friend class ucl::RefCountObj<MsgClient>;
+ friend class ucl::ReffedObj<MsgClient>;
MsgClient();
ucl::Result prepare();
LOG_RETURN(RES_FAIL, "Phone Number is NULL");
}
- if (!m_msgClient) {
+ const auto msgClient = m_msgClient.lock();
+ if (!msgClient) {
LOG_RETURN(RES_FAIL, "Client is NULL");
}
msg_set_struct_handle(reqInfo, MSG_REQUEST_SENDOPT_HND, sendOpt);
// Send message
- int err = msg_sms_send_message(*m_msgClient, reqInfo);
+ int err = msg_sms_send_message(*msgClient, reqInfo);
if (err != MSG_SUCCESS) {
ELOG("msg_sms_send_message() failed. err[%d]", err);
} else {
std::string getText() const override final;
private:
- friend class ucl::RefCountObj<RejectMsg>;
+ friend class ucl::ReffedObj<RejectMsg>;
RejectMsg(MsgClientWRef client, const ucl::TString &string);
ucl::Result prepare();
virtual int getMsgCount() const override final;
private:
- friend class ucl::RefCountObj<RejectMsgProvider>;
+ friend class ucl::ReffedObj<RejectMsgProvider>;
RejectMsgProvider();
ucl::Result prepare();
virtual void setStateChangeHandler(StateChangeHandler handler) override final;
private:
- friend class ucl::RefCountObj<RssiStateSource>;
+ friend class ucl::ReffedObj<RssiStateSource>;
RssiStateSource();
ucl::Result prepare();
using namespace ucl;
- SoundManager::SoundManager(RefCountObjBase &rc,
- const CallClientSRef &client):
- RefCountAware(&rc),
- m_client(client),
- m_deviceVolumeCbID(-1)
+ SoundManager::SoundManager(IRefCountObj &rc, const CallClientSRef &client):
+ RefCountAware(&rc),
+ m_client(client),
+ m_deviceVolumeCbID(-1)
{
}
virtual bool isBluetoothSupported() const override final;
private:
- friend class ucl::RefCountObj<SoundManager>;
- SoundManager(ucl::RefCountObjBase &rc,
- const CallClientSRef &client);
+ friend class ucl::ReffedObj<SoundManager>;
+ SoundManager(ucl::IRefCountObj &rc, const CallClientSRef &client);
ucl::Result prepare();
ucl::Result registerVolumeCallbacks();
#include "model/types.h"
#include "ucl/misc/Event.h"
-#include "ucl/misc/smartDelegation.h"
+#include "ucl/util/smartDelegation.h"
namespace callui {
return result;
}
- AcceptDialog::AcceptDialog(RefCountObjBase &rc,
+ AcceptDialog::AcceptDialog(IRefCountObj &rc,
const AcceptDialogHandler &handler):
Presenter(rc),
m_handler(handler),
// IncomingCallPresenter
- AcceptRejectPresenter::AcceptRejectPresenter(RefCountObjBase &rc,
+ AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
const IIncomingCallSRef &call,
CallMask calls):
Presenter(rc),
AcceptRejectPresenter::~AcceptRejectPresenter()
{
- if (m_popup) {
- m_popup->dispose();
+ if (const auto popup = m_popup.lock()) {
+ popup->dispose();
}
delRotaryEventHandler(
{
if (m_callMask != calls) {
m_callMask = calls;
- if (m_popup) {
+ if (const auto popup = m_popup.lock()) {
m_accept->emit(impl::SIGNAL_RESET);
m_widget->emit(impl::SIGNAL_RESET);
- m_popup->dismiss();
+ popup->dismiss();
}
}
}
return result;
}
- AccessoryPresenter::AccessoryPresenter(RefCountObjBase &rc,
+ AccessoryPresenter::AccessoryPresenter(IRefCountObj &rc,
const ISoundManagerSRef &sm):
Presenter(rc),
m_sm(sm),
return result;
}
- CallInfoPresenter::CallInfoPresenter(RefCountObjBase &rc,
+ CallInfoPresenter::CallInfoPresenter(IRefCountObj &rc,
const ICallManagerSRef &cm,
CallMode mode):
Presenter(rc),
}
- CallStatus::CallStatus(RefCountObjBase &rc,
+ CallStatus::CallStatus(IRefCountObj &rc,
const LayoutSRef &layout,
CallMode mode,
const ICallInfoWCRef &info,
Result CallStatus::processOutgoingMode()
{
- m_duration = m_info->getDuration();
-
m_ly->setText(STR_DIALING_CALL, impl::PART_TXT_TEXT_INFO);
// TODO: need add logic for RTL mode in the future
Eina_Bool CallStatus::onCallDurationTimerCb()
{
- if (!m_info) {
+ const auto info = m_info.lock();
+ if (!info) {
m_timer = nullptr;
LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
}
- struct tm tmp = m_info->getDuration();
+ struct tm tmp = info->getDuration();
tryUpdateCallDurationTime(
m_duration,
tmp,
if (m_isOnHold) {
m_ly->setText(STR_ON_HOLD, impl::PART_TXT_TEXT_INFO);
} else {
- m_duration = m_info->getDuration();
+ if (const auto info = m_info.lock()) {
+ m_duration = info->getDuration();
+ }
setCallDuration(m_duration, *m_ly, impl::PART_TXT_TEXT_INFO);
if (m_timer) {
m_timer = nullptr;
}
- m_duration = m_info->getDuration();
+ if (const auto info = m_info.lock()) {
+ m_duration = info->getDuration();
+ }
m_timer = ecore_timer_add(impl::END_CALL_BLINKING_TIMER_INTERVAL,
CALLBACK_B(CallStatus::onBlinkingTimerCb), this);
// DeviceStatePresenter
- DeviceStatePresenter::DeviceStatePresenter(RefCountObjBase &rc,
- const ucl::WindowSRef &window):
- m_window(window),
- m_mode(DisplayMode::UNDEFINED),
- m_lockState(false)
+ DeviceStatePresenter::DeviceStatePresenter(const ucl::WindowSRef &window):
+ m_window(window),
+ m_mode(DisplayMode::UNDEFINED),
+ m_lockState(false)
{
}
return result;
}
- Indicator::Indicator(RefCountObjBase &rc,
+ Indicator::Indicator(IRefCountObj &rc,
const IIndicatorStateProviderSRef &provider):
Presenter(rc),
m_provider(provider)
using namespace ucl;
- Instance::Instance(SysEventProvider &sysEventProvider) :
+ Instance::Instance(IRefCountObj &rc,
+ SysEventProvider &sysEventProvider) :
+ RefCountAware(&rc),
m_sysEventProvider(sysEventProvider),
m_context(nullptr),
m_keyUpEventHandler(nullptr)
ecore_event_handler_del(m_keyUpEventHandler);
}
- if (m_page) {
- m_page->exitNoTransition();
+ if (const auto page = m_page.lock()) {
+ page->exitNoTransition();
}
}
"createCircleSurface() failed!");
m_sysEventProvider.addEventHandler(
- DELEGATE(Instance::onSysEvent, this));
+ WEAK_DELEGATE(Instance::onSysEvent, asWeak(*this)));
return RES_OK;
}
// KeypadPage
- KeypadPage::KeypadPage(RefCountObjBase &rc,
+ KeypadPage::KeypadPage(IRefCountObj &rc,
const NaviframeSRef &navi,
const ExitRequestHandler onExitRequest):
Page(rc, navi, onExitRequest)
// MainPage
- MainPage::MainPage(RefCountObjBase &rc,
+ MainPage::MainPage(IRefCountObj &rc,
const NaviframeSRef &navi,
const ExitRequestHandler handler,
const ICallSRef &call) :
// MoreOptionsPresenter
- MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc,
+ MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
const ICallManagerSRef &cm,
const ISoundManagerSRef &sm,
const NaviframeSRef &navi):
m_sm->removeAudioStateHandler(DELEGATE(
MoreOptionsPresenter::onAudioStateChanged, this));
- if (m_keypad) {
- m_keypad->exitNoTransition();
+ if (const auto keypad = m_keypad.lock()) {
+ keypad->exitNoTransition();
}
}
m_panelLy->emit(impl::SIGNAL_STATUS_TXT_BIG);
return;
}
- m_info = active->getInfo();
- if (!m_info) {
+ auto info = active->getInfo();
+ if (!info) {
LOG_RETURN_VOID(RES_FAIL, "Call Info is NULL");
}
- m_duration = m_info->getDuration();
+ m_info = info;
+ m_duration = info->getDuration();
setCallDuration(m_duration, *m_panelLy, impl::PART_TXT_STATUS);
updateStatusFontSize();
Eina_Bool MoreOptionsPresenter::onCallDurationTimerCb()
{
- if (!m_info) {
+ const auto info = m_info.lock();
+ if (!info) {
m_timer = nullptr;
LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL");
}
- struct tm tmp = m_info->getDuration();
+ struct tm tmp = info->getDuration();
tryUpdateCallDurationTime(
m_duration,
tmp,
using namespace ucl;
- Page::Page(RefCountObjBase &rc, const NaviframeSRef &navi,
+ Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
const ExitRequestHandler onExitRequest) :
Presenter(rc),
m_navi(navi),
using namespace ucl;
- Presenter::Presenter(RefCountObjBase &rc) :
+ Presenter::Presenter(IRefCountObj &rc) :
RefCountAware(&rc),
m_isPrepared(false)
{
return result;
}
- RejectMsgPresenter::RejectMsgPresenter(RefCountObjBase &rc,
+ RejectMsgPresenter::RejectMsgPresenter(IRefCountObj &rc,
const IRejectMsgProviderSRef &provider,
const RejectMsgStateHandler &stateHandler,
const RejectMsgSelectHandler &selectHandler):
* limitations under the License.
*/
-#include <view/Slider.h>
+#include "view/Slider.h"
#include "common.h"
return result;
}
- Slider::Slider(RefCountObjBase &rc,
+ Slider::Slider(IRefCountObj &rc,
const LayoutSRef &layout,
int maxValue,
int curValue):
ElmWidget(&rc, *layout, true),
- m_layout(layout),
+ m_layout(layout.get()),
m_circleLy(elm_layout_add(*m_layout)),
m_circleSurf(eext_circle_surface_layout_add(m_circleLy)),
m_slider(eext_circle_object_slider_add(*m_layout, m_circleSurf))
return result;
}
- VolumeControl::VolumeControl(RefCountObjBase &rc,
+ VolumeControl::VolumeControl(IRefCountObj &rc,
const LayoutSRef &layout,
const TString &info,
int maxValue,
namespace ucl {
+ class SysEventProvider;
+ using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
+
class SysEventProvider : public NonCopyable {
public:
using EventHandlerAddFunc = int (*)(app_event_handler_h *,
EventHandlerDelFunc delFunc);
~SysEventProvider();
- void addEventHandler(SysEventHandler handler);
- void delEventHandler(SysEventHandler handler);
+ void addEventHandler(const SysEventHandler &handler);
+ void delEventHandler(const SysEventHandler &handler);
private:
int addEventHandler(app_event_handler_h *handler,
namespace ucl {
- inline void SysEventProvider::addEventHandler(SysEventHandler handler)
+ inline void SysEventProvider::addEventHandler(
+ const SysEventHandler &handler)
{
m_event += handler;
}
- inline void SysEventProvider::delEventHandler(SysEventHandler handler)
+ inline void SysEventProvider::delEventHandler(
+ const SysEventHandler &handler)
{
m_event -= handler;
}
#include "ucl/util/types.h"
#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
#include "ucl/misc/HashMap.h"
#include "ucl/misc/Event.h"
+#include "ucl/misc/AutoHandle.h"
namespace ucl {
using AppParams = HashMap<AppParam, Variant>;
- class SysEventProvider;
- using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
-
enum class SysEvent {
LANGUAGE_CHANGED,
REGION_FMT_CHANGED,
UPDATE_REQUESTED
};
- using SysEventHandler = Delegate<void(SysEvent)>;
+ using SysEventHandler = WeakDelegate<void(SysEvent)>;
+
+ using AutoAppCtrl = AutoHandle<app_control_h, int, app_control_destroy>;
}
#endif // __UCL_APPFW_TYPES_H__
EdjeSignalSrc(""));
protected:
- EdjeWidget(RefCountObjBase *rc, Evas_Object *eo, bool isOwner = false);
+ EdjeWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = false);
};
}
namespace ucl {
- inline EdjeWidget::EdjeWidget(RefCountObjBase *const rc,
+ inline EdjeWidget::EdjeWidget(IRefCountObj *const rc,
Evas_Object *const eo, const bool isOwner) :
ElmWidget(rc, eo, isOwner)
{
#include "Widget.h"
+#define UCL_SMART_FWD_ATSPI UCL_SMART_FWD "atspi,"
+
namespace ucl {
+ constexpr SmartEvent ATSPI_ON_GESTURE {UCL_SMART_FWD_ATSPI "gesture"};
+
class Window;
UCL_DECLARE_REF_ALIASES(ElmWidget);
class ElmWidget : public Widget {
public:
- friend class RefCountObj<ElmWidget>;
- using Widget::Widget;
+ explicit ElmWidget(Evas_Object *eo, bool isOwner = false);
+ virtual ~ElmWidget();
void setEnabled(bool value);
bool isEnabled() const;
Window *getWindow() const;
protected:
+ friend class ReffedObj<ElmWidget>;
+ ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = false);
+
virtual void setFocusedImpl(bool value) final override;
virtual bool isFocusedImpl() const final override;
+ virtual bool ensureFwdEvent(SmartEvent fwdEvent) override;
+
+ private:
+ Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+ Evas_Object *obj);
+
+ private:
+ bool m_isAtspiGestureCbSet;
};
// Non-member functions //
namespace ucl {
+ inline ElmWidget::ElmWidget(Evas_Object *const eo, const bool isOwner) :
+ ElmWidget(nullptr, eo, isOwner)
+ {
+ }
+
inline void ElmWidget::setEnabled(const bool value)
{
elm_object_disabled_set(getEo(), toEina(!value));
};
public:
- friend class RefCountObj<Layout>;
+ friend class ReffedObj<Layout>;
using EdjeWidget::EdjeWidget;
explicit Layout(Evas_Object *eo, bool isOwner = false);
std::vector<NaviItem> getItems() const;
private:
- friend class RefCountObj<Naviframe>;
- Naviframe(RefCountObjBase &rc, Evas_Object *eo);
+ friend class ReffedObj<Naviframe>;
+ Naviframe(IRefCountObj &rc, Evas_Object *eo);
void onTransitionFinished(Widget &widget, void *eventInfo);
class StyledWidget : public EdjeWidget {
public:
- friend class RefCountObj<StyledWidget>;
+ friend class ReffedObj<StyledWidget>;
using EdjeWidget::EdjeWidget;
explicit StyledWidget(Evas_Object *eo, bool isOwner = false);
#include "ucl/misc/RefCountAware.h"
+#define UCL_SMART_FWD "ucl,fwd,"
+
namespace ucl {
UCL_DECLARE_REF_ALIASES(Widget);
bool isFocused() const;
protected:
- friend class RefCountObj<Widget>;
- Widget(RefCountObjBase *rc, Evas_Object *eo, bool isOwner = false);
+ friend class ReffedObj<Widget>;
+ Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = false);
virtual void setFocusedImpl(bool value);
virtual bool isFocusedImpl() const;
+ virtual bool ensureFwdEvent(SmartEvent fwdEvent);
private:
class EventProxy;
void delEventProxy(const EventProxiesIt it);
+ public:
+ // This section MUST be public!
+ // Signal to RefCountObj<T, C> to call onUniqueChanged()
+ enum { _ENABLE_ON_UNIQUE_CHANGED_DISPATCH };
+
protected:
- // This section MUST be protected!
- // Signal to RefCountObj<T> to call onUniqueChanged()
- enum { ENABLE_ON_UNIQUE_CHANGED_DISPATCH };
+ // This section MAY be protected
void onUniqueChanged(bool isUnique);
private:
Evas_Object *m_eo;
EventProxies m_eventProxies;
- bool m_isOwner;
- bool m_isBoundToEo;
- bool m_isEoRefKept;
- bool m_isSelfRefKept;
- bool m_isSelfRefUnique;
+ bool m_isOwner: 1;
+ bool m_isBoundToEo: 1;
+ bool m_isEoRefKept: 1;
+ bool m_isSelfRefKept: 1;
+ bool m_isSelfRefUnique: 1;
};
// Non-member functions //
void lower();
private:
- friend class RefCountObj<Window>;
- Window(RefCountObjBase *rc, Evas_Object *eo,
+ friend class ReffedObj<Window>;
+ Window(IRefCountObj *rc, Evas_Object *eo,
bool isOwner, Evas_Object *conform);
private:
// Window //
- inline Window::Window(RefCountObjBase *const rc, Evas_Object *const eo,
+ inline Window::Window(IRefCountObj *const rc, Evas_Object *const eo,
const bool isOwner, Evas_Object *const conform) :
ElmWidget(rc, eo, isOwner),
m_conform(conform)
#include "ucl/util/types.h"
#include "ucl/util/memory.h"
#include "ucl/util/delegation.h"
+#include "ucl/util/smartDelegation.h"
-#include "ucl/misc/smartDelegation.h"
#include "ucl/misc/Aspect.h"
#include "ucl/misc/TString.h"
#include "ucl/misc/Variant.h"
IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
};
+ // AtspiGestureEventInfo //
+
+ struct AtspiGestureEventInfo {
+ Elm_Atspi_Gesture_Info gestureInfo;
+ bool preventDefault;
+ bool stopPropagation;
+ };
+
// WidgetARHint //
enum class WidgetARHint
--- /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 __UCL_MISC_AUTO_HANDLE_H__
+#define __UCL_MISC_AUTO_HANDLE_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+ template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+ struct AutoHandle final : ucl::NonCopyable {
+ using Handle = HANDLE;
+
+ HANDLE value;
+
+ AutoHandle() :
+ value()
+ {
+ }
+
+ AutoHandle(std::nullptr_t) :
+ AutoHandle()
+ {
+ }
+
+ AutoHandle(HANDLE value) :
+ value(value)
+ {
+ }
+
+ ~AutoHandle()
+ {
+ if (value) {
+ DEL_FUNC(value);
+ }
+ }
+
+ AutoHandle(AutoHandle &&src) :
+ value(src.value)
+ {
+ src.value = nullptr;
+ }
+
+ AutoHandle &operator=(AutoHandle src)
+ {
+ swap(*this, src);
+ return *this;
+ }
+
+ AutoHandle &operator=(HANDLE value)
+ {
+ AutoHandle src{value};
+ swap(*this, src);
+ return *this;
+ }
+
+ HANDLE *operator&()
+ {
+ return &value;
+ }
+
+ operator HANDLE()
+ {
+ return value;
+ }
+ };
+
+ // Non-member functions //
+
+ template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
+ inline void swap(AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &x,
+ AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &y) noexcept
+ {
+ std::swap(x.value, y.value);
+ }
+}
+
+#endif // __UCL_MISC_AUTO_HANDLE_H__
template <class DELEGATE2>
void Event<DELEGATE>::operator+=(DELEGATE2 &&delegate)
{
- if (delegate && std::find(m_delegates.begin(), m_delegates.end(),
- delegate) == m_delegates.end()) {
- m_delegates.emplace_back(std::forward<DELEGATE2>(delegate));
- }
+ m_delegates.emplace_back(std::forward<DELEGATE2>(delegate));
}
template <class DELEGATE>
template <class DELEGATE>
bool Event<DELEGATE>::isEmpty() const
{
- return (isLocked() ? false : m_delegates.empty());
+ return m_delegates.empty();
}
template <class DELEGATE>
WeakRef<T> asWeakThis(T *thisAlias) const;
protected:
- RefCountAware(RefCountObjBase *rc);
+ RefCountAware(IRefCountObj *rc);
virtual ~RefCountAware() = default;
+ public:
+ // This section MUST be public!
+ // Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
+ enum { _IS_REF_COUNT_AWARE };
+
protected:
- RefCountObjBase *const m_rc;
+ IRefCountObj *const m_rc;
};
// Non-member functions //
namespace ucl {
- inline RefCountAware::RefCountAware(RefCountObjBase *const rc) :
+ inline RefCountAware::RefCountAware(IRefCountObj *const rc) :
m_rc(rc)
{
}
--- /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 __UCL_MISC_TIMEOUT_H__
+#define __UCL_MISC_TIMEOUT_H__
+
+#include <Ecore.h>
+
+#include "ucl/util/types.h"
+#include "ucl/util/smartDelegation.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(Timeout);
+
+ class Timeout final : public NonCopyable {
+ public:
+ using TimeoutHandler = WeakDelegate<void(Timeout *sender)>;
+
+ public:
+ static TimeoutSRef create(double timeoutSec,
+ const TimeoutHandler &handler);
+
+ bool isExpired() const;
+
+ private:
+ friend class ReffedObj<Timeout>;
+ Timeout(const TimeoutHandler &handler);
+ ~Timeout();
+
+ Result prepare(double timeoutSec);
+
+ Eina_Bool onTimer();
+
+ private:
+ Ecore_Timer *m_timer;
+ TimeoutHandler m_handler;
+ };
+}
+
+#endif // __UCL_MISC_TIMEOUT_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.
- */
-
-#ifndef __UCL_MISC_SMART_DELEGATION_H__
-#define __UCL_MISC_SMART_DELEGATION_H__
-
-#include "smartDelegation/WeakDelegate.h"
-
-#include "smartDelegation/macro.h"
-
-#if (UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H)
-#include "smartDelegation/shortMacro.h"
-#endif
-
-#endif // __UCL_MISC_SMART_DELEGATION_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.
- */
-
-#ifndef __UCL_MISC_SMART_DELEGATION_WEAK_DELEGATE_H__
-#define __UCL_MISC_SMART_DELEGATION_WEAK_DELEGATE_H__
-
-#include "ucl/util/delegation.h"
-#include "ucl/util/memory.h"
-
-namespace ucl {
-
- template <class FUNC_SIG>
- class WeakDelegate;
-
- template <class R, class ...ARGS>
- class WeakDelegate<R(ARGS...)> :
- public BaseDelegate<R(ARGS...), WeakRef<void>> {
- public:
- using BaseDelegate<R(ARGS...), WeakRef<void>>::BaseDelegate;
-
- template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
- static WeakDelegate make(const WeakRef<CLASS> &data) noexcept;
-
- template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
- static WeakDelegate make(const WeakRef<const CLASS> &data) noexcept;
- };
-}
-
-#include "WeakDelegate.hpp"
-
-#endif // __UCL_MISC_SMART_DELEGATION_WEAK_DELEGATE_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 ucl {
-
- template <class R, class ...ARGS>
- template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
- inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
- const WeakRef<CLASS> &data) noexcept
- {
- return {data, WeakDelegate::Cb::template stubA<CLASS, METHOD>};
- }
-
- template <class R, class ...ARGS>
- template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
- inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
- const WeakRef<const CLASS> &data) noexcept
- {
- return {constRefCast<CLASS>(data),
- WeakDelegate::Cb::template stubA<CLASS, METHOD>};
- }
-}
+++ /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 __UCL_MISC_SMART_DELEGATION_MACRO_H__
-#define __UCL_MISC_SMART_DELEGATION_MACRO_H__
-
-#define UCL_WEAK_DELEGATE(FUNC, DATA) \
- _UCL_DELEGATE(::ucl::WeakDelegate, FUNC, DATA)
-
-#endif // __UCL_MISC_SMART_DELEGATION_MACRO_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.
- */
-
-#ifndef __UCL_MISC_SMART_DELEGATION_SHORT_MACRO_H__
-#define __UCL_MISC_SMART_DELEGATION_SHORT_MACRO_H__
-
-#define WEAK_DELEGATE(FUNC, DATA) UCL_WEAK_DELEGATE(FUNC, DATA)
-
-#endif // __UCL_MISC_SMART_DELEGATION_SHORT_MACRO_H__
template <class FUNC_SIG>
BaseDelegate(BaseDelegate2<FUNC_SIG, DATA> &&d) noexcept;
- R operator()(ARGS ...args) const;
-
void reset() noexcept;
const DATA &getData() const noexcept;
protected:
BaseDelegate(const DATA &data, StubA stubA) noexcept;
- private:
+ protected:
DATA m_data;
StubA m_stubA;
};
{
}
- template <class R, class ...ARGS, class DATA>
- inline R BaseDelegate<R(ARGS...), DATA>::operator()(ARGS ...args) const
- {
- return m_stubA(
- static_cast<void *>(m_data), std::forward<ARGS>(args)...);
- }
-
template <class R, class ...ARGS, class DATA>
inline void BaseDelegate<R(ARGS...), DATA>::reset() noexcept
{
public:
using BaseDelegate<R(ARGS...), void *>::BaseDelegate;
+ R operator()(ARGS ...args) const;
+
template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
static Delegate make(CLASS *data) noexcept;
template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
namespace ucl {
+ template <class R, class ...ARGS>
+ inline R Delegate<R(ARGS...)>::operator()(ARGS ...args) const
+ {
+ return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
+ }
+
template <class R, class ...ARGS>
template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
inline Delegate<R(ARGS...)>
public:
using BaseDelegate2<R(ARGS...), void *>::BaseDelegate2;
+ R operator()(ARGS ...args) const;
+
template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
static Delegate2 make(CLASS *data) noexcept;
template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
namespace ucl {
+ template <class R, class ...ARGS>
+ inline R Delegate2<R(ARGS...)>::operator()(ARGS ...args) const
+ {
+ return this->m_stubA(this->m_data, std::forward<ARGS>(args)...);
+ }
+
template <class R, class ...ARGS>
template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
inline Delegate2<R(ARGS...)>
inline bool operator==(const BaseDelegate<R(ARGS...), DATA1> &lhs,
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
- return ((lhs.getStubA() == rhs.getStubA()) && (static_cast<void *>(
- lhs.getData()) == static_cast<void *>(rhs.getData())));
+ return ((lhs.getStubA() == rhs.getStubA()) && (
+ lhs.getData() == rhs.getData()));
}
template <class R, class ...ARGS, class DATA1, class DATA2>
inline bool operator!=(const BaseDelegate<R(ARGS...), DATA1> &lhs,
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
- return ((lhs.getStubA() != rhs.getStubA()) || (static_cast<void *>(
- lhs.getData()) != static_cast<void *>(rhs.getData())));
+ return ((lhs.getStubA() != rhs.getStubA()) || (
+ lhs.getData() != rhs.getData()));
}
template <class R, class ...ARGS, class DATA1, class DATA2>
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
return ((lhs.getStubA() < rhs.getStubA()) ||
- ((lhs.getStubA() == rhs.getStubA()) && (static_cast<void *>(
- lhs.getData()) < static_cast<void *>(rhs.getData()))));
+ ((lhs.getStubA() == rhs.getStubA()) && (
+ lhs.getData() < rhs.getData())));
}
template <class R, class ...ARGS, class DATA1, class DATA2>
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
return ((lhs.getStubA() < rhs.getStubA()) ||
- ((lhs.getStubA() == rhs.getStubA()) && (static_cast<void *>(
- lhs.getData()) <= static_cast<void *>(rhs.getData()))));
+ ((lhs.getStubA() == rhs.getStubA()) && (
+ lhs.getData() <= rhs.getData())));
}
template <class R, class ...ARGS, class DATA1, class DATA2>
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
return ((lhs.getStubA() > rhs.getStubA()) ||
- ((lhs.getStubA() == rhs.getStubA()) && (static_cast<void *>(
- lhs.getData()) > static_cast<void *>(rhs.getData()))));
+ ((lhs.getStubA() == rhs.getStubA()) && (
+ lhs.getData() > rhs.getData())));
}
template <class R, class ...ARGS, class DATA1, class DATA2>
const BaseDelegate<R(ARGS...), DATA2> &rhs) noexcept
{
return ((lhs.getStubA() > rhs.getStubA()) ||
- ((lhs.getStubA() == rhs.getStubA()) && (static_cast<void *>(
- lhs.getData()) >= static_cast<void *>(rhs.getData()))));
+ ((lhs.getStubA() == rhs.getStubA()) && (
+ lhs.getData() >= rhs.getData())));
}
}
#ifndef __UCL_UTIL_MEMORY_H__
#define __UCL_UTIL_MEMORY_H__
-#include "memory/RefCountObjBase.h"
#include "memory/RefCountObj.h"
#include "memory/BaseRef.h"
#ifndef __UCL_UTIL_MEMORY_BASE_REF_H__
#define __UCL_UTIL_MEMORY_BASE_REF_H__
-#include "RefCountObjBase.h"
+#include "IRefCountObj.h"
namespace ucl {
friend class WeakRef;
public:
- int getUseCount() const;
-
- T *operator->() const noexcept;
- typename std::add_lvalue_reference<T>::type operator*() const noexcept;
-
- template <class U>
- explicit operator U() const noexcept;
+ int getUseCount() const noexcept;
protected:
constexpr BaseRef() noexcept;
- BaseRef(RefCountObjBase *rc, T *ptr) noexcept;
+ BaseRef(IRefCountObj *rc, T *ptr) noexcept;
BaseRef(BaseRef<T> &&r) noexcept;
template <class U>
BaseRef(BaseRef<U> &&r) noexcept;
protected:
- RefCountObjBase *m_rc;
+ IRefCountObj *m_rc;
T *m_ptr;
};
}
template <class T>
inline BaseRef<T>::BaseRef(
- RefCountObjBase *const rc, T *const ptr) noexcept :
+ IRefCountObj *const rc, T *const ptr) noexcept :
m_rc(rc),
m_ptr(ptr)
{
}
template <class T>
- inline int BaseRef<T>::getUseCount() const
+ inline int BaseRef<T>::getUseCount() const noexcept
{
return (m_rc ? m_rc->getUseCount() : 0);
}
-
- template <class T>
- inline T *BaseRef<T>::operator->() const noexcept
- {
- return m_ptr;
- }
-
- template <class T>
- inline typename std::add_lvalue_reference<T>::type
- BaseRef<T>::operator*() const noexcept
- {
- return *m_ptr;
- }
-
- template <class T>
- template <class U>
- inline BaseRef<T>::operator U() const noexcept
- {
- return static_cast<U>(m_ptr);
- }
}
--- /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 __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
+#define __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
+
+#include "ucl/util/types/classTypes.h"
+
+namespace ucl {
+
+ class IRefCountObj : public Polymorphic {
+ public:
+ virtual void ref() noexcept = 0;
+ virtual void unref() noexcept = 0;
+ virtual bool refNz() noexcept = 0;
+ virtual void refWeak() noexcept = 0;
+ virtual void unrefWeak() noexcept = 0;
+ virtual unsigned getUseCount() const noexcept = 0;
+ virtual const void *getObjPtr() const noexcept = 0;
+ protected:
+ virtual ~IRefCountObj() = default;
+ };
+}
+
+#endif // __UCL_UTIL_MEMORY_I_REF_COUNT_OBJ_H__
#ifndef __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
#define __UCL_UTIL_MEMORY_REF_COUNT_OBJ_H__
-#include "RefCountObjBase.h"
+#include "IRefCountObj.h"
+#include "ReffedObj.h"
namespace ucl {
- template <class T>
- class RefCountObj : public RefCountObjBase {
+ template <class T, class C>
+ class RefCountObj final : public IRefCountObj {
public:
template <class ...ARGS>
RefCountObj(ARGS &&...args);
T *getObj() noexcept;
- protected:
- // RefCountObjBase //
- virtual void dispose() noexcept final override;
- virtual void onUniqueChanged(bool isUnique) noexcept final override;
+ // IRefCountObj //
+
+ virtual void ref() noexcept final override;
+ virtual void unref() noexcept final override;
+ 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 const void *getObjPtr() const noexcept final override;
private:
- // Consume-all SFINAE functions
- template <class T2, class ...ARGS>
- void createObj(const P<0> &, ARGS &&...args);
+ template <class T2, class = char[1]>
+ struct IsRefCountAware : std::false_type {};
+ template <class T2>
+ struct IsRefCountAware<T2, char[T2::_IS_REF_COUNT_AWARE * 0 + 1]> :
+ std::true_type {};
+
+ template <class T2, class = char[1]>
+ struct IsOnUniqueAware : std::false_type {};
template <class T2>
- void dispatchOnUniqueChanged(
- const P<0> &, const bool isUnique) noexcept;
+ struct IsOnUniqueAware<T2,
+ char[T2::_ENABLE_ON_UNIQUE_CHANGED_DISPATCH * 0 + 1]> :
+ std::true_type {};
- // Specialized SFINAE functions
+ private:
+ virtual ~RefCountObj() = default;
+
+ template <class T2, class ...ARGS, class =
+ typename std::enable_if<!IsRefCountAware<T2>::value>::type>
+ void createObj(const P<0> &, ARGS &&...args)
+ {
+ m_obj.create(std::forward<ARGS>(args)...);
+ }
- template <class T2, class ...ARGS>
+ template <class T2, class ...ARGS, class =
+ typename std::enable_if<IsRefCountAware<T2>::value>::type>
auto createObj(const P<1> &, ARGS &&...args) -> decltype(
- (void)(new T2(this, std::forward<ARGS>(args)...)))
+ ReffedObj<T>::template check<T2>(
+ (IRefCountObj *)0, std::forward<ARGS>(args)...))
{
- new (getObj()) T(this, std::forward<ARGS>(args)...);
+ m_obj.create(static_cast<IRefCountObj *>(this),
+ std::forward<ARGS>(args)...);
}
- template <class T2, class ...ARGS>
+ template <class T2, class ...ARGS, class =
+ typename std::enable_if<IsRefCountAware<T2>::value>::type>
auto createObj(const P<2> &, ARGS &&...args) -> decltype(
- (void)(new T2(*this, std::forward<ARGS>(args)...)))
+ ReffedObj<T>::template check<T2>(
+ *(IRefCountObj *)0, std::forward<ARGS>(args)...))
+ {
+ m_obj.create(*static_cast<IRefCountObj *>(this),
+ std::forward<ARGS>(args)...);
+ }
+
+ void dispatchOnUniqueChanged(const bool isUnique)
+ {
+ dispatchOnUniqueChanged<T>(P<1>(), isUnique);
+ }
+
+ template <class T2>
+ void dispatchOnUniqueChanged(...)
{
- new (getObj()) T(*this, std::forward<ARGS>(args)...);
}
- template <class T2,
- class = char(*)[T2::ENABLE_ON_UNIQUE_CHANGED_DISPATCH * 0 + 1]>
- void dispatchOnUniqueChanged(
- const P<1> &, const bool isUnique) noexcept
+ template <class T2, class =
+ typename std::enable_if<IsOnUniqueAware<T2>::value>::type>
+ void dispatchOnUniqueChanged(const P<1> &, const bool isUnique)
{
- getObj()->onUniqueChanged(isUnique);
+ m_obj.template dispatchOnUniqueChanged<T>(isUnique);
}
private:
- // Proper-aligned storage for T
- typename std::aligned_storage<sizeof(T), alignof(T)>::type m_obj;
+ ReffedObj<T> m_obj;
+ C m_useCounter;
+ C m_weakCounter;
};
}
namespace ucl {
- template <class T>
+ template <class T, class C>
template <class ...ARGS>
- inline RefCountObj<T>::RefCountObj(ARGS &&...args)
+ inline RefCountObj<T, C>::RefCountObj(ARGS &&...args) :
+ m_useCounter(1),
+ m_weakCounter(1)
{
createObj<T>(P<2>(), std::forward<ARGS>(args)...);
}
- template <class T>
- inline T *RefCountObj<T>::getObj() noexcept
+ template <class T, class C>
+ inline T *RefCountObj<T, C>::getObj() noexcept
{
- return static_cast<T *>(static_cast<void *>(&m_obj));
+ return m_obj.get();
}
- template <class T>
- inline void RefCountObj<T>::dispose() noexcept
+ template <class T, class C>
+ inline void RefCountObj<T, C>::ref() noexcept
{
- if (!isDisposed()) {
- RefCountObjBase::dispose();
- getObj()->~T();
+ if (m_useCounter.ref() == 2) {
+ dispatchOnUniqueChanged(false);
}
}
- template <class T>
- inline void RefCountObj<T>::onUniqueChanged(const bool isUnique) noexcept
+ template <class T, class C>
+ inline void RefCountObj<T, C>::unref() noexcept
{
- dispatchOnUniqueChanged<T>(P<1>(), isUnique);
+ const auto newCount = m_useCounter.unref();
+ if (newCount == 0) {
+ m_obj.destroy();
+ unrefWeak();
+ } else if (newCount == 1) {
+ dispatchOnUniqueChanged(true);
+ }
+ }
+
+ template <class T, class C>
+ inline bool RefCountObj<T, C>::refNz() noexcept
+ {
+ const auto newCount = m_useCounter.refNz();
+ if (newCount == 0) {
+ return false;
+ }
+ if (newCount == 2) {
+ dispatchOnUniqueChanged(false);
+ }
+ return true;
+ }
+
+ template <class T, class C>
+ inline void RefCountObj<T, C>::refWeak() noexcept
+ {
+ m_weakCounter.ref();
+ }
+
+ template <class T, class C>
+ inline void RefCountObj<T, C>::unrefWeak() noexcept
+ {
+ if (m_weakCounter.unref() == 0) {
+ delete this;
+ }
}
- template <class T>
- template <class T2, class ...ARGS>
- inline void RefCountObj<T>::createObj(const P<0> &, ARGS &&...args)
+ template <class T, class C>
+ inline unsigned RefCountObj<T, C>::getUseCount() const noexcept
{
- new (getObj()) T(std::forward<ARGS>(args)...);
+ return m_useCounter.get();
}
- template <class T>
- template <class T2>
- inline void RefCountObj<T>::dispatchOnUniqueChanged(
- const P<0> &, const bool isUnique) noexcept
+ template <class T, class C>
+ inline const void *RefCountObj<T, C>::getObjPtr() const noexcept
{
+ return m_obj.get();
}
}
+++ /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 __UCL_UTIL_MEMORY_REF_COUNT_OBJ_BASE_H__
-#define __UCL_UTIL_MEMORY_REF_COUNT_OBJ_BASE_H__
-
-#include "ucl/util/types/classTypes.h"
-
-namespace ucl {
-
- class RefCountObjBase : public Polymorphic {
- public:
- void ref() noexcept;
- void unref() noexcept;
-
- void refWeak() noexcept;
- void unrefWeak() noexcept;
-
- int getUseCount() const noexcept;
- bool isDisposed() const noexcept;
-
- protected:
- RefCountObjBase();
- virtual ~RefCountObjBase() = default;
-
- virtual void dispose() noexcept;
- virtual void onUniqueChanged(bool isUnique) noexcept = 0;
-
- private:
- int m_useRefs;
- int m_weakRefs;
- bool m_isDisposed;
- };
-}
-
-#include "RefCountObjBase.hpp"
-
-#endif // __UCL_UTIL_MEMORY_REF_COUNT_OBJ_BASE_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 ucl {
-
- inline RefCountObjBase::RefCountObjBase() :
- m_useRefs(0),
- m_weakRefs(1),
- m_isDisposed(false)
- {
- }
-
- inline void RefCountObjBase::ref() noexcept
- {
- ++m_useRefs;
- if (m_useRefs == 2) {
- onUniqueChanged(false);
- }
- }
-
- inline void RefCountObjBase::unref() noexcept
- {
- --m_useRefs;
- if (m_useRefs <= 1) {
- if (m_useRefs == 1) {
- onUniqueChanged(true);
- } else {
- dispose();
- unrefWeak();
- }
- }
- }
-
- inline void RefCountObjBase::refWeak() noexcept
- {
- ++m_weakRefs;
- }
-
- inline void RefCountObjBase::unrefWeak() noexcept
- {
- --m_weakRefs;
- if (m_weakRefs == 0) {
- delete this;
- }
- }
-
- inline int RefCountObjBase::getUseCount() const noexcept
- {
- return m_useRefs;
- }
-
- inline bool RefCountObjBase::isDisposed() const noexcept
- {
- return m_isDisposed;
- }
-
- inline void RefCountObjBase::dispose() noexcept
- {
- m_isDisposed = 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 __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
+#define __UCL_UTIL_MEMORY_REF_COUNTER_MT_H__
+
+#include "ucl/util/types/baseTypes.h"
+
+namespace ucl {
+
+ class RefCounterMT final {
+ public:
+ explicit RefCounterMT(const UInt count = 0) noexcept;
+
+ UInt ref() noexcept;
+ UInt unref() noexcept;
+ UInt refNz() noexcept;
+
+ UInt get() const noexcept;
+
+ private:
+ std::atomic<UInt> m_counter;
+ };
+}
+
+#include "RefCounterMT.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REF_COUNTER_MT_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 ucl {
+
+ inline RefCounterMT::RefCounterMT(const UInt count) noexcept :
+ m_counter(count)
+ {
+ }
+
+ inline UInt RefCounterMT::ref() noexcept
+ {
+ return (m_counter.fetch_add(1, std::memory_order_acq_rel) + 1);
+ }
+
+ inline UInt RefCounterMT::unref() noexcept
+ {
+ return (m_counter.fetch_sub(1, std::memory_order_acq_rel) - 1);
+ }
+
+ inline UInt RefCounterMT::refNz() noexcept
+ {
+ auto curCount = m_counter.load(std::memory_order_relaxed);
+ for (;;) {
+ if (curCount == 0) {
+ return 0;
+ }
+ const auto newCount = (curCount + 1);
+ if (m_counter.compare_exchange_weak(curCount, newCount,
+ std::memory_order_acq_rel, std::memory_order_relaxed)) {
+ return newCount;
+ }
+ }
+ }
+
+ inline UInt RefCounterMT::get() const noexcept
+ {
+ return m_counter.load(std::memory_order_relaxed);
+ }
+}
--- /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 __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
+#define __UCL_UTIL_MEMORY_REF_COUNTER_ST_H__
+
+#include "ucl/util/types/baseTypes.h"
+
+namespace ucl {
+
+ class RefCounterST final {
+ public:
+ explicit RefCounterST(const UInt count = 0) noexcept;
+
+ UInt ref() noexcept;
+ UInt unref() noexcept;
+ UInt refNz() noexcept;
+
+ UInt get() const noexcept;
+
+ private:
+ UInt m_counter;
+ };
+}
+
+#include "RefCounterST.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REF_COUNTER_ST_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 ucl {
+
+ inline RefCounterST::RefCounterST(const UInt count) noexcept :
+ m_counter(count)
+ {
+ }
+
+ inline UInt RefCounterST::ref() noexcept
+ {
+ return (++m_counter);
+ }
+
+ inline UInt RefCounterST::unref() noexcept
+ {
+ return (--m_counter);
+ }
+
+ inline UInt RefCounterST::refNz() noexcept
+ {
+ if (m_counter == 0) {
+ return 0;
+ }
+ return ref();
+ }
+
+ inline UInt RefCounterST::get() const noexcept
+ {
+ return m_counter;
+ }
+}
--- /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 __UCL_UTIL_MEMORY_REFFED_OBJ_H__
+#define __UCL_UTIL_MEMORY_REFFED_OBJ_H__
+
+#include "RefCounterST.h"
+#include "RefCounterMT.h"
+
+namespace ucl {
+
+ template <class T, class C>
+ class RefCountObj;
+
+ template <class T>
+ class ReffedObj final {
+ private:
+ friend class RefCountObj<T, RefCounterST>;
+ friend class RefCountObj<T, RefCounterMT>;
+
+ template <class ...ARGS>
+ void create(ARGS &&...args);
+ void destroy() noexcept;
+
+ T *get() noexcept;
+ const T *get() const noexcept;
+
+ template <class T2>
+ void dispatchOnUniqueChanged(bool isUnique);
+
+ private:
+ template <class T2, class ...ARGS>
+ static constexpr auto check(ARGS &&...args) -> decltype(
+ (void)(new T2(std::forward<ARGS>(args)...)))
+ {
+ return;
+ }
+
+ private:
+ typename std::aligned_storage<sizeof(T), alignof(T)>::type m_obj;
+ };
+}
+
+#include "ReffedObj.hpp"
+
+#endif // __UCL_UTIL_MEMORY_REFFED_OBJ_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 ucl {
+
+ template <class T>
+ template <class ...ARGS>
+ inline void ReffedObj<T>::create(ARGS &&...args)
+ {
+ new (get()) T(std::forward<ARGS>(args)...);
+ }
+
+ template <class T>
+ inline void ReffedObj<T>::destroy() noexcept
+ {
+ get()->~T();
+ }
+
+ template <class T>
+ inline T *ReffedObj<T>::get() noexcept
+ {
+ return static_cast<T *>(static_cast<void *>(&m_obj));
+ }
+
+ template <class T>
+ inline const T *ReffedObj<T>::get() const noexcept
+ {
+ return static_cast<const T *>(static_cast<const void *>(&m_obj));
+ }
+
+ template <class T>
+ template <class T2>
+ inline void ReffedObj<T>::dispatchOnUniqueChanged(const bool isUnique)
+ {
+ get()->onUniqueChanged(isUnique);
+ }
+}
namespace ucl {
template <class T>
- class SharedRef : public BaseRef<T> {
+ class SharedRef final : public BaseRef<T> {
public:
template <class U>
friend void swap(SharedRef<U> &x, SharedRef<U> &y) noexcept;
constexpr SharedRef() noexcept;
constexpr SharedRef(std::nullptr_t) noexcept;
- SharedRef(RefCountObjBase *rc, T *ptr) noexcept;
+ SharedRef(IRefCountObj *rc, T *ptr) noexcept;
+ SharedRef(IRefCountObj *rc, T *ptr, bool noRef) noexcept;
SharedRef(const SharedRef<T> &r) noexcept;
template <class U>
- SharedRef(const BaseRef<U> &r) noexcept;
+ SharedRef(const SharedRef<U> &r) noexcept;
SharedRef(SharedRef<T> &&r) noexcept;
template <class U>
T *get() const noexcept;
operator bool() const noexcept;
+ T *operator->() const noexcept;
+ typename std::add_lvalue_reference<T>::type operator*() const noexcept;
+
template <class U, class = typename std::enable_if<
std::is_convertible<T *, U *>::value && (
std::is_same<typename std::remove_cv<U>::type, void>::value ||
template <class T, class ...ARGS>
SharedRef<T> makeShared(ARGS &&...args);
+ template <class T, class ...ARGS>
+ SharedRef<T> makeSharedMT(ARGS &&...args);
template <class T, class U>
const SharedRef<T> &constRefCast(const SharedRef<U> &r) noexcept;
* limitations under the License.
*/
-#include "RefCountObj.h"
-
namespace ucl {
template <class T>
template <class T>
inline SharedRef<T>::SharedRef(
- RefCountObjBase *const rc, T *const ptr) noexcept :
+ IRefCountObj *const rc, T *const ptr) noexcept :
BaseRef<T>(rc, ptr)
{
this->m_rc->ref();
}
+ template <class T>
+ inline SharedRef<T>::SharedRef(
+ IRefCountObj *const rc, T *const ptr, bool noRef) noexcept :
+ BaseRef<T>(rc, ptr)
+ {
+ }
+
template <class T>
inline SharedRef<T>::SharedRef(const SharedRef<T> &r) noexcept :
BaseRef<T>(r.m_rc, r.m_ptr)
template <class T>
template <class U>
- inline SharedRef<T>::SharedRef(const BaseRef<U> &r) noexcept :
+ inline SharedRef<T>::SharedRef(const SharedRef<U> &r) noexcept :
BaseRef<T>(r.m_rc, r.m_ptr)
{
if (this->m_rc) {
return !!this->m_ptr;
}
+ template <class T>
+ inline T *SharedRef<T>::operator->() const noexcept
+ {
+ return this->m_ptr;
+ }
+
+ template <class T>
+ inline typename std::add_lvalue_reference<T>::type
+ SharedRef<T>::operator*() const noexcept
+ {
+ return *this->m_ptr;
+ }
+
// Non-member functions //
template <class T, class ...ARGS>
SharedRef<T> makeShared(ARGS &&...args)
{
- const auto rc = new RefCountObj<T>(std::forward<ARGS>(args)...);
- return {rc, rc->getObj()};
+ const auto rc = new RefCountObj<T, RefCounterST>(
+ std::forward<ARGS>(args)...);
+ return {rc, rc->getObj(), true};
+ }
+
+ template <class T, class ...ARGS>
+ SharedRef<T> makeSharedMT(ARGS &&...args)
+ {
+ const auto rc = new RefCountObj<T, RefCounterMT>(
+ std::forward<ARGS>(args)...);
+ return {rc, rc->getObj(), true};
}
template <class T>
namespace ucl {
template <class T>
- class WeakRef : public BaseRef<T> {
+ class WeakRef final : public BaseRef<T> {
public:
template <class U>
friend void swap(WeakRef<U> &x, WeakRef<U> &y) noexcept;
constexpr WeakRef() noexcept;
constexpr WeakRef(std::nullptr_t) noexcept;
- WeakRef(RefCountObjBase *rc, T *ptr) noexcept;
+ WeakRef(IRefCountObj *rc, T *ptr) noexcept;
WeakRef(const WeakRef<T> &r) noexcept;
template <class U>
void reset() noexcept;
- T *get() const noexcept;
+ SharedRef<T> lock() const noexcept;
+
+ T *getUnsafePtr() const noexcept;
operator bool() const noexcept;
template <class U, class = typename std::enable_if<
template <class T>
inline WeakRef<T>::WeakRef(
- RefCountObjBase *const rc, T *const ptr) noexcept :
+ IRefCountObj *const rc, T *const ptr) noexcept :
BaseRef<T>(rc, ptr)
{
this->m_rc->refWeak();
}
template <class T>
- inline T *WeakRef<T>::get() const noexcept
+ inline SharedRef<T> WeakRef<T>::lock() const noexcept
+ {
+ if (this->m_rc && this->m_rc->refNz()) {
+ return {this->m_rc, this->m_ptr, true};
+ }
+ return {};
+ }
+
+ template <class T>
+ inline T *WeakRef<T>::getUnsafePtr() const noexcept
{
return (operator bool() ? this->m_ptr : nullptr);
}
template <class T>
inline WeakRef<T>::operator bool() const noexcept
{
- return (this->m_ptr && !this->m_rc->isDisposed());
+ return (this->m_rc && (this->m_rc->getUseCount() > 0));
}
// Non-member functions //
template <class T, class U>
inline WeakRef<T> staticRefCast(const WeakRef<U> &r) noexcept
{
- return {r.m_rc, static_cast<T *>(r.get())};
+ return {r.m_rc, static_cast<T *>(r.getUnsafePtr())};
}
template <class T, class U>
inline WeakRef<T> dynamicRefCast(const WeakRef<U> &r) noexcept
{
- const auto ptr = dynamic_cast<T *>(r.get());
+ const auto ptr = dynamic_cast<T *>(r.getUnsafePtr());
if (!ptr) {
return {};
}
// Relation operators //
+ namespace himpl {
+
+ template <class T, class = typename std::enable_if<
+ !std::is_base_of<BaseRef<typename T::Type>, T>::value>::type>
+ inline const T &getCmpPtr(const T &ptr) noexcept
+ {
+ return ptr;
+ }
+
+ template <class T>
+ inline T *getCmpPtr(const SharedRef<T> &r) noexcept
+ {
+ return r.get();
+ }
+
+ template <class T>
+ inline T *getCmpPtr(const WeakRef<T> &r) noexcept
+ {
+ return r.getUnsafePtr();
+ }
+ }
+
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator==(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() == rhs.get());
+ return (himpl::getCmpPtr(lhs) == himpl::getCmpPtr(rhs));
}
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator!=(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() != rhs.get());
+ return (himpl::getCmpPtr(lhs) != himpl::getCmpPtr(rhs));
}
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator<(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() < rhs.get());
+ return (himpl::getCmpPtr(lhs) < himpl::getCmpPtr(rhs));
}
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator<=(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() <= rhs.get());
+ return (himpl::getCmpPtr(lhs) <= himpl::getCmpPtr(rhs));
}
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator>(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() > rhs.get());
+ return (himpl::getCmpPtr(lhs) > himpl::getCmpPtr(rhs));
}
template <class T, class U, class = typename std::enable_if<
- std::is_base_of<BaseRef<typename T::Type>, T>::value &&
+ std::is_base_of<BaseRef<typename T::Type>, T>::value ||
std::is_base_of<BaseRef<typename U::Type>, U>::value>::type>
inline bool operator>=(const T &lhs, const U &rhs) noexcept
{
- return (lhs.get() >= rhs.get());
+ return (himpl::getCmpPtr(lhs) >= himpl::getCmpPtr(rhs));
}
template <class T, class = typename std::enable_if<
using CLASS_NAME##SCRef = ::ucl::SharedRef<const CLASS_NAME>; \
using CLASS_NAME##WCRef = ::ucl::WeakRef<const CLASS_NAME>
+#define UCL_USING_REF_ALIASES(CLASS_NAME) \
+ using CLASS_NAME; \
+ using CLASS_NAME##SRef; \
+ using CLASS_NAME##WRef; \
+ using CLASS_NAME##SCRef; \
+ using CLASS_NAME##WCRef; \
+
#endif // __UCL_UTIL_MEMORY_MACRO_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.
+ */
+
+#ifndef __UCL_UTIL_SMART_DELEGATION_H__
+#define __UCL_UTIL_SMART_DELEGATION_H__
+
+#include "smartDelegation/WeakDelegate.h"
+
+#include "smartDelegation/macro.h"
+
+#if (UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H)
+#include "smartDelegation/shortMacro.h"
+#endif
+
+#endif // __UCL_UTIL_SMART_DELEGATION_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.
+ */
+
+#ifndef __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
+#define __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_H__
+
+#include "ucl/util/delegation.h"
+#include "ucl/util/memory.h"
+
+namespace ucl {
+
+ template <class FUNC_SIG>
+ class WeakDelegate;
+
+ template <class R, class ...ARGS>
+ class WeakDelegate<R(ARGS...)> :
+ public BaseDelegate<R(ARGS...), WeakRef<void>> {
+ public:
+ using BaseDelegate<R(ARGS...), WeakRef<void>>::BaseDelegate;
+
+ R operator()(ARGS ...args) const;
+
+ template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+ static WeakDelegate make(const WeakRef<CLASS> &data) noexcept;
+
+ template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+ static WeakDelegate make(const WeakRef<const CLASS> &data) noexcept;
+ };
+}
+
+#include "WeakDelegate.hpp"
+
+#endif // __UCL_UTIL_SMART_DELEGATION_WEAK_DELEGATE_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 ucl {
+
+ template <class R, class ...ARGS>
+ inline R WeakDelegate<R(ARGS...)>::operator()(ARGS ...args) const
+ {
+ const auto tmp = this->m_data.lock();
+ if (tmp) {
+ return this->m_stubA(tmp.get(), std::forward<ARGS>(args)...);
+ }
+ return R();
+ }
+
+ template <class R, class ...ARGS>
+ template <class CLASS, R(CLASS::*METHOD)(ARGS...)>
+ inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
+ const WeakRef<CLASS> &data) noexcept
+ {
+ return {data, WeakDelegate::Cb::template stubA<CLASS, METHOD>};
+ }
+
+ template <class R, class ...ARGS>
+ template <class CLASS, R(CLASS::*METHOD)(ARGS...) const>
+ inline WeakDelegate<R(ARGS...)> WeakDelegate<R(ARGS...)>::make(
+ const WeakRef<const CLASS> &data) noexcept
+ {
+ return {constRefCast<CLASS>(data),
+ WeakDelegate::Cb::template stubA<CLASS, METHOD>};
+ }
+}
--- /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 __UCL_UTIL_SMART_DELEGATION_MACRO_H__
+#define __UCL_UTIL_SMART_DELEGATION_MACRO_H__
+
+#define UCL_WEAK_DELEGATE(FUNC, DATA) \
+ _UCL_DELEGATE(::ucl::WeakDelegate, FUNC, DATA)
+
+#endif // __UCL_UTIL_SMART_DELEGATION_MACRO_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.
+ */
+
+#ifndef __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
+#define __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
+
+#define WEAK_DELEGATE(FUNC, DATA) UCL_WEAK_DELEGATE(FUNC, DATA)
+
+#endif // __UCL_UTIL_SMART_DELEGATION_SHORT_MACRO_H__
#include <string>
#include <memory>
+#include <atomic>
#include <functional>
#include <type_traits>
#include <utility>
public:
virtual IPRODUCT *newInstance() const = 0;
protected:
- ~IFactory() = default;
+ virtual ~IFactory() = default;
};
template <class PRODUCT, class IPRODUCT>
#include "ucl/util/shortLogs.h"
#include "ucl/util/delegation/shortMacro.h"
-#include "ucl/misc/smartDelegation/shortMacro.h"
+#include "ucl/util/smartDelegation/shortMacro.h"
#endif // __UCL_COMMON_H__
namespace ucl {
+ ElmWidget::ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner) :
+ Widget(rc, eo, isOwner),
+ m_isAtspiGestureCbSet(false)
+ {
+ }
+
+ ElmWidget::~ElmWidget()
+ {
+ if (m_isAtspiGestureCbSet) {
+ elm_atspi_accessible_gesture_cb_set(getEo(), nullptr, nullptr);
+ }
+ }
+
void ElmWidget::setFocusedImpl(const bool value)
{
elm_object_focus_set(getEo(), toEina(value));
return elm_object_focus_get(getEo());
}
+ bool ElmWidget::ensureFwdEvent(const SmartEvent fwdEvent)
+ {
+ if (Widget::ensureFwdEvent(fwdEvent)) {
+ return true;
+ }
+ if (fwdEvent == ATSPI_ON_GESTURE) {
+ if (!m_isAtspiGestureCbSet) {
+ m_isAtspiGestureCbSet = true;
+ elm_atspi_accessible_gesture_cb_set(getEo(),
+ CALLBACK_A(ElmWidget::onAtspiGesture), this);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ Eina_Bool ElmWidget::onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+ Evas_Object *obj)
+ {
+ AtspiGestureEventInfo eventInfo{gestureInfo};
+ callEvent(ATSPI_ON_GESTURE, &eventInfo);
+ return toEina(eventInfo.preventDefault);
+ }
+
Window *ElmWidget::getWindow() const
{
return dynamicCast<Window>(getTopWidget());
// Naviframe //
- Naviframe::Naviframe(RefCountObjBase &rc, Evas_Object *eo) :
+ Naviframe::Naviframe(IRefCountObj &rc, Evas_Object *eo) :
StyledWidget(&rc, eo, true),
m_isInTransition(false)
{
// Widget //
- Widget::Widget(RefCountObjBase *const rc, Evas_Object *const eo,
+ Widget::Widget(IRefCountObj *const rc, Evas_Object *const eo,
const bool isOwner) :
RefCountAware(rc),
m_eo(eo),
void Widget::updateRefs()
{
- const auto rc = m_rc;
-
updateEoRef();
- if (rc && !rc->isDisposed()) {
+ if (m_rc) {
updateSelfRef();
}
}
void Widget::addEventHandler(const SmartEvent event,
const WidgetEventHandler handler)
{
+ if (strncmp(event.name, UCL_SMART_FWD, strlen(UCL_SMART_FWD)) == 0) {
+ if (!ensureFwdEvent(event)) {
+ LOG_RETURN_VOID(RES_NOT_SUPPORTED,
+ "Event is not supported: %s;", event.name);
+ }
+ }
m_eventProxies.emplace_front(*this, event, handler);
m_eventProxies.front().setSelfIt(m_eventProxies.begin());
}
{
return evas_object_focus_get(getEo());
}
+
+ bool Widget::ensureFwdEvent(const SmartEvent fwdEvent)
+ {
+ return false;
+ }
}
--- /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 "ucl/misc/Timeout.h"
+
+#include "common.h"
+
+namespace ucl {
+
+ TimeoutSRef Timeout::create(double timeoutSec,
+ const TimeoutHandler &handler)
+ {
+ auto result = makeShared<Timeout>(handler);
+
+ FAIL_RETURN_VALUE(result->prepare(timeoutSec), {},
+ "result->prepare() failed!");
+
+ return result;
+ }
+
+ Timeout::Timeout(const TimeoutHandler &handler) :
+ m_timer(nullptr),
+ m_handler(handler)
+ {
+ }
+
+ Timeout::~Timeout()
+ {
+ if (m_timer) {
+ ecore_timer_del(m_timer);
+ }
+ }
+
+ Result Timeout::prepare(const double timeoutSec)
+ {
+ m_timer = ecore_timer_add(timeoutSec,
+ [](void *data) -> Eina_Bool
+ {
+ const auto self = static_cast<Timeout *>(data);
+ self->m_timer = nullptr;
+ if (self->m_handler) {
+ self->m_handler(self);
+ }
+ return ECORE_CALLBACK_CANCEL;
+ },
+ this);
+
+ if (!m_timer) {
+ FAIL_RETURN(RES_FAIL, "ecore_timer_add() failed!");
+ }
+
+ return RES_OK;
+ }
+
+ bool Timeout::isExpired() const
+ {
+ return !m_timer;
+ }
+}