*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
+
// INTERNAL INCLUDES
+#include <dali/devel-api/common/singleton-service.h>
#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/event/common/scene-impl.h>
* Class to store a pointer to core in thread local storage.
*
*/
-class ThreadLocalStorage
+class ThreadLocalStorage : public Dali::BaseObject
{
public:
ThreadLocalStorage(Core* core);
/**
- * Destructor.
- */
- ~ThreadLocalStorage();
-
- /**
* Remove core pointer.
* Prevents the core pointer being automatically deleted when the thread exits.
*/
static ThreadLocalStorage& Get();
/**
+ * @copydoc Dali::SingletonService::Get()
+ */
+ static Dali::SingletonService GetSingletonService();
+
+ /**
* Checks if the TLS has been created
* @return if the TLS has been created
*/
AnimationPlaylist& GetAnimationPlaylist();
/**
+ * @brief Returns whether the blend equation is supported in the system or not.
+ * @param[in] blendEquation blend equation to be checked.
+ * @return True if the blend equation supported.
+ */
+ bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation );
+
+ /**
+ * @brief Returns shader prefix of shading language version.
+ */
+ std::string GetShaderVersionPrefix();
+
+ /**
+ * @brief Returns vertex shader prefix including shading language version.
+ */
+ std::string GetVertexShaderPrefix();
+
+ /**
+ * @brief Returns fragment shader prefix including shading language version and extension information.
+ */
+ std::string GetFragmentShaderPrefix();
+
+ /**
* Add a Scene to the Core.
* This is only used by the Scene to add itself to the core when the Scene is created.
* @param[in] scene The Scene.
*/
void RemoveScene( Scene* scene );
+ /**
+ * @copydoc Dali::SingletonService::Register()
+ */
+ void Register( const std::type_info& info, BaseHandle singleton );
+
+ /**
+ * @copydoc Dali::SingletonService::UnregisterAll()
+ */
+ void UnregisterAll();
+
+ /**
+ * @copydoc Dali::SingletonService::GetSingleton()
+ */
+ BaseHandle GetSingleton( const std::type_info& info ) const;
+
+private:
+
+ /**
+ * Virtual Destructor
+ */
+ ~ThreadLocalStorage() override;
+
+ // Undefined
+ ThreadLocalStorage( const ThreadLocalStorage& );
+ ThreadLocalStorage& operator=( ThreadLocalStorage& );
+
private:
Core* mCore; ///< reference to core
+ // using the address of the type name string as compiler will allocate these once per library
+ // and we don't support un/re-loading of dali libraries while singleton service is alive
+ using SingletonPair = std::pair<const char*, BaseHandle>;
+ using SingletonContainer = std::vector<SingletonPair>;
+ using SingletonConstIter = SingletonContainer::const_iterator;
+
+ SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
+
};
} // namespace Internal
+// Helpers for public-api forwarding methods
+
+inline Internal::ThreadLocalStorage& GetImplementation(Dali::SingletonService& service)
+{
+ DALI_ASSERT_ALWAYS( service && "SingletonService handle is empty" );
+
+ BaseObject& handle = service.GetBaseObject();
+
+ return static_cast<Internal::ThreadLocalStorage&>(handle);
+}
+
+inline const Internal::ThreadLocalStorage& GetImplementation(const Dali::SingletonService& service)
+{
+ DALI_ASSERT_ALWAYS( service && "SingletonService handle is empty" );
+
+ const BaseObject& handle = service.GetBaseObject();
+
+ return static_cast<const Internal::ThreadLocalStorage&>(handle);
+}
+
} // namespace Dali
#endif // DALI_INTERNAL_THREAD_LOCAL_STORAGE_H