#define DALI_INTERNAL_FRAMEWORK_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
-#include <string>
#include <dali/public-api/signals/callback.h>
+#include <string>
#ifdef APPCORE_WATCH_AVAILABLE
#include <dali/public-api/watch/watch-application.h>
#endif
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* The Framework class is ideally placed to provide key API required by Applications.
*
class Framework
{
public:
-
enum Type
{
- NORMAL, ///< normal appFramework
- WATCH, ///< watch appFramework
- WIDGET, ///< widget appFramework
- COMPONENT ///< component appFramework
+ NORMAL, ///< normal appFramework
+ WATCH, ///< watch appFramework
+ WIDGET, ///< widget appFramework
+ COMPONENT ///< component appFramework
};
/**
* Observer class for the framework.
+ * @brief When the UI thread is enabled, the events are emitted on the UI thread.
+ * When it is disabled, the events are emitted on the main thread.
*/
class Observer
{
public:
-
/**
* Invoked when the application is to be initialised.
*/
- virtual void OnInit() {}
+ virtual void OnInit()
+ {
+ }
/**
* Invoked when the application is to be terminated.
*/
- virtual void OnTerminate() {}
+ virtual void OnTerminate()
+ {
+ }
/**
* Invoked when the application is to be paused.
*/
- virtual void OnPause() {}
+ virtual void OnPause()
+ {
+ }
/**
* Invoked when the application is to be resumed.
*/
- virtual void OnResume() {}
+ virtual void OnResume()
+ {
+ }
/**
* Invoked when the application is to be reset.
*/
- virtual void OnReset() {}
+ virtual void OnReset()
+ {
+ }
/**
- * Invoked when the AppControl message is received.
- * @param[in] The bundle data of AppControl message.
- */
- virtual void OnAppControl(void *) {}
+ * Invoked when the AppControl message is received.
+ * @param[in] The bundle data of AppControl message.
+ */
+ virtual void OnAppControl(void*)
+ {
+ }
#ifdef APPCORE_WATCH_AVAILABLE
/**
* Invoked at every second
*/
- virtual void OnTimeTick(WatchTime&) {}
+ virtual void OnTimeTick(WatchTime&)
+ {
+ }
/**
* Invoked at every second in ambient mode
*/
- virtual void OnAmbientTick(WatchTime&) {}
+ virtual void OnAmbientTick(WatchTime&)
+ {
+ }
/**
* Invoked when the device enters or exits ambient mode
*/
- virtual void OnAmbientChanged(bool ambient) {}
+ virtual void OnAmbientChanged(bool ambient)
+ {
+ }
#endif
/**
* Invoked when the language of the device is changed.
*/
- virtual void OnLanguageChanged() {}
+ virtual void OnLanguageChanged()
+ {
+ }
/**
* Invoked when the region is changed.
*/
- virtual void OnRegionChanged() {}
+ virtual void OnRegionChanged()
+ {
+ }
/**
* Invoked when the battery level of the device is low.
*/
- virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status ) {}
+ virtual void OnBatteryLow(Dali::DeviceStatus::Battery::Status status)
+ {
+ }
/**
* Invoked when the memory level of the device is low.
*/
- virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) {}
+ virtual void OnMemoryLow(Dali::DeviceStatus::Memory::Status status)
+ {
+ }
/**
* Invoked when the platform surface is created.
*/
- virtual void OnSurfaceCreated( Any newSurface ) {}
+ virtual void OnSurfaceCreated(Any newSurface)
+ {
+ }
/**
* Invoked when the platform surface is destroyed.
*/
- virtual void OnSurfaceDestroyed( Any newSurface ) {}
+ virtual void OnSurfaceDestroyed(Any newSurface)
+ {
+ }
#ifdef COMPONENT_APPLICATION_SUPPORT
/**
* Invoked when the component application is created.
*/
- virtual Any OnCreate() { return nullptr; }
+ virtual Any OnCreate()
+ {
+ return nullptr;
+ }
#endif
};
-public:
+ /**
+ * TaskObserver class for the framework.
+ * @brief This is used only when UiThread is enabled. the events are emitted on the main thread.
+ */
+ class TaskObserver
+ {
+ public:
+ /**
+ * Invoked when the application is to be initialised.
+ */
+ virtual void OnTaskInit()
+ {
+ }
+
+ /**
+ * Invoked when the application is to be terminated.
+ */
+ virtual void OnTaskTerminate()
+ {
+ }
+
+ /**
+ * Invoked when the AppControl message is received.
+ * @param[in] The bundle data of AppControl message.
+ */
+ virtual void OnTaskAppControl(void*)
+ {
+ }
+ /**
+ * Invoked when the language of the device is changed.
+ */
+ virtual void OnTaskLanguageChanged()
+ {
+ }
+
+ /**
+ * Invoked when the region is changed.
+ */
+ virtual void OnTaskRegionChanged()
+ {
+ }
+
+ /**
+ * Invoked when the battery level of the device is low.
+ */
+ virtual void OnTaskBatteryLow(Dali::DeviceStatus::Battery::Status status)
+ {
+ }
+
+ /**
+ * Invoked when the memory level of the device is low.
+ */
+ virtual void OnTaskMemoryLow(Dali::DeviceStatus::Memory::Status status)
+ {
+ }
+ };
+
+public:
/**
* Constructor
- * @param[in] observer The observer of the Framework.
- * @param[in] argc A pointer to the number of arguments.
- * @param[in] argv A pointer the the argument list.
- * @param[in] type The type of application
+ * @param[in] observer The observer of the Framework.
+ * @param[in] taskObserver The task observer of the Framework.
+ * @param[in] argc A pointer to the number of arguments.
+ * @param[in] argv A pointer the the argument list.
+ * @param[in] type The type of application
+ * @param[in] useUiThread True if the application would create a UI thread
*/
- Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
+ Framework(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
/**
* Destructor
~Framework();
public:
-
/**
* Runs the main loop of framework
*/
* @note Only one callback can be registered. The last callback to be set will be called on abort.
* @note The ownership of callback is passed onto this class.
*/
- void AddAbortCallback( CallbackBase* callback );
+ void AddAbortCallback(CallbackBase* callback);
/**
* Gets bundle name which was passed in app_reset callback.
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
*/
- void SetCommandLineOptions( int* argc, char **argv[] )
+ void SetCommandLineOptions(int* argc, char** argv[])
{
mArgc = argc;
mArgv = argv;
}
-
/**
* Gets the path at which application resources are stored.
*/
/**
* Sets system language.
*/
- void SetLanguage( const std::string& language );
+ void SetLanguage(const std::string& language);
/**
* Sets system region.
*/
- void SetRegion( const std::string& region );
+ void SetRegion(const std::string& region);
/**
* Gets system language.
* @param[in] callback The callback.
* @return The callback id.
*/
- unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) );
+ unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data));
/**
* Called by the adaptor when an idle callback is removed.
* @param[in] id The callback id.
*/
- void RemoveIdle( unsigned int id );
+ void RemoveIdle(unsigned int id);
private:
-
// Undefined
Framework(const Framework&);
Framework& operator=(Framework&);
private:
-
/**
* Called when the application is created.
*/
void InitThreads();
private:
- Observer& mObserver;
- bool mInitialised;
- bool mPaused;
- bool mRunning;
- int* mArgc;
- char*** mArgv;
- std::string mBundleName;
- std::string mBundleId;
- AbortHandler mAbortHandler;
+ Observer& mObserver;
+ TaskObserver& mTaskObserver;
+ bool mInitialised;
+ bool mPaused;
+ bool mRunning;
+ int* mArgc;
+ char*** mArgv;
+ std::string mBundleName;
+ std::string mBundleId;
+ AbortHandler mAbortHandler;
private: // impl members
-
struct Impl;
Impl* mImpl;
};