<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/PopupManager.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/RingtonePicker.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Serialization.o""/>
- <listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Signal.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/SoundManager.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/ThemeExtension.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Time.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/TizenApp.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Translate.o""/>
- <listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Utils.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/WorldClock.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/View/AlarmView.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/View/CounterView.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockMap.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockReorderView.o""/>
<listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockView.o""/>
+ <listOptionValue builtIn="false" value=""/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/TizenAppUtils.o""/>
</option>
<option id="gnu.cpp.link.option.libs.2071152623" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="gtest"/>
Subscriber s1, s2;
TestEvent event;
- Listener l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
- Listener l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
+ Connection l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
+ Connection l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
EXPECT_EQ(s1.times_, 0);
EXPECT_EQ(s2.times_, 0);
Subscriber s1, s2;
TestEvent event;
- Listener l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
- Listener l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
+ Connection l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
+ Connection l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
EXPECT_EQ(s1.times_, 0);
EXPECT_EQ(s2.times_, 0);
EXPECT_EQ(s1.times_, 1);
EXPECT_EQ(s2.times_, 1);
- l1.Unregister();
+ l1->Disconnect();
EventBus::FireEvent(event);
EXPECT_EQ(s1.times_, 1);
EXPECT_EQ(s2.times_, 2);
- l2.Unregister();
+ l2->Disconnect();
EventBus::FireEvent(event);
EXPECT_EQ(s1.times_, 1);
EXPECT_EQ(s2.times_, 2);
}
-TEST(EventBusTestSuite, listener_copy)
-{
- Subscriber s1, s2;
- TestEvent event;
-
- Listener l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
- Listener l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
-
- EXPECT_EQ(s1.times_, 0);
- EXPECT_EQ(s2.times_, 0);
-
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 1);
- EXPECT_EQ(s2.times_, 1);
-
- Listener l3 = l1;
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 3);
- EXPECT_EQ(s2.times_, 2);
-
- l1.Unregister();
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 4);
- EXPECT_EQ(s2.times_, 3);
-
- l3.Unregister();
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 4);
- EXPECT_EQ(s2.times_, 4);
-
- l2.Unregister();
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 4);
- EXPECT_EQ(s2.times_, 4);
-}
-
TEST(EventBusTestSuite, listener_in_vector)
{
- DBG("Last test start");
Subscriber s1, s2;
TestEvent event;
- std::vector<Listener> listeners;
+ std::vector<Connection> listeners;
listeners.push_back(EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1)));
listeners.push_back(EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1)));
EXPECT_EQ(s1.times_, 1);
EXPECT_EQ(s2.times_, 1);
}
-
-TEST(EventBusTestSuite, listener_copy2)
-{
- Subscriber s1, s2;
- TestEvent event;
-
- Listener l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
- Listener l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
-
- EXPECT_EQ(s1.times_, 0);
- EXPECT_EQ(s2.times_, 0);
-
- /* Unregister l1 subscription and make new subscription like l2 */
- l1 = l2;
-
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 0);
- EXPECT_EQ(s2.times_, 2);
-}
-
-TEST(EventBusTestSuite, listener_copy3)
-{
- Subscriber s1, s2;
- Listener l3;
- TestEvent event;
-
- Listener l1 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s1, _1));
- Listener l2 = EventBus::AddListener<TestEvent>(std::bind(&Subscriber::OnEvent2, &s2, _1));
-
- EXPECT_EQ(s1.times_, 0);
- EXPECT_EQ(s2.times_, 0);
-
- /* Unregister l1 subscription and make new subscription like empty subscription l3 */
- l1 = l3;
-
- EventBus::FireEvent(event);
- EXPECT_EQ(s1.times_, 0);
- EXPECT_EQ(s2.times_, 1);
-}
--- /dev/null
+#include "Utils/Signal.h"
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <vector>
+#include <iostream>
+#include <cstdlib>
+
+using namespace testing;
+using namespace utils;
+using std::placeholders::_1;
+
+
+class SignalTestSuite : public testing::Test
+{
+ protected:
+ // virtual void SetUp() will be called before each test is run.
+ // You should define it if you need to initialize the variables.
+ // Otherwise, you don't have to provide it.
+ virtual void SetUp()
+ {
+
+ }
+ // virtual void TearDown() will be called after each test is run.
+ // You should define it if there is cleanup work to do.
+ // Otherwise, you don't have to provide it.
+ virtual void TearDown()
+ {
+
+ }
+};
+
+class Subscriber
+{
+ public:
+ Subscriber() : times_(0) {}
+ int times_;
+ void OnEvent(int e);
+};
+
+void Subscriber::OnEvent(int event)
+{
+ times_ += event;
+}
+
+TEST(SignalTestSuite, connection)
+{
+ Subscriber s1, s2;
+ Signal<void(int)> event;
+
+ Connection c1 = event.Connect(std::bind(&Subscriber::OnEvent, &s1, _1));
+ Connection c2 = event.Connect(std::bind(&Subscriber::OnEvent, &s2, _1));
+
+ EXPECT_EQ(s1.times_, 0);
+ EXPECT_EQ(s2.times_, 0);
+ event(1);
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+}
+
+TEST(SignalTestSuite, connection2)
+{
+ Subscriber s1, s2;
+ Signal<void(int)> event;
+
+ Connection c1 = event.Connect(std::bind(&Subscriber::OnEvent, &s1, _1));
+ Connection c2 = event.Connect(std::bind(&Subscriber::OnEvent, &s2, _1));
+
+ EXPECT_EQ(s1.times_, 0);
+ EXPECT_EQ(s2.times_, 0);
+ event(1);
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+
+ c1->Disconnect();
+ event(1);
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 2);
+
+ c2->Disconnect();
+ event(1);
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 2);
+}
+
+TEST(SignalTestSuite, listener_in_vector)
+{
+ Subscriber s1, s2;
+ Signal<void(int)> event;
+
+ std::vector<Connection> listeners;
+
+ listeners.push_back(event.Connect(std::bind(&Subscriber::OnEvent, &s1, _1)));
+ listeners.push_back(event.Connect(std::bind(&Subscriber::OnEvent, &s2, _1)));
+
+ EXPECT_EQ(s1.times_, 0);
+ EXPECT_EQ(s2.times_, 0);
+
+ event(1);
+
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+}
+
+TEST(SignalTestSuite, listener_in_vector2)
+{
+ Subscriber s1, s2;
+ Signal<void(int)> event;
+
+ std::vector<Connection> *listeners = new std::vector<Connection>(2);
+
+ listeners->push_back(event.Connect(std::bind(&Subscriber::OnEvent, &s1, _1)));
+ listeners->push_back(event.Connect(std::bind(&Subscriber::OnEvent, &s2, _1)));
+
+ EXPECT_EQ(s1.times_, 0);
+ EXPECT_EQ(s2.times_, 0);
+
+ event(1);
+
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+
+ delete listeners;
+
+ event(1);
+
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+}
+
+TEST(SignalTestSuite, signals_auto_unsubsribe_on_destroy)
+{
+ Subscriber s1, s2;
+ Signal<void(int)> *event = new Signal<void(int)>();
+
+ std::vector<Connection> listeners;
+
+ listeners.push_back(event->Connect(std::bind(&Subscriber::OnEvent, &s1, _1)));
+ listeners.push_back(event->Connect(std::bind(&Subscriber::OnEvent, &s2, _1)));
+
+ EXPECT_EQ(s1.times_, 0);
+ EXPECT_EQ(s2.times_, 0);
+
+ (*event)(1);
+
+ EXPECT_EQ(s1.times_, 1);
+ EXPECT_EQ(s2.times_, 1);
+
+ delete event;
+
+ // listeners goes out-of scope (Disconnect called implicite)
+}
+
+class SubscriberWithConnection
+{
+ public:
+ void OnEvent(int e);
+ Connection conn;
+};
+
+void SubscriberWithConnection::OnEvent(int event)
+{
+ conn->Disconnect();
+}
+
+TEST(SignalTestSuite, signals_disconnect_in_invoke)
+{
+ SubscriberWithConnection s1;
+ Signal<void(int)> event;
+
+ s1.conn = event.Connect(std::bind(&SubscriberWithConnection::OnEvent, &s1, _1));
+
+ event(1);
+}
+
+class SubscriberWithSignalObject
+{
+ public:
+ void OnEvent(int e);
+ Connection conn;
+ Signal<void(int)> *event;
+};
+
+void SubscriberWithSignalObject::OnEvent(int id)
+{
+ delete event;
+}
+
+TEST(SignalTestSuite, signals_destruct_signal)
+{
+ SubscriberWithSignalObject s2;
+ s2.event = new Signal<void(int)>();
+ s2.conn = s2.event->Connect(std::bind(&SubscriberWithSignalObject::OnEvent, &s2, _1));
+ s2.event->operator()(1);
+}
+
+class SubscriberWithSignalObjectReentrant
+{
+ public:
+ void OnEvent(int e);
+ Connection conn;
+ int counter;
+ Signal<void(int)> *event;
+};
+
+void SubscriberWithSignalObjectReentrant::OnEvent(int id)
+{
+ if (++counter < 5)
+ event->operator()(1);
+
+ conn->Disconnect();
+}
+
+TEST(SignalTestSuite, signals_reentrancy)
+{
+ SubscriberWithSignalObjectReentrant s2;
+ s2.event = new Signal<void(int)>();
+ s2.conn = s2.event->Connect(std::bind(&SubscriberWithSignalObjectReentrant::OnEvent, &s2, _1));
+
+ s2.counter = 0;
+ s2.event->operator()(1);
+ EXPECT_EQ(s2.counter, 5);
+}
+
+class SubscriberWithSignalObjectReentrant2
+{
+ public:
+ void OnEvent(int e);
+ std::vector<Connection> conn;
+ int counter;
+ Signal<void(int)> event;
+};
+
+void SubscriberWithSignalObjectReentrant2::OnEvent(int id)
+{
+ ++counter;
+
+ if (counter % 2 == 0) {
+ int idx = std::rand() % (conn.size());
+ conn[idx]->Disconnect();
+ }
+ else
+ conn.push_back(event.Connect(std::bind(&SubscriberWithSignalObjectReentrant2::OnEvent, this, _1)));
+
+ if (counter < 30)
+ event(1);
+}
+
+TEST(SignalTestSuite, signals_reentrancy2)
+{
+ std::srand(0);
+ SubscriberWithSignalObjectReentrant2 s2;
+ s2.conn.push_back(s2.event.Connect(std::bind(&SubscriberWithSignalObjectReentrant2::OnEvent, &s2, _1)));
+
+ s2.counter = 0;
+ s2.event(1);
+}
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/PopupManager.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/RingtonePicker.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Serialization.o</targetObjectFile>
-<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Signal.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/SoundManager.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/ThemeExtension.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Time.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/TizenApp.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Translate.o</targetObjectFile>
-<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/Utils.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/WorldClock.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/View/AlarmView.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/View/CounterView.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockMap.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockReorderView.o</targetObjectFile>
<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/View/WorldClockView.o</targetObjectFile>
+<targetObjectFile>/home/l.stanislaws/Projects/clock/clock/Debug/src/Utils/TizenAppUtils.o</targetObjectFile>
</tizen_unittest>
#include <vector>
#include <functional>
+#include "Utils/Signal.h"
+
namespace common {
/**
void SetFrametime(double time);
/**
- * @brief Registers animators callback
- *
- * This function registers callback to be called on
- * every animator tick.
- *
- * @param[in] func Callback function to be registered
+ * @brief Signal emitted on each animator tick.
*/
- void RegisterSignal(std::function<void(void)>func);
+ utils::Signal<void(void)> OnTick;
private:
Ecore_Animator *animator_;
-
-
- std::vector<std::function<void(void)>> signals_;
-
- void EmitSignal(void);
static Eina_Bool Task(void *data);
};
}
/**
* @brief global events subscriptions vector
*/
- std::vector<utils::Listener> listeners_;
+ std::vector<utils::Connection> connections_;
/**
* @brief intiialized flag
model::Ring *model_;
view::RingView *view_;
model::AlarmProvider *provider_;
- utils::Listener listener_;
+ utils::Connection listener_;
void RingCreate(void);
void RingDestroy(utils::Event &e);
#include <functional>
#include "Model/Location.h"
+#include "Utils/Signal.h"
namespace model {
public:
/**
- * @brief Enumeration for signals that passes parameter
- *
- * @details Only const model::Location & parameter type is allowed
- */
- enum class ParameterSignalType {
- USER_LOCATION_REMOVED,
- MAX
- };
-
- /**
- * @brief Model signals
- */
- enum class SignalType {
- CUSTOM_LIST_CHANGED,
- MAX
- };
-
- /**
* @brief Enumeration for direction of time zone shift.
*/
enum Direction {
void MoveCurrentTimezone(Direction direction);
/**
- * @brief Registers signal handler
- * @details func must have one parameter. For now only const model::Location & type is supported
- *
- * @param signal signal type
- * @param func function to be called when registered signal is emitted.
+ * @brief Signal emitted when custom locations list has been
+ * changed.
*/
- void RegisterSignalHandler(ParameterSignalType signal, std::function<void(const model::Location &)> func);
+ utils::Signal<void(void)> OnCustomListChanged;
/**
- * @brief Registers signal handler
- *
- * @param signal signal type
- * @param func function to be called when registered signal is emitted.
+ * @brief Signal emitted when user location list has been
+ * removed.
*/
- void RegisterSignalHandler(SignalType signal, std::function<void(void)> func);
+ utils::Signal<void(const model::Location&)> OnUserLocationRemoved;
+
private:
enum ItemKeyType {
*/
static std::vector<Timezone> time_zones_;
- std::vector<std::function<void(const model::Location &)>> parameter_signals_;
-
- std::vector<std::function<void(void)>> signals_;
-
/**
* @brief Saves items list state using app_preferences API
*
* @brief Gets time zone by its no in time_zone_ list
*/
const Timezone *GetTimezone(int no) const;
-
- /**
- * @brief Emits signal s
- *
- * @param s signal
- * @param location location to pass to function registered for given signal
- */
- void EmitSignal(ParameterSignalType s, const model::Location &location);
-
- /**
- * @brief Emits signal s
- *
- * @param s signal
- * @param location location to pass to function registered for given signal
- */
- void EmitSignal(SignalType s);
};
} /* model */
void OnDeleteItemClicked();
void UpdateBackgroundLabel();
std::map<int, std::reference_wrapper<model::Alarm>> alarms_;
- std::vector<utils::Listener> listeners_;
+ std::vector<utils::Connection> connections_;
bool CheckModelSizeLimit();
void OnMenuButtonClicked();
};
#include "Model/AlarmProvider.h"
#include "View/DeleteAlarmView.h"
+#include "Utils/Signal.h"
#include <map>
model::AlarmProvider *model_;
void OnDeleteButtonClicked();
void OnCancelButtonClicked();
+ std::vector<utils::Connection> connections_;
std::map<int, std::reference_wrapper<model::Alarm>> alarms_;
};
} /* presenter */
#include "View/EditAlarmView.h"
#include "Model/Alarm.h"
#include "Model/AlarmProvider.h"
+#include "Utils/Signal.h"
+
+#include <vector>
namespace presenter {
/**
void ShowAlarmUpdatedPopup(const utils::Time &time);
void OnBackButton();
void OnDiscardPopupOptionClicked(view::EditAlarmView::DiscardPopupOption option);
+ std::vector<utils::Connection> connections_;
};
} /* presenter */
model::Ring *model_;
model::Alarm *alarm_;
- std::vector<utils::Listener> listeners_;
+ std::vector<utils::Connection> connections_;
common::CounterAnimator animator_;
#include "View/StopWatchView.h"
#include "View/CounterView.h"
#include "View/View.h"
+#include "Utils/Signal.h"
#include "Model/StopWatch.h"
#include "Common/CounterAnimator.h"
std::string GetTimeString(std::chrono::milliseconds time);
Time GetTimeStructure(std::chrono::milliseconds time);
+
+ std::vector<utils::Connection> connections_;
};
}
#include "View/CounterView.h"
#include "Model/Timer.h"
#include "Common/CounterAnimator.h"
+#include "Utils/Signal.h"
namespace presenter {
void TimeIsUp();
void TimeUpdateRequest();
+ std::vector<utils::Connection> connections_;
};
}
* @brief Updates page title and "Select All" item state.
*/
void OnListItemClicked();
+
+ /**
+ * @brief Presenter connections
+ */
+ std::vector<utils::Connection> connections_;
};
}
view::WorldClockView *view_;
model::WorldClock *model_;
- std::vector<utils::Listener> listeners_;
-
/**
* @brief Updates background of locations list. If list is empty proper message is displayed
*/
*/
void OnCustomListChanged();
+ /**
+ * @brief Connections
+ */
+ std::vector<utils::Connection> connections_;
};
}
#include "View/WorldClockReorderView.h"
#include "Model/WorldClock.h"
+#include "Utils/Signal.h"
namespace presenter {
/**
* @details Pops Reorder View page
*/
void OnBackClicked();
+
+ /**
+ * @brief Presenter connections.
+ */
+ std::vector<utils::Connection> connections_;
};
}
#include <list>
#include <typeindex>
+#include "Utils/Signal.h"
+
namespace utils {
/**
* @brief Base event class.
};
/**
- * @brief Listener class represents event subscription.
- *
- * Listeners are created with EventBus::AddListener function.
- */
- class Listener {
- public:
- /**
- * @brief default constructor
- *
- * Creates listener without any subscription.
- */
- Listener() : owner_(nullptr) {}
-
- /**
- * @brief Copy constructor. Creates new event subscription.
- */
- Listener(const Listener&);
-
- /**
- * @brief Stealing constructor
- */
- Listener(Listener&& obj);
-
- /**
- * @brief Destructor
- *
- * Destructor Unregisters event subscription.
- */
- ~Listener();
-
- /**
- * @brief Unregister current event subscription.
- */
- void Unregister();
-
- /**
- * @brief Assignment operator.
- *
- * Assignment make two thins:
- * 1. Unregisters current event subscription.
- * 2. Creates new subscription identical to right value.
- *
- * example:
- * Listener l1 = EventBus::AllListner(std::bind(&MyClass::MyMethod,
- * obj1, _1));
- * Listener l2 = EventBus::AllListner(std::bind(&MyClass::MyMethod,
- * obj2, _1));
- *
- * // subscription on obj1 get unregistered, new registration on obj2
- * // has been set in l1.
- *
- * l1 = l2;
- *
- * EventBus::FireEvent(...) // MyMethod on obj2 will be called 2 times.
- */
- Listener& operator=(const Listener&);
-
- /**
- * @brief Constructor used to create listener subscribed to event.
- */
- Listener(std::list<std::function<void(Event&)>> &owner,
- std::list<std::function<void(Event&)>>::iterator it);
-
- private:
- std::list<std::function<void(Event&)>> *owner_;
- std::list<std::function<void(Event&)>>::iterator it_;
- };
-
- /**
* @brief Global events dispatcher.
*
* How to use Event bus:
* @brief Registers handler for given event type
*/
template <typename T>
- static Listener AddListener(std::function<void(Event&)> func)
+ static utils::Connection AddListener(std::function<void(Event&)> func)
{
return AddListenerInternal(typeid(T), func);
}
void operator=(const EventBus &bus) = delete;
private:
- static Listener AddListenerInternal(const std::type_index,
+ static utils::Connection AddListenerInternal(const std::type_index,
std::function<void(Event&)>);
static EventBus& GetInstance();
EventBus() {}
- std::map<std::type_index, std::list<std::function<void(Event&)>>> callbacks_;
+ std::map<std::type_index, utils::Signal<void(Event&)>> callbacks_;
};
} /* utils */
#include <app_control.h>
#include <functional>
+#include "Utils/Signal.h"
+
namespace utils {
/**
*
* @return return absolute file path to ringtone. Value remains valid
* until class is destructed or function subscribed with
- * RegisterPathUpdateSignalHandler is called.
+ * OnPathUpdated is called.
*/
const std::string& GetRingtonePath() const { return ringtone_; }
/**
- * @brief Register callback called when ringtone path changes.
- * New path will be returned by GetRingtonePath method.
+ * @brief Signal emitted when ringtone path has been updated.
*/
- void RegisterPathUpdateSignalHandler(std::function<void(void)> cb);
+ utils::Signal<void(void)> OnPathUpdated;
private:
std::string ringtone_;
- std::function<void(void)> update_cb_;
bool initialized_;
static void AppControlCb(app_control_h request, app_control_h reply, app_control_result_e result, void *priv);
};
--- /dev/null
+/*
+* Copyright 2016 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 _CLOCK_SIGNAL_H_
+#define _CLOCK_SIGNAL_H_
+
+#include <functional>
+#include <list>
+#include <memory>
+
+namespace utils {
+ /**
+ * @brief Implementation of Signal/Slot infrastructure.
+ *
+ * @details Signals and Slots are widely used technique of connecting
+ * event emission objects with multiple recievers.
+ *
+ * Event emission objects are called signals and are presented by Signal class.
+ * The reciever object is called Slot and is represented by a functor object.
+ *
+ * To connect function object to signal, we use 'Connect' method of signal
+ * object. The method 'Connect' returns object representing connection
+ * between signal and a Slot. As long as connection object is valid,
+ * the emission of events in signal will invoke Slot objects.
+ *
+ * Example:
+ *
+ * void f(int a) {
+ * }
+ *
+ * Signal<void(int)> onClicked; // declare new signal of void(int) type
+ *
+ * auto conn = onClicked.Connect(std::bind(&f); //connect function f to signal
+ *
+ * onClicked(1); // emit signal
+ *
+ * conn.Disconnect(); // disconnect function 'f' from signal
+ *
+ * @note Unlike many other signal-Slot libraries the connection returned by
+ * 'Connect' method follows RAII pattern, so when connection object is being
+ * destructed the target object will be disconnected from signal.
+ */
+ template <typename... T_arg>
+ class Signal;
+
+ /**
+ * @brief Slot structure
+ */
+ template <typename... T_arg>
+ struct Slot;
+
+ /**
+ * @brief Class representing signal connection
+ */
+ template <typename... T_arg>
+ class SignalConnection;
+
+ /**
+ * @brief Base class for all signal connections.
+ */
+ class SignalBaseConnection;
+
+ typedef std::unique_ptr<SignalBaseConnection> Connection;
+
+ /**
+ * @brief Call context
+ */
+ template <typename... T_arg>
+ struct Slot<void(T_arg...)>
+ {
+ Slot(std::function<void(T_arg...)> f) : func(f), delete_me(false) {}
+ /** @brief Function to call */
+ std::function<void(T_arg...)> func;
+ /** @brief slot has been marked for deletion */
+ bool delete_me : 1;
+ };
+
+ /**
+ * @brief Specialized template for signals with functions of type
+ * void (*)(A...)
+ */
+ template <typename... T_arg>
+ class Signal<void(T_arg...)>
+ {
+ public:
+
+ /**
+ * @brief Default constructor
+ */
+ Signal() : on_delete_(false) , recursive_count_(0) {}
+
+ /**
+ * @brief Delete copy constructor
+ *
+ * @param[in] ref reference to Signal
+ *
+ * @details Copying signals should not be possible in order
+ * to avoid unexpected behaviour on object connected to copyied
+ * signal.
+ */
+ Signal(const Signal<void(T_arg...)> &ref) = delete;
+
+ /**
+ * @brief Delete assignment operator
+ *
+ * @param[in] ref reference to Signal
+ */
+ Signal<void(T_arg...)>& operator=(const Signal<void(T_arg...)> &ref) = delete;
+
+ /**
+ * @brief Move constructor
+ *
+ * @param[in] ref r-value reference to Signal
+ */
+ Signal(Signal<void(T_arg...)> &&ref)
+ {
+ this->slots_ = std::move(ref.slots_);
+ }
+
+ /**
+ * @brief Emit signal
+ *
+ * @param[in] a variadic paramenter list
+ *
+ * @details This function will call all connected listeners
+ * (slots) for given signal.
+ */
+ void operator()(T_arg... a)
+ {
+ recursive_count_++;
+ auto it = slots_.begin();
+ while (it != slots_.end()) {
+ if (!it->delete_me) it->func(a...);
+ if (on_delete_) return;
+ ++it;
+ }
+ recursive_count_--;
+ if (!recursive_count_)
+ clean_slots();
+ }
+
+ /**
+ * @brief Connect function f to signal.
+ *
+ * @details This means that every time the signal will be emitted
+ * (with () operator) the function f will be called.
+ */
+ Connection Connect(std::function<void(T_arg...)> f)
+ {
+ Slot<void(T_arg...)> slot(f);
+ slots_.push_back(slot);
+ auto ptr = new SignalConnection<void(T_arg...)>(&slots_.back());
+ return std::unique_ptr<SignalBaseConnection>(ptr);
+ }
+
+ /**
+ * @brief Destructor
+ *
+ * @details Disconnects automatically all conntected Slots
+ */
+ ~Signal()
+ {
+ on_delete_ = true;
+ slots_.clear();
+ }
+ protected:
+ /**
+ * @brief Clear-up deleted slots
+ */
+ void clean_slots()
+ {
+ auto it = slots_.begin();
+ while (it != slots_.end()) {
+ if (it->delete_me)
+ it = slots_.erase(it);
+ else
+ ++it;
+ }
+ }
+
+ /** @brief generic storage for slots */
+ std::list<Slot<void(T_arg...)>> slots_;
+ bool on_delete_;
+ int recursive_count_;
+ };
+
+ /**
+ * @brief Purpose of this class is to allow connections to be stored
+ * in generic containers.
+ */
+ class SignalBaseConnection
+ {
+ public:
+ SignalBaseConnection() {}
+ /** @brief Disconnects registered function from signal. */
+ virtual void Disconnect() {}
+ virtual ~SignalBaseConnection() {}
+ };
+
+ /**
+ * @brief Specialized template for signal connections with functions of type
+ * void (*)(T_arg...)
+ */
+ template <typename... T_arg>
+ class SignalConnection<void(T_arg...)> : public SignalBaseConnection
+ {
+ public:
+ /**
+ * @brief Constructor
+ *
+ * @param[in] it iterator to list element
+ */
+ SignalConnection(Slot<void(T_arg...)> *slot) : slot_(slot) {}
+
+ ~SignalConnection() { Disconnect(); }
+
+ void Disconnect() override
+ {
+ if (slot_) {
+ slot_->delete_me = true;
+ slot_ = nullptr;
+ }
+ }
+
+ bool IsConnected() const
+ {
+ return slot_ != nullptr;
+ }
+
+ /**
+ * @brief R-Value constructor
+ */
+ SignalConnection(SignalConnection&& ref)
+ {
+ slot_ = ref.slot_;
+ ref.slot_ = nullptr;
+ }
+
+ /**
+ * @brief Delete copy constructor
+ */
+ SignalConnection(const SignalConnection& ln) = delete;
+
+ /**
+ * @brief Delete assign operator
+ */
+ SignalConnection<T_arg...> operator=(const SignalConnection& ln) = delete;
+
+ private:
+ Slot<void(T_arg...)> *slot_;
+ };
+
+}; /* utils */
+
+#endif
#include "View/View.h"
#include "Model/WeekFlags.h"
-#include "Utils/EventBus.h"
+#include "Utils/Signal.h"
#include "Utils/Time.h"
#include <functional>
*/
class AlarmView : public ui::IView {
public:
- /** @brief Generic event function */
- typedef std::function<void(int)> SelectCallback;
- /** @brief Selected event. Selected item identifier is passed in parameter. */
- typedef std::function<void(int)> ToggleCallback;
- /** @brief Generic event function */
- typedef std::function<void(void)> ButtonClickedCallback;
- /** @brief Generic event function */
- typedef std::function<void(void)> MenuButtonClickedCallback;
-
- /**
- * @brief Creates AlarmView instance
- * @param main MainView instance
- */
AlarmView(ui::IView &main);
/**
const model::WeekFlags flags, bool active);
/**
- * @brief Registers callback emitted when user has cancelled edit
- * operation.
- *
- * @param[in] func callback to register.
+ * @brief Signal emitted when user clicked "delete" item on Delete popup
*/
- void SetItemToggleCallback(ToggleCallback func) { onToggled_ = func; }
+ utils::Signal<void(void)> OnDeleteItemClicked;
/**
- * @brief Registers callback emitted when user has selected item on
- * list.
- *
- * @param[in] func callback to register.
+ * @brief Signal emitted when user clicked "+" button
*/
- void SetItemSelectCallback(SelectCallback func) { onSelected_ = func; }
+ utils::Signal<void(void)> OnAddButtonClicked;
/**
- * @brief Registers callback emitted when user has clicked "+" floating button
- *
- * @param[in] func callback to register.
+ * @brief Signal emitted when user clicked "menu" hardware button
*/
- void SetButtonClickedCallback(ButtonClickedCallback func) { onClicked_ = func; }
+ utils::Signal<void(void)> OnMenuButtonClicked;
/**
- * @brief Registers callback emitted when user clicked Delete Item
- * on Delete popup
- *
- * @param[in] func callback to register.
+ * @brief Signal emitted when user selected item on alarm list
*/
- void SetDeleteItemClickedCallback(ButtonClickedCallback func) { onDeleteClicked_ = func;}
+ utils::Signal<void(int)> OnItemSelected;
+
/**
- * @brief Registers callback emitted when user clicked "Menu" hardware button
- *
- * @param[in] func callback to register.
+ * @brief Signal emitted when user toggled checkbox on alarm list item
*/
- void SetMenuButtonClickedCallback(MenuButtonClickedCallback func) { onMenuClicked_ = func;}
+ utils::Signal<void(int)> OnItemToggled;
+
Evas_Object *GetEvasObject();
/**
Evas_Object *content_;
Evas_Object *popup_;
Evas_Object *label_;
- SelectCallback onSelected_;
- ToggleCallback onToggled_;
- ButtonClickedCallback onClicked_;
- ButtonClickedCallback onDeleteClicked_;
- MenuButtonClickedCallback onMenuClicked_;
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
void TimeFormatChanged();
};
}
#include "View/PageView.h"
#include "Model/WeekFlags.h"
-#include "Utils/EventBus.h"
+#include "Utils/Signal.h"
#include "Utils/Time.h"
#include <vector>
*/
class DeleteAlarmView : public PageView {
public:
- /** @brief Generic event function */
- typedef std::function<void(void)> ButtonClickedCallback;
-
/**
* @brief Creates DeleteAlarmView instance
*
~DeleteAlarmView();
/**
- * @brief Registers callback emitted when cancel button is clicked
- *
- * @param[in] cb callback to register.
+ * @brief Signal emitted when cancel button is clicked
*/
- void RegisterCancelButtonClickedCallback(ButtonClickedCallback cb) { onCancelButtonClicked_ = cb; }
+ utils::Signal<void(void)> OnCancelButtonClicked;
/**
- * @brief Registers callback emitted when delete button is clicked
- *
- * @param[in] cb callback to register.
+ * @brief Signal emitted when delete button is clicked
*/
- void RegisterDeleteButtonClickedCallback(ButtonClickedCallback cb) { onDeleteButtonClicked_ = cb; }
+ utils::Signal<void(void)> OnDeleteButtonClicked;
+
Evas_Object *GetEvasObject() { return content_; }
/**
Evas_Object *left_btn_;
Evas_Object *right_btn_;
- ButtonClickedCallback onDeleteButtonClicked_;
- ButtonClickedCallback onCancelButtonClicked_;
-
void SelectAllStateSet(bool value);
void UpdateTitle(void);
void CreateSelectAllItem();
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
void TimeFormatChanged();
};
} /* view */
#include "Model/WeekFlags.h"
#include "Model/Alarm.h"
#include "View/WeekFlagsView.h"
-#include "Utils/EventBus.h"
+#include "Utils/Signal.h"
#include "Utils/RingtonePicker.h"
namespace view {
CONFIRM /** User has requested to confirmed discard operation */
};
- /** @brief Generic event function */
- typedef std::function<void(void)> EditDoneCallback;
- /** @brief Generic event function */
- typedef std::function<void(void)> EditCancelCallback;
- /** @brief Generic event function */
- typedef std::function<void(void)> BackButtonCallback;
- /** @brief Event with operation result */
- typedef std::function<void(DiscardPopupOption)> DiscardPopupCallback;
-
/**
- * @brief Registers callback emitted when user has finished edit
+ * @brief Signal emitted when user has finished edit
* operation.
- *
- * @param[in] cb callback to register.
*/
- void RegisterEditDoneCallback(EditDoneCallback cb) { onEditDone_ = cb; }
+ utils::Signal<void(void)> OnEditDone;
/**
- * @brief Registers callback emitted when user has cancelled edit
+ * @brief Signal emitted when user has cancelled edit
* operation.
- *
- * @param[in] cb callback to register.
*/
- void RegisterEditCancelCallback(EditCancelCallback cb) { onEditCancel_ = cb; }
+ utils::Signal<void(void)> OnEditCancel;
/**
- * @brief Registers callback emitted when back button is clicked
- *
- * @param[in] cb callback to register.
+ * @brief Signal emitted when back button is clicked
*/
- void RegisterBackButtonCallback(BackButtonCallback cb) { onBackButton = cb; }
+ utils::Signal<void(void)> OnBackButtonClicked;
/**
- * @brief Registers callback emitted when option has been chosen on
+ * @brief Signal emitted when option has been chosen on
* discard popup
- *
- * @param[in] cb callback to register.
*/
- void RegisterDiscardPopupCallback(DiscardPopupCallback cb) { onDiscardPopupCallback = cb; }
+ utils::Signal<void(DiscardPopupOption)> OnDiscardPopupOptionSelected;
/**
* @brief Constructor
/* child view of EditAlarmView */
WeekFlagsView week_flags_view_;
- EditDoneCallback onEditDone_;
- EditCancelCallback onEditCancel_;
- BackButtonCallback onBackButton;;
- DiscardPopupCallback onDiscardPopupCallback;
-
Elm_Object_Item *type_it_;
Elm_Object_Item *repeat_it_;
Elm_Object_Item *volume_it_;
void RingtonePathUpdateCallback();
const char *GetTitle();
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
void TimeFormatChanged();
+
+ utils::Connection week_flags_popped_conn_;
+ utils::Connection picker_conn_;
};
} /* view */
#include <Elementary.h>
#include "View/MainView.h"
#include "View/View.h"
+#include "Utils/Signal.h"
#include <vector>
#include <functional>
void PopPage();
/**
- * @brief Registers page popped callback
+ * @brief Signal emitted when page is popped.
*/
- void RegisterPoppedCallback(std::function<void(void)>);
+ utils::Signal<void(void)> OnPagePopped;
protected:
/**
Evas_Object *naviframe_;
static void ItemDeletedCallback(void*, Evas_Object*, void *);
- std::vector<std::function<void(void)>> onPopped_;
- void EmitPoppedEvent();
};
};
#include <functional>
#include "View/CounterView.h"
+#include "Utils/Signal.h"
namespace view {
/**
- * @brief Ring view signal type
- */
- enum class RingSignal {
- BUTTON_DISMISS_CLICKED,
- BUTTON_SNOOZE_CLICKED,
-
- MAX,
- };
-
- /**
* @brief Ring's view class
*
* Class creates and displays ring alarm view that shows incoming alarm's
void DisplayTime(int hour, int min, int sec);
/**
- * @brief Registers signal with the RingSignal type.
- *
- * @param[in] func The function to be called on passed type signal
- * @param[in] type The signal type on which callback should be called
+ * @brief Signal emitted when snooze button is clicked.
*/
- void RegisterSignal(std::function<void(void)>func, RingSignal type);
+ utils::Signal<void(void)> OnSnoozeButtonClicked;
/**
- * @brief Emits signal with the assigned type.
- *
- * @param[in] type The type of the signal whose callback must be called
+ * @brief Signal emitted when dismiss button is clicked.
*/
- void EmitSignal(RingSignal type);
+ utils::Signal<void(void)> OnDismissButtonClicked;
/**
* @brief Shows or hides snooze swipe button.
view::CounterView *counter_ = NULL;
- std::vector<std::function<void(void)>> signals_
- = std::vector<std::function<void(void)>>((int)RingSignal::MAX, nullptr);
-
static const char *GROUP;
static const char *EDJE_FILE;
#include "View/CounterView.h"
#include "View/View.h"
+#include "Utils/Signal.h"
#define PART_LAP_NO "txt.lap.no"
#define PART_LAP_SPLIT "txt.lap.split"
namespace view {
/**
- * @brief StopWatch signal type
- */
- enum class Signal {
- BUTTON_START_CLICKED,
- BUTTON_STOP_CLICKED,
- BUTTON_LAP_CLICKED,
- BUTTON_RESUME_CLICKED,
- BUTTON_RESET_CLICKED,
- MAX
- };
-
- /**
* @brief Lap class
*
* Class helper for StopWatch view that stores displayed information
Evas_Object *GetEvasObject(void);
/**
- * @brief Registers StopWatchView callbacks
- *
- * @param[in] func The callback
- * @param[in] type The type of the signal
+ * @brief Signal emitted when start button was clicked.
+ */
+ utils::Signal<void(void)> OnStartButtonClicked;
+
+ /**
+ * @brief Signal emitted when stop button was clicked.
+ */
+ utils::Signal<void(void)> OnStopButtonClicked;
+
+ /**
+ * @brief Signal emitted when lap button was clicked.
+ */
+ utils::Signal<void(void)> OnLapButtonClicked;
+
+ /**
+ * @brief Signal emitted when resume button was clicked.
*/
- void RegisterSignal(std::function<void(void)>func, Signal type);
+ utils::Signal<void(void)> OnResumeButtonClicked;
+
+ /**
+ * @brief Signal emitted when reset button was clicked.
+ */
+ utils::Signal<void(void)> OnResetButtonClicked;
/**
* @brief Shows running menu
void CreateMenuButtons(void);
Evas_Object *CreateList(void);
void FreeListItemsData(Evas_Object *list);
- void EmitSignal(Signal type);
const char *GetEdjeFilePath(void);
- std::vector<std::function<void(void)>> signals
- = std::vector<std::function<void(void)>> ((int)Signal::MAX, nullptr);
-
static const char *EDJE_FILE;
static const char *GROUP;
#include "View/View.h"
#include "View/PageView.h"
#include "View/CounterView.h"
+#include "Utils/Signal.h"
namespace view {
/**
- * @brief Timer's signal type
- */
- enum class TimerSignal {
- BUTTON_HOUR_INCREASE_CLICKED,
- BUTTON_MINUTE_INCREASE_CLICKED,
- BUTTON_SECOND_INCREASE_CLICKED,
-
- BUTTON_HOUR_DECREASE_CLICKED,
- BUTTON_MINUTE_DECREASE_CLICKED,
- BUTTON_SECOND_DECREASE_CLICKED,
-
- BUTTON_START_CLICKED,
- BUTTON_PAUSE_CLICKED,
- BUTTON_CANCEL_CLICKED,
- BUTTON_RESUME_CLICKED,
- BUTTON_RESET_CLICKED,
-
- ON_COUNTER_FOCUS,
- ON_COUNTER_UNFOCUS,
-
- MAX,
- };
-
- /**
* @brief Timer's view class
*
* Class displays timer's view for user interaction with backend.
Evas_Object *GetEvasObject();
/**
- * @brief Registers TimerView callback
- *
- * @param[in] func The function to be called
- * @param[in] type The type of the signal on which callback is called
+ * @brief Signal emitted when start button has been clicked.
+ */
+ utils::Signal<void(void)> OnStartButtonClicked;
+
+ /**
+ * @brief Signal emitted when start button has been clicked.
+ */
+ utils::Signal<void(void)> OnPauseButtonClicked;
+
+ /**
+ * @brief Signal emitted when cancel button has been clicked.
*/
- void RegisterSignal(std::function<void(void)>func, TimerSignal type);
+ utils::Signal<void(void)> OnCancelButtonClicked;
+
+ /**
+ * @brief Signal emitted when resume button has been clicked.
+ */
+ utils::Signal<void(void)> OnResumeButtonClicked;
+
+ /**
+ * @brief Signal emitted when reset button has been clicked.
+ */
+ utils::Signal<void(void)> OnResetButtonClicked;
+
+ /**
+ * @brief Signal emitted when counter has been focused.
+ */
+ utils::Signal<void(void)> OnCounterFocus;
+
+ /**
+ * @brief Signal emitted when counter has been unfocued.
+ */
+ utils::Signal<void(void)> OnCounterUnfocused;
/**
* @brief Enables Start button
};
Time set_time_;
- std::vector<std::function<void(void)>> signals
- = std::vector<std::function<void(void)>>((int)TimerSignal::MAX, nullptr);
-
void CreateButton(Evas_Object *parent, const char *name,
const char *part, Evas_Smart_Cb cb);
void UnfocusEntries();
- void EmitSignal(TimerSignal type);
-
static const char *EDJE_FILE;
static const char *GROUP;
static const char *GetEdjeFilePath(void);
#include "View/PageView.h"
#include "Model/Location.h"
#include "Utils/Time.h"
+#include "Utils/Signal.h"
namespace view {
/**
public:
/**
- * @brief Enumeration for callbacks signals
- */
- enum class SignalType {
- BUTTON_CANCEL_CLICKED, //!< BUTTON_CANCEL_CLICKED
- BUTTON_DELETE_CLICKED, //!< BUTTON_DELETE_CLICKED
- BUTTON_BACK_CLICKED, //!< BUTTON_BACK_CLICKED
- CHECKBOX_SELECT_ALL_CLICKED,//!< CHECKBOX_SELECT_ALL_CLICKED
- LIST_ITEM_CLICKED, //!< LIST_ITEM_CLICKED
- MAX //!< MAX
- };
-
- /**
* @brief Creates Class object, push new page and invokes CreateContent().
* @param main MainView reference.
*/
Evas_Object *GetEvasObject() override;
/**
- * @brief Registers signals
- *
- * @param s signal enumerator
- * @param func function invoked when the signal will be emitted
+ * @brief Signal emitted when cancel button has been clicked.
+ */
+ utils::Signal<void(void)> OnCancelButtonClicked;
+
+ /**
+ * @brief Signal emitted when delete button has been clicked.
+ */
+ utils::Signal<void(void)> OnDeleteButtonClicked;
+
+ /**
+ * @brief Signal emitted when back button has been clicked.
+ */
+ utils::Signal<void(void)> OnBackButtonClicked;
+
+ /**
+ * @brief Signal emitted when select all checkbox has been clicked.
+ */
+ utils::Signal<void(void)> OnSelectAllCheckboxClicked;
+
+ /**
+ * @brief Signal emitted when list item has been clicked.
*/
- void RegisterSignal(SignalType s, std::function<void(void)>func);
+ utils::Signal<void(void)> OnListItemClicked;
/**
* @brief Appends items(Locations) from given list to delete View genlist
bool all_selected_;
/**
- * @brief list of signals
- */
- std::vector<std::function<void(void)>> signals_
- = std::vector<std::function<void(void)>>((int)SignalType::MAX, nullptr);
-
- /**
* @brief Callback invoked when any item of list is clicked
*
* @param data user data
void CreateSelectAll();
/**
- * @brief emits signal
- *
- * @details it cause invocation of registered function
- *
- * @param s signal enumerator
- */
- void EmitSignal(SignalType s);
-
- /**
* @brief Emits BUTTON_CANCEL_CLICKED signal.
*
* @details Invoked when "Cancel" button is clicked
*/
- static void OnCancelButtonClicked(void *data, Evas_Object *obj, void *event_info);
+ static void CancelButtonClicked(void *data, Evas_Object *obj, void *event_info);
/**
* @brief Emits BUTTON_DELETE_CLICKED signal.
*
* @details Invoked when "Delete" button is clicked
*/
- static void OnDeleteButtonClicked(void *data, Evas_Object *obj, void *event_info);
+ static void DeleteButtonClicked(void *data, Evas_Object *obj, void *event_info);
/**
* @brief Emits CHECKBOX_SELECT_ALL_CLICKED signal and toggle "Select all" checkbox state.
*
* @details Invoked when "Select all" item or checkbox is clicked
*/
- static void OnSelectAllClicked(void *data, Evas_Object *obj, void *event_info);
+ static void SelectAllClicked(void *data, Evas_Object *obj, void *event_info);
/**
* @brief Emits LIST_ITEM_CLICKED signal and toggle checkbox state.
*/
static Eina_Bool TimeUpdateCb(void *data);
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
/**
* @brief Invoke when platform time format changes.
#include "View/PageView.h"
#include "Model/Location.h"
#include "Utils/Time.h"
+#include "Utils/Signal.h"
namespace view {
public:
/**
- * @brief Enumeration for callbacks signals
- */
- enum class Signals {
- LIST_REORDERED, //!< LIST_REORDERED
- BUTTON_BACK_CLICKED, //!< BUTTON_BACK_CLICKED
- MAX //!< MAX
- };
-
- /**
* @brief Creates Class object.
*/
WorldClockReorderView(view::MainView &main);
Evas_Object *GetEvasObject() override;
/**
- * @brief Registers signals
- *
- * @param s signal enumerator
- * @param func function invoked when the signal will be emitted
+ * @brief Signal emitted when list has been reordered.
*/
- void RegisterSignalHandler(Signals s, std::function<void(void)>func);
+ utils::Signal<void(void)> OnListReordered;
/**
+ * @brief Signal emitted when back button has been clicked.
+ */
+ utils::Signal<void(void)> OnBackButtonClicked;
+ /**
* @brief Appends items(Locations) from given list to delete View genlist
*
* @details The list is identical with user_locations_ list
Ecore_Timer *timer_;
/**
- * @brief list of signals
- */
- std::vector<std::function<void(void)>> signals_
- = std::vector<std::function<void(void)>>((int)Signals::MAX, nullptr);
-
- /**
* @brief Gets content for genlist item part
*
* @param data user data
static Evas_Object *CreatePaddingObject(Evas_Object *parent, int width);
/**
- * @brief emits signal
- *
- * @details it cause invocation of registered function
- *
- * @param s signal enumerator
- */
- void EmitSignal(Signals s);
-
- /**
* @brief Emits LIST_REORDERED signal
*
* @remarks Invoked everytime list is reordered
*/
- static void OnListReordered(void *data, Evas_Object *obj, void *event_info);
+ static void ListReordered(void *data, Evas_Object *obj, void *event_info);
/**
* @brief Emits BUTTON_BACK_CLICKED signal
*
* @remarks Invoked by clicking BACK naviframe button or back hardware key
*/
- static void OnBackButtonClicked(void *data, Evas_Object *obj, void *event_info);
+ static void BackButtonClicked(void *data, Evas_Object *obj, void *event_info);
/**
* @brief Timer callback for time updates.
*/
static Eina_Bool TimeUpdateCb(void *data);
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
/**
* @brief Invoke when platform time format changes.
#include "View/PageView.h"
#include "View/View.h"
#include "View/WorldClockMap.h"
-#include "Utils/EventBus.h"
+#include "Utils/Signal.h"
namespace view {
/**
- * @brief Enumeration for callbacks signals
- */
- enum class WorldClockSignals {
- BUTTON_LEFT_ARROW_CLICKED,
- BUTTON_RIGHT_ARROW_CLICKED,
- BUTTON_MORE_CLICKED,
- BUTTON_MORE_DELETE_CLICKED,
- BUTTON_MORE_REORDER_CLICKED,
-
- CUSTOM_LIST_ITEM_CLICKED,
- CUSTOM_LIST_ITEM_ADD,
- CUSTOM_LIST_UPDATE_REQUEST,
-
- MAX
- };
-
- /**
* @brief Class representing World Clock view and is responsible for UI layer of the view.
*
* @details It communicates with external classes by sending signals and do
Evas_Object *GetEvasObject(){return world_clock_main_;};
/**
- * @brief Registers signals
- *
- * @param[in] func function invoked when the signal will be emitted
- * @param[in] signal signal enumerator
+ * @brief Signal emitted when left arrow has been clicked.
+ */
+ utils::Signal<void(void)> OnLeftArrowClicked;
+
+ /**
+ * @brief Signal emitted when right arrow has been clicked.
+ */
+ utils::Signal<void(void)> OnRightArrowClicked;
+
+ /**
+ * @brief Signal emitted when menu button has been clicked.
+ */
+ utils::Signal<void(void)> OnMenuButtonClicked;
+
+ /**
+ * @brief Signal emitted when delete item has been clicked.
*/
- void RegisterSignal(std::function<void(void)>func, view::WorldClockSignals signal);
+ utils::Signal<void(void)> OnMoreDeleteButtonClicked;
+
+ /**
+ * @brief Signal emitted when reorder item has been clicked.
+ */
+ utils::Signal<void(void)> OnMoreReorderButtonClicked;
+
+ /**
+ * @brief Signal emitted when custom list item has been clicked.
+ */
+ utils::Signal<void(void)> OnCustomListItemClicked;
+
+ /**
+ * @brief Signal emitted when custom list item has been added.
+ */
+ utils::Signal<void(void)> OnCustomListItemAdded;
+
+ /**
+ * @brief Signal emitted when custom list item has been updated.
+ */
+ utils::Signal<void(void)> OnCustomListUpdateRequested;
/**
* @brief Updates map area and timezone details
void SetItemLastClicked(const model::Location *location);
void SetItemToAdd(model::Location *l);
- void EmitSignal(view::WorldClockSignals signal);
const char *OffsetToString(int offset);
Ecore_Timer *timer_;
WorldClockMap *map_;
- std::vector<std::function<void(void)>> signals
- = std::vector<std::function<void(void)>>((int)WorldClockSignals::MAX, nullptr);
-
- utils::Listener time_format_change_listener_;
+ utils::Connection time_format_change_listener_;
void TimeFormatChanged();
model::Timezone current_timezone_; /* Currently displayed timezone */
ecore_animator_del(animator_);
}
-void CounterAnimator::RegisterSignal(std::function<void(void)>func)
-{
- signals_.push_back(func);
-}
-
-
Eina_Bool CounterAnimator::Task(void *data)
{
CounterAnimator *object = (CounterAnimator *)data;
- object->EmitSignal();
+ object->OnTick();
return ECORE_CALLBACK_RENEW;
}
-void CounterAnimator::EmitSignal()
-{
- for (auto func: signals_)
- func();
-}
-
} //namespace common
stop_watch_presenter_ = new StopWatchPresenter((StopWatchView *)main_view_.GetView(STOP_WATCH), stop_watch_model_);
timer_presenter_ = new TimerPresenter((TimerView *)main_view_.GetView(TIMER), timer_model_);
- listeners_.push_back(utils::EventBus::AddListener<AlarmCreateRequestEvent>(
+ connections_.push_back(utils::EventBus::AddListener<AlarmCreateRequestEvent>(
std::bind(&MainController::CreateNewAlarmPage, this, _1)));
- listeners_.push_back(utils::EventBus::AddListener<AlarmDeleteRequestEvent>(
+ connections_.push_back(utils::EventBus::AddListener<AlarmDeleteRequestEvent>(
std::bind(&MainController::CreateNewDeleteAlarmsPage, this, _1)));
- listeners_.push_back(utils::EventBus::AddListener<AlarmEditRequestEvent>(
+ connections_.push_back(utils::EventBus::AddListener<AlarmEditRequestEvent>(
std::bind(&MainController::CreateEditAlarmPage, this, _1)));
- listeners_.push_back(utils::EventBus::AddListener<WorldClockDeleteRequestEvent>(
+ connections_.push_back(utils::EventBus::AddListener<WorldClockDeleteRequestEvent>(
std::bind(&MainController::CreateNewWorldClockDeletePage, this, _1)));
- listeners_.push_back(utils::EventBus::AddListener<WorldClockReorderRequestEvent>(
+ connections_.push_back(utils::EventBus::AddListener<WorldClockReorderRequestEvent>(
std::bind(&MainController::CreateNewWorldClockReorderPage, this, _1)));
initialized_ = true;
delete timer_presenter_;
delete timer_model_;
- listeners_.clear();
+ connections_.clear();
initialized_ = false;
}
char *tz;
int current_tz = 11; //GMT+0
- parameter_signals_.resize((int)ParameterSignalType::MAX);
- signals_.resize((int)SignalType::MAX);
LoadItemsList();
int ret = preference_get_int("WORLD_CLOCK_MAP_CURRENT_TIMEZONE", ¤t_tz);
DBG();
user_locations_ = locations;
- EmitSignal(SignalType::CUSTOM_LIST_CHANGED);
+ OnCustomListChanged();
}
bool WorldClock::AddUserLocation(const model::Location *l)
for (auto it = user_locations_.begin(); it != user_locations_.end(); ++it) {
if (!((*it)->name.compare(d_it->name)) && !((*it)->country.compare(d_it->country))) {
- EmitSignal(ParameterSignalType::USER_LOCATION_REMOVED, **it);
+ OnUserLocationRemoved(**it);
user_locations_.erase(it);
break;
}
return location;
}
-
-void WorldClock::RegisterSignalHandler(ParameterSignalType signal, std::function<void(const model::Location &)> func)
-{
- parameter_signals_.at((int)signal) = func;
-}
-
-void WorldClock::EmitSignal(ParameterSignalType signal, const model::Location &location)
-{
- if (parameter_signals_.at((int)signal) != nullptr) {
- parameter_signals_.at((int)signal)(location);
- }
-}
-
-void WorldClock::RegisterSignalHandler(SignalType signal, std::function<void(void)> func)
-{
- signals_.at((int)signal) = func;
-}
-
-void WorldClock::EmitSignal(SignalType signal)
-{
- if (signals_.at((int)signal) != nullptr) {
- signals_.at((int)signal)();
- }
-}
AlarmPresenter::AlarmPresenter(AlarmView *v, AlarmProvider *m) : view_(v), model_(m)
{
- view_->SetButtonClickedCallback(std::bind(&AlarmPresenter::OnAddButtonClicked, this));
- view_->SetDeleteItemClickedCallback(std::bind(&AlarmPresenter::OnDeleteItemClicked, this));
- view_->SetItemToggleCallback(std::bind(&AlarmPresenter::OnItemActiveStatusChanged, this, _1));
- view_->SetItemSelectCallback(std::bind(&AlarmPresenter::OnItemSelected, this, _1));
- view_->SetMenuButtonClickedCallback(std::bind(&AlarmPresenter::OnMenuButtonClicked, this));
-
- listeners_.push_back(EventBus::AddListener<AlarmAddedEvent>(
+ connections_.push_back(
+ view_->OnAddButtonClicked.Connect(std::bind(&AlarmPresenter::OnAddButtonClicked, this)));
+ connections_.push_back(
+ view_->OnDeleteItemClicked.Connect(std::bind(&AlarmPresenter::OnDeleteItemClicked, this)));
+ connections_.push_back(
+ view_->OnItemToggled.Connect(std::bind(&AlarmPresenter::OnItemActiveStatusChanged, this, _1)));
+ connections_.push_back(
+ view_->OnItemSelected.Connect(std::bind(&AlarmPresenter::OnItemSelected, this, _1)));
+ connections_.push_back(
+ view_->OnMenuButtonClicked.Connect(std::bind(&AlarmPresenter::OnMenuButtonClicked, this)));
+
+ connections_.push_back(EventBus::AddListener<AlarmAddedEvent>(
std::bind(&AlarmPresenter::OnAlarmAddedEvent, this, _1)));
- listeners_.push_back(EventBus::AddListener<AlarmRemovedEvent>(
+ connections_.push_back(EventBus::AddListener<AlarmRemovedEvent>(
std::bind(&AlarmPresenter::OnAlarmRemovedEvent, this, _1)));
- listeners_.push_back(EventBus::AddListener<AlarmEditedEvent>(
+ connections_.push_back(EventBus::AddListener<AlarmEditedEvent>(
std::bind(&AlarmPresenter::OnAlarmEditedEvent, this, _1)));
ShowAll();
DeleteAlarmPresenter::DeleteAlarmPresenter(DeleteAlarmView *view, AlarmProvider *model)
: view_(view), model_(model)
{
- view->RegisterCancelButtonClickedCallback(
+ connections_.push_back(
+ view->OnCancelButtonClicked.Connect(
std::bind(&DeleteAlarmPresenter::OnCancelButtonClicked, this)
- );
- view->RegisterDeleteButtonClickedCallback(
+ ));
+ connections_.push_back(
+ view->OnDeleteButtonClicked.Connect(
std::bind(&DeleteAlarmPresenter::OnDeleteButtonClicked, this)
- );
+ ));
std::vector<std::reference_wrapper<Alarm>> alarms = model_->GetAlarms();
EditAlarmPresenter::EditAlarmPresenter(model::AlarmProvider *provider, model::Alarm *alarm, view::EditAlarmView& view) :
provider_(provider), alarm_(alarm), view_(view)
{
- view_.RegisterEditDoneCallback(std::bind(&EditAlarmPresenter::OnEditDone, this));
- view_.RegisterEditCancelCallback(std::bind(&EditAlarmPresenter::OnEditCancel, this));
- view_.RegisterBackButtonCallback(std::bind(&EditAlarmPresenter::OnBackButton, this));
+ connections_.push_back(
+ view_.OnEditDone.Connect(std::bind(&EditAlarmPresenter::OnEditDone, this)));
+ connections_.push_back(
+ view_.OnEditCancel.Connect(std::bind(&EditAlarmPresenter::OnEditCancel, this)));
+ connections_.push_back(
+ view_.OnBackButtonClicked.Connect(std::bind(&EditAlarmPresenter::OnBackButton, this)));
+ connections_.push_back(
+ view_.OnDiscardPopupOptionSelected.Connect(std::bind(&EditAlarmPresenter::OnDiscardPopupOptionClicked, this, _1)))
+ ;
info_ = GetInfoForAlarm(alarm);
view_.SetData(info_);
view_.SetMode(alarm == nullptr ? EditAlarmView::Mode::Create : EditAlarmView::Mode::Edit);
void EditAlarmPresenter::OnDiscardPopupOptionClicked(EditAlarmView::DiscardPopupOption option)
{
- view_.RegisterDiscardPopupCallback(nullptr);
-
switch (option)
{
case EditAlarmView::DiscardPopupOption::CANCEL:
if (!CompareAlarmInfoStructures(info_, view_.GetData()))
{
- view_.RegisterDiscardPopupCallback(std::bind(&EditAlarmPresenter::OnDiscardPopupOptionClicked, this, _1));
view_.ShowDiscardPopup();
} else {
view_.PopPage();
RingPresenter::RingPresenter(view::RingView *view, model::Ring *model)
: view_(view), model_(model)
{
- animator_.RegisterSignal(std::bind(&RingPresenter::TimeUpdateRequest, this));
-
- view_->RegisterSignal(std::bind(&RingPresenter::DismissButtonClicked, this),
- view::RingSignal::BUTTON_DISMISS_CLICKED);
- view_->RegisterSignal(std::bind(&RingPresenter::SnoozeButtonClicked, this),
- view::RingSignal::BUTTON_SNOOZE_CLICKED);
-
- listeners_.push_back(utils::EventBus::AddListener<model::RingNewAlarmEvent>(
+ connections_.push_back(animator_.OnTick.Connect(
+ std::bind(&RingPresenter::TimeUpdateRequest, this)));
+ connections_.push_back(view_->OnDismissButtonClicked.Connect(
+ std::bind(&RingPresenter::DismissButtonClicked, this)));
+ connections_.push_back(view->OnSnoozeButtonClicked.Connect(
+ std::bind(&RingPresenter::SnoozeButtonClicked, this)));
+
+ connections_.push_back(utils::EventBus::AddListener<model::RingNewAlarmEvent>(
std::bind(&RingPresenter::AlarmHandle,
this, std::placeholders::_1)));
- listeners_.push_back(utils::EventBus::AddListener<model::RingTimeoutEvent>(
+ connections_.push_back(utils::EventBus::AddListener<model::RingTimeoutEvent>(
std::bind(&RingPresenter::TimeoutHandle,
this, std::placeholders::_1)));
}
StopWatchPresenter::StopWatchPresenter(view::StopWatchView *ui, model::StopWatch *model)
: ui_(ui), model_(model)
{
- ui_->RegisterSignal(std::bind(&StopWatchPresenter::StartButtonClicked, this),
- view::Signal::BUTTON_START_CLICKED);
- ui_->RegisterSignal(std::bind(&StopWatchPresenter::StopButtonClicked, this),
- view::Signal::BUTTON_STOP_CLICKED);
- ui_->RegisterSignal(std::bind(&StopWatchPresenter::ResumeButtonClicked, this),
- view::Signal::BUTTON_RESUME_CLICKED);
- ui_->RegisterSignal(std::bind(&StopWatchPresenter::ResetButtonClicked, this),
- view::Signal::BUTTON_RESET_CLICKED);
- ui_->RegisterSignal(std::bind(&StopWatchPresenter::LapButtonClicked, this),
- view::Signal::BUTTON_LAP_CLICKED);
-
- animator_.RegisterSignal(std::bind(&StopWatchPresenter::TimeUpdateRequest, this));
+ connections_.push_back(ui_->OnStartButtonClicked.Connect(
+ std::bind(&StopWatchPresenter::StartButtonClicked, this)));
+ connections_.push_back(ui_->OnStopButtonClicked.Connect(
+ std::bind(&StopWatchPresenter::StopButtonClicked, this)));
+ connections_.push_back(ui_->OnResumeButtonClicked.Connect(
+ std::bind(&StopWatchPresenter::ResumeButtonClicked, this)));
+ connections_.push_back(ui_->OnResetButtonClicked.Connect(
+ std::bind(&StopWatchPresenter::ResetButtonClicked, this)));
+ connections_.push_back(ui_->OnLapButtonClicked.Connect(
+ std::bind(&StopWatchPresenter::LapButtonClicked, this)));
+ connections_.push_back(animator_.OnTick.Connect(
+ std::bind(&StopWatchPresenter::TimeUpdateRequest, this)));
}
StopWatchPresenter::~StopWatchPresenter()
TimerPresenter::TimerPresenter(view::TimerView *view, model::Timer *model)
: view_(view), model_(model)
{
-
- view_->RegisterSignal(std::bind(&TimerPresenter::StartButtonClicked, this),
- view::TimerSignal::BUTTON_START_CLICKED);
- view_->RegisterSignal(std::bind(&TimerPresenter::PauseButtonClicked, this),
- view::TimerSignal::BUTTON_PAUSE_CLICKED);
- view_->RegisterSignal(std::bind(&TimerPresenter::ResumeButtonClicked, this),
- view::TimerSignal::BUTTON_RESUME_CLICKED);
- view_->RegisterSignal(std::bind(&TimerPresenter::CancelButtonClicked, this),
- view::TimerSignal::BUTTON_CANCEL_CLICKED);
- view_->RegisterSignal(std::bind(&TimerPresenter::ResetButtonClicked, this),
- view::TimerSignal::BUTTON_RESET_CLICKED);
-
- animator_.RegisterSignal(std::bind(&TimerPresenter::TimeUpdateRequest, this));
+ connections_.push_back(view_->OnStartButtonClicked.Connect(
+ std::bind(&TimerPresenter::StartButtonClicked, this)));
+ connections_.push_back(view_->OnPauseButtonClicked.Connect(
+ std::bind(&TimerPresenter::PauseButtonClicked, this)));
+ connections_.push_back(view_->OnResumeButtonClicked.Connect(
+ std::bind(&TimerPresenter::ResumeButtonClicked, this)));
+ connections_.push_back(view_->OnCancelButtonClicked.Connect(
+ std::bind(&TimerPresenter::CancelButtonClicked, this)));
+ connections_.push_back(view_->OnResetButtonClicked.Connect(
+ std::bind(&TimerPresenter::ResetButtonClicked, this)));
+ connections_.push_back(animator_.OnTick.Connect(
+ std::bind(&TimerPresenter::TimeUpdateRequest, this)));
}
TimerPresenter::~TimerPresenter()
model_(model), delete_view_(view)
{
DBG("");
- delete_view_->RegisterSignal(view::WorldClockDeleteItemsView::SignalType::BUTTON_CANCEL_CLICKED,
- std::bind(&WorldClockDeletePresenter::OnCancelClicked, this));
- delete_view_->RegisterSignal(view::WorldClockDeleteItemsView::SignalType::BUTTON_DELETE_CLICKED,
- std::bind(&WorldClockDeletePresenter::OnDeleteClicked, this));
- delete_view_->RegisterSignal(view::WorldClockDeleteItemsView::SignalType::CHECKBOX_SELECT_ALL_CLICKED,
- std::bind(&WorldClockDeletePresenter::OnSelectAllClicked, this));
- delete_view_->RegisterSignal(view::WorldClockDeleteItemsView::SignalType::LIST_ITEM_CLICKED,
- std::bind(&WorldClockDeletePresenter::OnListItemClicked, this));
+ connections_.push_back(delete_view_->OnCancelButtonClicked.Connect(
+ std::bind(&WorldClockDeletePresenter::OnCancelClicked, this)));
+ connections_.push_back(delete_view_->OnDeleteButtonClicked.Connect(
+ std::bind(&WorldClockDeletePresenter::OnDeleteClicked, this)));
+ connections_.push_back(delete_view_->OnSelectAllCheckboxClicked.Connect(
+ std::bind(&WorldClockDeletePresenter::OnSelectAllClicked, this)));
+ connections_.push_back(delete_view_->OnListItemClicked.Connect(
+ std::bind(&WorldClockDeletePresenter::OnListItemClicked, this)));
delete_view_->PushPage();
delete_view_->AppendItems(model_->user_locations_);
WorldClockPresenter::WorldClockPresenter(WorldClockView *view, WorldClock *model)
: view_(view), model_(model)
{
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnLeftArrowButtonClicked, this),
- WorldClockSignals::BUTTON_LEFT_ARROW_CLICKED);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnRightArrowButtonClicked, this),
- WorldClockSignals::BUTTON_RIGHT_ARROW_CLICKED);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnCustomListItemClicked, this),
- WorldClockSignals::CUSTOM_LIST_ITEM_CLICKED);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnItemAdded, this),
- WorldClockSignals::CUSTOM_LIST_ITEM_ADD);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMapViewUpdateRequest, this),
- WorldClockSignals::CUSTOM_LIST_UPDATE_REQUEST);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreButtonClicked, this),
- WorldClockSignals::BUTTON_MORE_CLICKED);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreDeleteButtonClicked, this),
- WorldClockSignals::BUTTON_MORE_DELETE_CLICKED);
- view_->RegisterSignal(std::bind(&WorldClockPresenter::OnMoreReorderButtonClicked, this),
- WorldClockSignals::BUTTON_MORE_REORDER_CLICKED);
-
- model_->RegisterSignalHandler(WorldClock::ParameterSignalType::USER_LOCATION_REMOVED,
- std::bind(&WorldClockPresenter::OnItemDeleted, this, _1));
-
- model_->RegisterSignalHandler(WorldClock::SignalType::CUSTOM_LIST_CHANGED,
- std::bind(&WorldClockPresenter::OnCustomListChanged, this));
+ connections_.push_back(view_->OnLeftArrowClicked.Connect(
+ std::bind(&WorldClockPresenter::OnLeftArrowButtonClicked, this)));
+ connections_.push_back(view_->OnRightArrowClicked.Connect(
+ std::bind(&WorldClockPresenter::OnRightArrowButtonClicked, this)));
+ connections_.push_back(view_->OnCustomListItemClicked.Connect(
+ std::bind(&WorldClockPresenter::OnCustomListItemClicked, this)));
+ connections_.push_back(view_->OnCustomListItemAdded.Connect(
+ std::bind(&WorldClockPresenter::OnItemAdded, this)));
+ connections_.push_back(view_->OnCustomListUpdateRequested.Connect(
+ std::bind(&WorldClockPresenter::OnMapViewUpdateRequest, this)));
+ connections_.push_back(view_->OnMenuButtonClicked.Connect(
+ std::bind(&WorldClockPresenter::OnMoreButtonClicked, this)));
+ connections_.push_back(view_->OnMoreDeleteButtonClicked.Connect(
+ std::bind(&WorldClockPresenter::OnMoreDeleteButtonClicked, this)));
+ connections_.push_back(view->OnMoreReorderButtonClicked.Connect(
+ std::bind(&WorldClockPresenter::OnMoreReorderButtonClicked, this)));
+
+ connections_.push_back(model_->OnUserLocationRemoved.Connect(
+ std::bind(&WorldClockPresenter::OnItemDeleted, this, _1)));
+ connections_.push_back(model_->OnCustomListChanged.Connect(
+ std::bind(&WorldClockPresenter::OnCustomListChanged, this)));
OnMapViewUpdateRequest();
WorldClockReorderView *view, model::WorldClock *model) :
model_(model), reorder_view_(view)
{
- reorder_view_->RegisterSignalHandler(WorldClockReorderView::Signals::LIST_REORDERED,
- std::bind(&WorldClockReorderPresenter::OnListReordered, this));
+ connections_.push_back(reorder_view_->OnListReordered.Connect(
+ std::bind(&WorldClockReorderPresenter::OnListReordered, this)));
- reorder_view_->RegisterSignalHandler(WorldClockReorderView::Signals::BUTTON_BACK_CLICKED,
- std::bind(&WorldClockReorderPresenter::OnBackClicked, this));
+ connections_.push_back(reorder_view_->OnBackButtonClicked.Connect(
+ std::bind(&WorldClockReorderPresenter::OnBackClicked, this)));
reorder_view_->PushPage();
reorder_view_->AppendItems(model_->user_locations_);
void EventBus::FireEvent(Event& event)
{
EventBus &bus = GetInstance();
-
- auto it = bus.callbacks_[typeid(event)].begin();
- auto end = bus.callbacks_[typeid(event)].end();
-
- for (; it != end; ++it) {
- (*it)(event);
- }
+ bus.callbacks_[typeid(event)](event);
}
-Listener EventBus::AddListenerInternal(const std::type_index type, std::function<void(Event&)> cb)
+utils::Connection EventBus::AddListenerInternal(const std::type_index type, std::function<void(Event&)> cb)
{
EventBus &bus = GetInstance();
- bus.callbacks_[type].push_back(cb);
- return Listener(bus.callbacks_[type], --bus.callbacks_[type].end());
-}
-
-Listener::Listener(std::list<std::function<void(Event&)>> &owner,
- std::list<std::function<void(Event&)>>::iterator it)
-{
- owner_ = std::addressof(owner);
- it_ = it;
-}
-
-Listener::~Listener()
-{
- Unregister();
-}
-
-void Listener::Unregister()
-{
- if (owner_) {
- owner_->erase(it_);
- owner_ = nullptr;
- }
-}
-
-Listener::Listener(Listener&& ref)
-{
- owner_ = ref.owner_;
- it_ = std::move(ref.it_);
- ref.owner_ = nullptr;
-}
-
-Listener::Listener(const Listener& ln)
-{
- owner_ = ln.owner_;
- if (owner_) {
- owner_->push_back(*ln.it_);
- it_ = --owner_->end();
- }
-}
-
-Listener& Listener::operator=(const Listener& ln)
-{
- // unregister first, as subscription may be set.
- Unregister();
-
- owner_ = ln.owner_;
- if (owner_) {
- owner_->push_back(*ln.it_);
- it_ = --owner_->end();
- }
- return *this;
+ return bus.callbacks_[type].Connect(cb);
}
DBG("Recieved ringthone path: %s", ringtone_path[0]);
instance->ringtone_ = ringtone_path[0];
free(ringtone_path);
- if (instance->update_cb_)
- instance->update_cb_();
+ instance->OnPathUpdated();
}
bool RingtonePicker::ShowDialog()
return true;
}
-void RingtonePicker::RegisterPathUpdateSignalHandler(std::function<void(void)> cb)
-{
- update_cb_ = cb;
-}
-
};
else
elm_object_item_signal_emit(id->it, "alarm,state,disabled", "clock");
- if (id->instance->onToggled_) id->instance->onToggled_((uintptr_t)id->it);
+ id->instance->OnItemToggled((uintptr_t)id->it);
}
void AlarmView::ItemRealized(void *data, Evas_Object *obj, void *info)
void AlarmView::ItemSelected(void *data, Evas_Object *obj, void *info)
{
ItemData *id = static_cast<ItemData*>(data);
- if (id->instance->onSelected_) id->instance->onSelected_((uintptr_t)id->it);
+ id->instance->OnItemSelected((uintptr_t)id->it);
elm_genlist_item_selected_set(id->it, EINA_FALSE);
}
void AlarmView::MoreButtonClicked(void *data, Evas_Object *obj, void *info)
{
AlarmView *view = static_cast<AlarmView*>(data);
- if (view->onMenuClicked_) view->onMenuClicked_();
+ view->OnMenuButtonClicked();
}
void AlarmView::Clear()
void AlarmView::ButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
AlarmView *view = static_cast<AlarmView*>(data);
- if (view->onClicked_) view->onClicked_();
+ view->OnAddButtonClicked();
}
void AlarmView::DismissPopupCallback(void *data, Evas_Object *obj, void *event_info)
void AlarmView::PopupDeleteItemCallback(void *data, Evas_Object *obj, void *event_info)
{
AlarmView *view = static_cast<AlarmView*>(data);
- if (view->onDeleteClicked_) view->onDeleteClicked_();
+ view->OnDeleteItemClicked();
evas_object_del(view->popup_);
view->popup_ = nullptr;
}
void DeleteAlarmView::OnCancelButtonClickedCb(void *data, Evas_Object *obj, void *event)
{
DeleteAlarmView *view = static_cast<DeleteAlarmView*>(data);
- if (view->onCancelButtonClicked_) view->onCancelButtonClicked_();
+ view->OnCancelButtonClicked();
}
void DeleteAlarmView::OnDeleteButtonClickedCb(void *data, Evas_Object *obj, void *event)
{
DeleteAlarmView *view = static_cast<DeleteAlarmView*>(data);
- if (view->onDeleteButtonClicked_) view->onDeleteButtonClicked_();
+ view->OnDeleteButtonClicked();
}
int DeleteAlarmView::ItemAppend(utils::Time time, const char *name,
#define SOUND_ICON_PATH "images/00_volume_icon.png"
EditAlarmView::EditAlarmView(view::MainView &main)
- : PageView(main), week_flags_view_(main, data_.flags), is_muted_(false), main_(main)
+ : PageView(main), discard_popup_(nullptr), week_flags_view_(main, data_.flags), is_muted_(false), main_(main)
{
- week_flags_view_.RegisterPoppedCallback(
+ week_flags_popped_conn_ = week_flags_view_.OnPagePopped.Connect(
std::bind(&EditAlarmView::OnWeekFlagsPagePopped, this));
- picker_.RegisterPathUpdateSignalHandler(
+ picker_conn_ = picker_.OnPathUpdated.Connect(
std::bind(&EditAlarmView::RingtonePathUpdateCallback, this));
time_format_change_listener_ = EventBus::AddListener<Time::PreferedTimeFormatChanged>(
std::bind(&EditAlarmView::TimeFormatChanged, this));
void EditAlarmView::OnCancelButtonClickedCb(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onEditCancel_) view->onEditCancel_();
+ view->OnEditCancel();
}
void EditAlarmView::OnConfirmButtonClickedCb(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onEditDone_) view->onEditDone_();
+ view->OnEditDone();
}
const char *EditAlarmView::GetTitle()
void EditAlarmView::BackButtonOnMainClicked(void *data, Evas_Object *obj, void *event)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onBackButton) view->onBackButton();
+ view->OnBackButtonClicked();
}
void EditAlarmView::CreateContent(Evas_Object *parent)
void EditAlarmView::PopupDiscardButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onDiscardPopupCallback) view->onDiscardPopupCallback(DiscardPopupOption::CONFIRM);
+ view->OnDiscardPopupOptionSelected(DiscardPopupOption::CONFIRM);
}
void EditAlarmView::PopupCancelButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
EditAlarmView *view = static_cast<EditAlarmView*>(data);
- if (view->onDiscardPopupCallback) view->onDiscardPopupCallback(DiscardPopupOption::CANCEL);
+ view->OnDiscardPopupOptionSelected(DiscardPopupOption::CANCEL);
}
void EditAlarmView::ShowDiscardPopup()
{
Elm_Object_Item *it = static_cast<Elm_Object_Item*>(event);
PageView *view = static_cast<PageView*>(elm_object_item_data_get(it));
- view->EmitPoppedEvent();
+ view->OnPagePopped();
view->navi_item_ = NULL;
view->DestroyContent();
}
elm_object_item_del_cb_set(navi_item_, nullptr);
elm_object_item_del(navi_item_);
navi_item_ = NULL;
- EmitPoppedEvent();
+ OnPagePopped();
}
Evas_Object *PageView::GetNaviframe()
{
return naviframe_;
}
-
-void PageView::RegisterPoppedCallback(std::function<void(void)> f)
-{
- onPopped_.push_back(f);
-}
-
-void PageView::EmitPoppedEvent()
-{
- for (auto func: onPopped_) {
- func();
- }
-}
{
RingView *object = static_cast<RingView *>(data);
- object->EmitSignal(view::RingSignal::BUTTON_DISMISS_CLICKED);
+ object->OnDismissButtonClicked();
evas_object_del(object->win_);
}
{
RingView *object = static_cast<RingView *>(data);
- object->EmitSignal(view::RingSignal::BUTTON_SNOOZE_CLICKED);
+ object->OnSnoozeButtonClicked();
evas_object_del(object->win_);
}
-void RingView::RegisterSignal(std::function<void(void)>func, RingSignal type)
-{
- signals_.at((int)type) = func;
-}
-
-void RingView::EmitSignal(RingSignal type)
-{
- if (signals_.at((int)type) != nullptr)
- signals_.at((int)type)();
-}
-
} //namespace view
void StopWatchView::StartButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
StopWatchView *object = static_cast<StopWatchView *>(data);
- object->EmitSignal(Signal::BUTTON_START_CLICKED);
+ object->OnStartButtonClicked();
}
void StopWatchView::StopButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
StopWatchView *object = static_cast<StopWatchView *>(data);
- object->EmitSignal(Signal::BUTTON_STOP_CLICKED);
+ object->OnStopButtonClicked();
}
void StopWatchView::LapButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
StopWatchView *object = static_cast<StopWatchView *>(data);
- object->EmitSignal(Signal::BUTTON_LAP_CLICKED);
+ object->OnLapButtonClicked();
}
void StopWatchView::ResumeButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
StopWatchView *object = static_cast<StopWatchView *>(data);
- object->EmitSignal(Signal::BUTTON_RESUME_CLICKED);
+ object->OnResumeButtonClicked();
}
void StopWatchView::ResetButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
StopWatchView *object = static_cast<StopWatchView *>(data);
- object->EmitSignal(Signal::BUTTON_RESET_CLICKED);
+ object->OnResetButtonClicked();
}
Evas_Object *StopWatchView::CreateList()
return NULL;
}
-void StopWatchView::RegisterSignal(std::function<void(void)>func, Signal type)
-{
- signals.at((int)type) = func;
-}
-
-void StopWatchView::EmitSignal(Signal type)
-{
- if (signals.at((int)type) != nullptr)
- signals.at((int)type)();
-}
-
void StopWatchView::DisplayTime(unsigned hour, unsigned minute, unsigned second, unsigned millisecond)
{
main_counter_->DisplayTime(hour, minute, second, millisecond);
{
TimerView *object = static_cast<TimerView *>(data);
- object->EmitSignal(TimerSignal::BUTTON_CANCEL_CLICKED);
+ object->OnCancelButtonClicked();
elm_object_signal_emit(object->layout_, "menu.startup.show", "timer");
}
void TimerView::StartButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
TimerView *object = static_cast<TimerView *>(data);
-
- object->EmitSignal(TimerSignal::BUTTON_START_CLICKED);
+ object->OnStartButtonClicked();
}
void TimerView::PauseButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
TimerView *object = static_cast<TimerView *>(data);
-
- object->EmitSignal(TimerSignal::BUTTON_PAUSE_CLICKED);
+ object->OnPauseButtonClicked();
}
void TimerView::CancelButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
TimerView *object = static_cast<TimerView *>(data);
-
- object->EmitSignal(TimerSignal::BUTTON_CANCEL_CLICKED);
+ object->OnCancelButtonClicked();
}
void TimerView::ResumeButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
TimerView *object = static_cast<TimerView *>(data);
-
- object->EmitSignal(TimerSignal::BUTTON_RESUME_CLICKED);
+ object->OnResumeButtonClicked();
}
void TimerView::ResetButtonClicked(void *data, Evas_Object *obj, void *event_info)
{
TimerView *object = static_cast<TimerView *>(data);
- object->EmitSignal(TimerSignal::BUTTON_RESET_CLICKED);
+ object->OnResetButtonClicked();
object->set_time_.Hour = 0;
object->set_time_.Min = 0;
object->UnfocusEntries();
}
-void TimerView::RegisterSignal(std::function<void(void)>func, TimerSignal type)
-{
- signals.at((int)type) = func;
-}
-
-void TimerView::EmitSignal(TimerSignal type)
-{
- if (signals.at((int)type) != nullptr)
- signals.at((int)type)();
-}
-
} //namespace view
}
ldid->view->UpdateTitle();
- ldid->view->EmitSignal(SignalType::LIST_ITEM_CLICKED);
+ ldid->view->OnListItemClicked();
elm_genlist_item_selected_set(ldid->it, EINA_FALSE);
elm_check_state_set(ldid->checkbox, ldid->selected);
elm_object_text_set(left_button_, "CANCEL");
elm_object_style_set(left_button_, "naviframe/title_left");
evas_object_smart_callback_add(left_button_, "clicked",
- WorldClockDeleteItemsView::OnCancelButtonClicked, this);
+ WorldClockDeleteItemsView::CancelButtonClicked, this);
evas_object_show(left_button_);
right_button_ = elm_button_add(parent);
elm_object_text_set(right_button_, "DELETE");
elm_object_style_set(right_button_, "naviframe/title_left");
evas_object_smart_callback_add(right_button_, "clicked",
- WorldClockDeleteItemsView::OnDeleteButtonClicked, this);
+ WorldClockDeleteItemsView::DeleteButtonClicked, this);
evas_object_show(right_button_);
content_ = elm_genlist_add(parent);
elm_check_state_set(view->select_all_checkbox_, view->all_selected_);
evas_object_propagate_events_set(view->select_all_checkbox_, EINA_FALSE);
evas_object_smart_callback_add(view->select_all_checkbox_, "changed",
- WorldClockDeleteItemsView::OnSelectAllClicked, view);
+ WorldClockDeleteItemsView::SelectAllClicked, view);
evas_object_show(view->select_all_checkbox_);
return view->select_all_checkbox_;
}
return nullptr;
};
item = elm_genlist_item_append(content_, itc, this, NULL, ELM_GENLIST_ITEM_NONE,
- WorldClockDeleteItemsView::OnSelectAllClicked, this);
+ WorldClockDeleteItemsView::SelectAllClicked, this);
elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_genlist_item_class_unref(itc);
evas_object_del(right_button_);
}
-void WorldClockDeleteItemsView::RegisterSignal(SignalType s, std::function<void(void)>func)
-{
- signals_.at((int)s) = func;
-}
-
-
-void WorldClockDeleteItemsView::EmitSignal(SignalType s)
-{
- if (signals_.at((int)s) != nullptr)
- signals_.at((int)s)();
-}
-
-void WorldClockDeleteItemsView::OnCancelButtonClicked(void *data, Evas_Object *obj, void *event_data)
+void WorldClockDeleteItemsView::CancelButtonClicked(void *data, Evas_Object *obj, void *event_data)
{
WorldClockDeleteItemsView * view = static_cast<WorldClockDeleteItemsView *>(data);
- view->EmitSignal(SignalType::BUTTON_CANCEL_CLICKED);
+ view->OnCancelButtonClicked();
}
-void WorldClockDeleteItemsView::OnDeleteButtonClicked(void *data, Evas_Object *obj, void *event_data)
+void WorldClockDeleteItemsView::DeleteButtonClicked(void *data, Evas_Object *obj, void *event_data)
{
WorldClockDeleteItemsView * view = static_cast<WorldClockDeleteItemsView *>(data);
- view->EmitSignal(SignalType::BUTTON_DELETE_CLICKED);
+ view->OnDeleteButtonClicked();
}
-void WorldClockDeleteItemsView::OnSelectAllClicked(void *data, Evas_Object *obj, void *event_info)
+void WorldClockDeleteItemsView::SelectAllClicked(void *data, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *it = static_cast<Elm_Object_Item*>(event_info);
WorldClockDeleteItemsView *view = static_cast<WorldClockDeleteItemsView *>(data);
view->all_selected_ = !view->all_selected_;
elm_check_state_set(view->select_all_checkbox_, view->all_selected_);
- view->EmitSignal(SignalType::CHECKBOX_SELECT_ALL_CLICKED);
+ view->OnSelectAllCheckboxClicked();
}
void WorldClockDeleteItemsView::ItemSelectToggle(void *data, Evas_Object *obj, void *event_info)
if (!ldid->selected)
ldid->view->SetSelectAllCheckbox(false);
- ldid->view->EmitSignal(SignalType::LIST_ITEM_CLICKED);
+ ldid->view->OnListItemClicked();
}
std::vector<const model::Location *> WorldClockDeleteItemsView::GetSelectedItems()
left_button_ = elm_button_add(parent);
elm_object_text_set(left_button_, "BACK");
elm_object_style_set(left_button_, "naviframe/title_left");
- evas_object_smart_callback_add(left_button_, "clicked", OnBackButtonClicked, this);
+ evas_object_smart_callback_add(left_button_, "clicked", BackButtonClicked, this);
evas_object_show(left_button_);
content_ = elm_genlist_add(parent);
elm_object_item_part_content_set(navi_item_, "title_left_btn", left_button_);
elm_object_item_content_set(navi_item_, content_);
- evas_object_smart_callback_add(content_, "moved" , OnListReordered, this);
+ evas_object_smart_callback_add(content_, "moved" , ListReordered, this);
time_delta = utils::GetSecondsToNextExactMinute();
return padding;
}
-void WorldClockReorderView::RegisterSignalHandler(WorldClockReorderView::Signals s, std::function<void(void)> func)
-{
- signals_.at((int)s) = func;
-}
-
-void WorldClockReorderView::EmitSignal(Signals s)
-{
- if (signals_.at((int)s) != nullptr)
- signals_.at((int)s)();
-}
-
-void WorldClockReorderView::OnListReordered(void *data,
+void WorldClockReorderView::ListReordered(void *data,
Evas_Object *obj, void *event_info)
{
WorldClockReorderView *view = static_cast<WorldClockReorderView *>(data);
- view->EmitSignal(Signals::LIST_REORDERED);
+ view->OnListReordered();
}
-void WorldClockReorderView::OnBackButtonClicked(void *data,
+void WorldClockReorderView::BackButtonClicked(void *data,
Evas_Object *obj, void *event_info)
{
WorldClockReorderView *view = static_cast<WorldClockReorderView *>(data);
- view->EmitSignal(Signals::BUTTON_BACK_CLICKED);
+ view->OnBackButtonClicked();
}
std::vector<const model::Location *> WorldClockReorderView::GetReorderedLocations()
LocationItemData *lid = static_cast<LocationItemData *>(data);
lid->wc_view->SetItemLastClicked(lid->location);
- lid->wc_view->EmitSignal(view::WorldClockSignals::CUSTOM_LIST_ITEM_CLICKED);
+ lid->wc_view->OnCustomListItemClicked();
elm_genlist_item_selected_set(lid->it, EINA_FALSE);
}
if (!strcmp(source, "main.world.map:arrow.left")) {
- world_clock_view->EmitSignal(view::WorldClockSignals::BUTTON_LEFT_ARROW_CLICKED);
+ world_clock_view->OnLeftArrowClicked();
} else if (!strcmp(source, "main.world.map:arrow.right")) {
- world_clock_view->EmitSignal(view::WorldClockSignals::BUTTON_RIGHT_ARROW_CLICKED);
+ world_clock_view->OnRightArrowClicked();
}
}
{
WorldClockView *view = static_cast<WorldClockView *>(data);
elm_genlist_realized_items_update(view->custom_locations_list_);
- view->EmitSignal(view::WorldClockSignals::CUSTOM_LIST_UPDATE_REQUEST);
+ view->OnCustomListUpdateRequested();
ecore_timer_interval_set(view->timer_, utils::GetSecondsToNextExactMinute());
void WorldClockView::MoreButtonClicked(void *data, Evas_Object *obj, void *info)
{
WorldClockView *view = static_cast<WorldClockView *>(data);
- view->EmitSignal(view::WorldClockSignals::BUTTON_MORE_CLICKED);
+ view->OnMenuButtonClicked();
}
void WorldClockView::ShowMorePopup(MoreMenuOptions options)
{
WorldClockView *view = static_cast<WorldClockView *>(data);
- view->EmitSignal(view::WorldClockSignals::BUTTON_MORE_DELETE_CLICKED);
+ view->OnMoreDeleteButtonClicked();
evas_object_del(view->more_popup_);
view->more_popup_ = nullptr;
}
{
WorldClockView *view = static_cast<WorldClockView *>(data);
- view->EmitSignal(view::WorldClockSignals::BUTTON_MORE_REORDER_CLICKED);
+ view->OnMoreReorderButtonClicked();
evas_object_del(view->more_popup_);
view->more_popup_ = nullptr;
}
WorldClockView *view = static_cast<WorldClockView *>(user_data);
view->SetItemToAdd(l);
- view->EmitSignal(view::WorldClockSignals::CUSTOM_LIST_ITEM_ADD);
+ view->OnCustomListItemAdded();
free(city_name);
free(country_name);
item_last_clicked_ = location;
}
-void WorldClockView::RegisterSignal(std::function<void(void)>func, view::WorldClockSignals signal)
-{
- signals.at((int)signal) = func;
-}
-
-void WorldClockView::EmitSignal(view::WorldClockSignals signal)
-{
- if (signals.at((int)signal) != nullptr)
- signals.at((int)signal)();
-}
-
const char *WorldClockView::OffsetToString(int offset)
{
int remainder;