Added SingletonService, removed Singleton APIs from Adaptor & removed Application... 42/26942/8
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 1 Sep 2014 17:45:12 +0000 (18:45 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 8 Sep 2014 09:47:40 +0000 (10:47 +0100)
Change-Id: I09191b12dfb40c54e68f3bfa811bd61b70248780

29 files changed:
adaptors/common/adaptor-impl.cpp
adaptors/common/adaptor-impl.h
adaptors/common/application-impl.cpp
adaptors/common/application-impl.h
adaptors/common/clipboard-event-notifier-impl.cpp
adaptors/common/file.list
adaptors/common/haptic-player-impl.cpp
adaptors/common/physical-keyboard-impl.cpp
adaptors/common/singleton-service-impl.cpp [new file with mode: 0644]
adaptors/common/singleton-service-impl.h [new file with mode: 0644]
adaptors/common/sound-player-impl.cpp
adaptors/common/style-monitor-impl.cpp
adaptors/mobile/mobile-color-controller-impl.cpp
adaptors/public-api/adaptor-framework/adaptor.cpp
adaptors/public-api/adaptor-framework/adaptor.h
adaptors/public-api/adaptor-framework/application.cpp
adaptors/public-api/adaptor-framework/application.h
adaptors/public-api/adaptor-framework/singleton-service.cpp [new file with mode: 0644]
adaptors/public-api/adaptor-framework/singleton-service.h [new file with mode: 0644]
adaptors/public-api/dali.h
adaptors/public-api/file.list
adaptors/tizen/accessibility-manager-impl-tizen.cpp
adaptors/tizen/tilt-sensor-impl-tizen.cpp
adaptors/ubuntu/accessibility-manager-impl-ubuntu.cpp
adaptors/ubuntu/tilt-sensor-impl-ubuntu.cpp
adaptors/wayland/clipboard-impl-wl.cpp
adaptors/wayland/imf-manager-impl-wl.cpp
adaptors/x11/clipboard-impl-x.cpp
adaptors/x11/imf-manager-impl-x.cpp

index 3482250..05aae0d 100644 (file)
@@ -819,27 +819,6 @@ void Adaptor::ProcessCoreEventsFromIdle()
   mNotificationOnIdleInstalled = false;
 }
 
-void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
-{
-  if(singleton)
-  {
-    mSingletonContainer.insert(SingletonPair(info.name(), singleton));
-  }
-}
-
-BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
-{
-  BaseHandle object = Dali::BaseHandle();
-
-  SingletonConstIter iter = mSingletonContainer.find(info.name());
-  if(iter != mSingletonContainer.end())
-  {
-    object = (*iter).second;
-  }
-
-  return object;
-}
-
 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
 : mAdaptor(adaptor),
   mState(READY),
index fa068e2..942bab9 100644 (file)
@@ -90,10 +90,6 @@ public:
 
   typedef Dali::Adaptor::AdaptorSignalV2 AdaptorSignalV2;
 
-  typedef std::pair<std::string, BaseHandle> SingletonPair;
-  typedef std::map<std::string, BaseHandle>  SingletonContainer;
-  typedef SingletonContainer::const_iterator SingletonConstIter;
-
   /**
    * Creates a New Adaptor
    * @param[in]  surface     A render surface can be one of the following
@@ -201,16 +197,6 @@ public: // AdaptorInternalServices implementation
    */
   virtual bool CallFromMainLoop(boost::function<void(void)> callBack);
 
-  /**
-   * @copydoc Dali::Adaptor::RegisterSingleton()
-   */
-  virtual void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
-
-  /**
-   * @copydoc Dali::Adaptor::GetSingleton()
-   */
-  virtual BaseHandle GetSingleton(const std::type_info& info) const;
-
 public:
 
   /**
@@ -517,7 +503,6 @@ private: // Data
   size_t                                mVDpi;                        ///< Override vertical DPI
   FeedbackPluginProxy*                  mDaliFeedbackPlugin;          ///< Used to access feedback support
   FeedbackController*                   mFeedbackController;          ///< Plays feedback effects for Dali-Toolkit UI Controls.
-  SingletonContainer                    mSingletonContainer;          ///< The container to look up singleton by its type name
   Dali::TtsPlayer                       mTtsPlayers[Dali::TtsPlayer::MODE_NUM];                   ///< Provides TTS support
   ObserverContainer                     mObservers;                   ///< A list of adaptor observer pointers
   DragAndDropDetectorPtr                mDragAndDropDetector;         ///< The Drag & Drop detector
index 79a666a..aeee4d3 100644 (file)
@@ -25,6 +25,7 @@
 // INTERNAL INCLUDES
 #include <command-line-options.h>
 #include <common/adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -52,8 +53,6 @@ const unsigned int DEFAULT_WINDOW_WIDTH   = 480;
 const unsigned int DEFAULT_WINDOW_HEIGHT  = 800;
 const float        DEFAULT_HORIZONTAL_DPI = 220;
 const float        DEFAULT_VERTICAL_DPI   = 217;
-
-boost::thread_specific_ptr<Application> gThreadLocalApplication;
 }
 
 ApplicationPtr Application::New(
@@ -67,28 +66,26 @@ ApplicationPtr Application::New(
   return application;
 }
 
-Application::Application(
-  int* argc,
-  char** argv[],
-  const std::string& name,
-  const DeviceLayout& baseLayout,
-  Dali::Application::WINDOW_MODE windowMode)
-: mFramework(NULL),
-  mCommandLineOptions(NULL),
-  mAdaptor(NULL),
+Application::Application( int* argc, char** argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode)
+: mInitSignalV2(),
+  mTerminateSignalV2(),
+  mPauseSignalV2(),
+  mResumeSignalV2(),
+  mResetSignalV2(),
+  mResizeSignalV2(),
+  mLanguageChangedSignalV2(),
+  mEventLoop( NULL ),
+  mFramework( NULL ),
+  mCommandLineOptions( NULL ),
+  mSingletonService( SingletonService::New() ),
+  mAdaptor( NULL ),
   mWindow(),
   mWindowMode( windowMode ),
-  mName(name),
-  mInitialized(false),
-  mBaseLayout(baseLayout),
+  mName( name ),
+  mInitialized( false ),
+  mBaseLayout( baseLayout ),
   mSlotDelegate( this )
 {
-  // make sure we don't create the local thread application instance twice
-  DALI_ASSERT_ALWAYS(gThreadLocalApplication.get() == NULL && "Cannot create more than one Application per thread" );
-
-  // reset is used to store a new value associated with this thread
-  gThreadLocalApplication.reset(this);
-
   mCommandLineOptions = new CommandLineOptions(argc, argv);
 
   mFramework = new Framework(*this, argc, argv, name);
@@ -100,7 +97,6 @@ Application::~Application()
   delete mCommandLineOptions;
   delete mAdaptor;
   mWindow.Reset();
-  gThreadLocalApplication.release();
 }
 
 void Application::CreateWindow()
@@ -266,15 +262,6 @@ Dali::Window Application::GetWindow()
   return mWindow;
 }
 
-Dali::Application Application::Get()
-{
-  DALI_ASSERT_ALWAYS( gThreadLocalApplication.get() != NULL && "Application not instantiated" );
-
-  Dali::Application application(gThreadLocalApplication.get());
-
-  return application;
-}
-
 const std::string& Application::GetTheme()
 {
   return Dali::StyleMonitor::Get().GetTheme();
index 44d4362..8301f00 100644 (file)
 
 // INTERNAL INCLUDES
 #include <application.h>
+#include <singleton-service.h>
 
 #include <framework.h>
 #include <window-impl.h>
 
 namespace Dali
 {
-class Window;
 class Adaptor;
+class Window;
 
 namespace Internal
 {
@@ -72,7 +73,7 @@ public:
                             const DeviceLayout& baseLayout,
                             Dali::Application::WINDOW_MODE windowMode);
 
-  Application(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
+  Application( int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout, Dali::Application::WINDOW_MODE windowMode );
 
   /**
    * Destructor
@@ -112,11 +113,6 @@ public:
   Dali::Window GetWindow();
 
   /**
-   * @copydoc Dali::Application::Get();
-   */
-  static Dali::Application Get();
-
-  /**
    * @copydoc Dali::Application::GetTheme();
    */
   const std::string& GetTheme();
@@ -262,6 +258,7 @@ private:
 
   CommandLineOptions*                   mCommandLineOptions;
 
+  Dali::SingletonService                mSingletonService;
   Dali::Adaptor*                        mAdaptor;
   Dali::Window                          mWindow;
   Dali::Application::WINDOW_MODE        mWindowMode;
index 3f509e8..c28dcf0 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali/public-api/dali-core.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -39,12 +39,15 @@ BaseHandle Create()
 {
   BaseHandle handle( ClipboardEventNotifier::Get() );
 
-  if ( !handle && Adaptor::IsAvailable() )
+  if ( !handle )
   {
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-    Dali::ClipboardEventNotifier notifier( ClipboardEventNotifier::New() );
-    adaptorImpl.RegisterSingleton( typeid( notifier ), notifier );
-    handle = notifier;
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      Dali::ClipboardEventNotifier notifier( ClipboardEventNotifier::New() );
+      service.Register( typeid( notifier ), notifier );
+      handle = notifier;
+    }
   }
 
   return handle;
@@ -64,10 +67,11 @@ Dali::ClipboardEventNotifier ClipboardEventNotifier::Get()
 {
   Dali::ClipboardEventNotifier notifier;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
     if(handle)
     {
       // If so, downcast the handle
index 91ff562..96f7ed6 100644 (file)
@@ -20,6 +20,7 @@ adaptor_common_internal_src_files = \
   $(adaptor_common_dir)/render-surface-impl.cpp \
   $(adaptor_common_dir)/server-connection.cpp \
   $(adaptor_common_dir)/shared-file.cpp \
+  $(adaptor_common_dir)/singleton-service-impl.cpp \
   $(adaptor_common_dir)/sound-player-impl.cpp \
   $(adaptor_common_dir)/style-monitor-impl.cpp \
   $(adaptor_common_dir)/timer-impl.cpp \
index 23a3023..9df0ded 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -56,10 +56,11 @@ Dali::HapticPlayer HapticPlayer::Get()
 {
   Dali::HapticPlayer player;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::HapticPlayer ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::HapticPlayer ) );
     if ( handle )
     {
       // If so, downcast the handle
@@ -67,9 +68,8 @@ Dali::HapticPlayer HapticPlayer::Get()
     }
     else
     {
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
       player = Dali::HapticPlayer( New() );
-      adaptorImpl.RegisterSingleton( typeid( player ), player );
+      service.Register( typeid( player ), player );
     }
   }
 
index 0f7ca87..8cb8a66 100644 (file)
@@ -21,7 +21,7 @@
 #include <physical-keyboard-impl.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -36,11 +36,11 @@ Dali::PhysicalKeyboard PhysicalKeyboard::New()
 {
   Dali::PhysicalKeyboard keyboardHandle;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
-    Dali::Adaptor& adaptor = Adaptor::Get();
     keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
-    adaptor.RegisterSingleton( typeid( keyboardHandle ), keyboardHandle );
+    service.Register( typeid( keyboardHandle ), keyboardHandle );
   }
 
   return keyboardHandle;
@@ -50,12 +50,10 @@ Dali::PhysicalKeyboard PhysicalKeyboard::Get()
 {
   Dali::PhysicalKeyboard keyboardHandle;
 
-  // Ensure the adaptor has been created
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service = SingletonService::Get();
+  if ( service )
   {
-    Dali::Adaptor& adaptor = Adaptor::Get();
-
-    BaseHandle handle = adaptor.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
+    BaseHandle handle = service.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
     if( handle )
     {
       // If so, downcast the handle of singleton to focus manager
diff --git a/adaptors/common/singleton-service-impl.cpp b/adaptors/common/singleton-service-impl.cpp
new file mode 100644 (file)
index 0000000..1faedb5
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <singleton-service-impl.h>
+
+// EXTERNAL INCLUDES
+#include <boost/thread/tss.hpp>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+
+#if defined(DEBUG_ENABLED)
+#include <slp-logging.h>
+Debug::Filter* gSingletonServiceLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_SINGLETON_SERVICE" );
+
+// Need to define own macro as the log function is not installed when this object is created so no logging is shown with DALI_LOG_INFO at construction and destruction
+#define DALI_LOG_SINGLETON_SERVICE_DIRECT(level, message)                        \
+    if(gSingletonServiceLogFilter && gSingletonServiceLogFilter->IsEnabledFor(level)) { std::string string(message); Dali::SlpPlatform::LogMessage( Debug::DebugInfo, string );  }
+
+#define DALI_LOG_SINGLETON_SERVICE(level, format, args...) DALI_LOG_INFO(gSingletonServiceLogFilter, level, format, ## args )
+
+#else
+
+#define DALI_LOG_SINGLETON_SERVICE_DIRECT(level, message)
+#define DALI_LOG_SINGLETON_SERVICE(level, format, args...)
+
+#endif
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+/*
+ * Dummy cleanup function required as boost::thread_specific_ptr requires access to destructor but
+ * we should not make the destructor of SingletonService public as it is a ref-counted object.
+ *
+ * We do not expect this to be called as we only release the pointer, and not reset.
+ */
+void DummyCleanup( SingletonService* )
+{
+}
+
+boost::thread_specific_ptr< SingletonService > gSingletonService( &DummyCleanup );
+} // unnamed namespace
+
+Dali::SingletonService SingletonService::New()
+{
+  Dali::SingletonService singletonService( new SingletonService );
+  return singletonService;
+}
+
+Dali::SingletonService SingletonService::Get()
+{
+  Dali::SingletonService singletonService;
+  if ( gSingletonService.get() )
+  {
+    singletonService = Dali::SingletonService( gSingletonService.get() );
+  }
+  return singletonService;
+}
+
+void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
+{
+  if( singleton )
+  {
+    DALI_LOG_SINGLETON_SERVICE( Debug::General, "Singleton Added: %s\n", info.name() );
+    mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
+  }
+}
+
+BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const
+{
+  BaseHandle object;
+
+  SingletonConstIter iter = mSingletonContainer.find(info.name());
+  if( iter != mSingletonContainer.end() )
+  {
+    object = ( *iter ).second;
+  }
+
+  return object;
+}
+
+SingletonService::SingletonService()
+: mSingletonContainer()
+{
+  // Can only have one instance of SingletonService
+  DALI_ASSERT_ALWAYS( !gSingletonService.get() && "Only one instance of SingletonService is allowed");
+
+  gSingletonService.reset( this );
+
+  DALI_LOG_SINGLETON_SERVICE_DIRECT( Debug::Concise, "SingletonService Created\n" );
+}
+
+SingletonService::~SingletonService()
+{
+  gSingletonService.release();
+  DALI_LOG_SINGLETON_SERVICE_DIRECT( Debug::Concise, "SingletonService Destroyed\n" );
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/adaptors/common/singleton-service-impl.h b/adaptors/common/singleton-service-impl.h
new file mode 100644 (file)
index 0000000..b86fc0e
--- /dev/null
@@ -0,0 +1,115 @@
+#ifndef __DALI_INTERNAL_SINGLETON_SERVICE_H__
+#define __DALI_INTERNAL_SINGLETON_SERVICE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/common/map-wrapper.h>
+
+// INTERNAL INCLUDES
+#include <singleton-service.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class SingletonService : public Dali::BaseObject
+{
+public:
+
+  /**
+   * Create a SingletonService.
+   * This should only be called once by the Application class.
+   * @return A newly created SingletonService.
+   */
+  static Dali::SingletonService New() DALI_IMPORT_API;
+
+  /**
+   * @copydoc Dali::SingletonService::Get()
+   */
+  static Dali::SingletonService Get();
+
+  /**
+   * @copydoc Dali::SingletonService::Register()
+   */
+  void Register( const std::type_info& info, BaseHandle singleton );
+
+  /**
+   * @copydoc Dali::SingletonService::GetSingleton()
+   */
+  BaseHandle GetSingleton( const std::type_info& info ) const;
+
+private:
+
+  /**
+   * Private Constructor
+   * @see SingletonService::New()
+   */
+  SingletonService();
+
+  /**
+   * Virtual Destructor
+   */
+  virtual ~SingletonService();
+
+  // Undefined
+  SingletonService( const SingletonService& );
+  SingletonService& operator=( SingletonService& );
+
+private:
+
+  typedef std::pair<std::string, BaseHandle> SingletonPair;
+  typedef std::map<std::string, BaseHandle>  SingletonContainer;
+  typedef SingletonContainer::const_iterator SingletonConstIter;
+
+  SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Adaptor::SingletonService& GetImplementation(Dali::SingletonService& player)
+{
+  DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
+
+  BaseObject& handle = player.GetBaseObject();
+
+  return static_cast<Internal::Adaptor::SingletonService&>(handle);
+}
+
+inline const Internal::Adaptor::SingletonService& GetImplementation(const Dali::SingletonService& player)
+{
+  DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
+
+  const BaseObject& handle = player.GetBaseObject();
+
+  return static_cast<const Internal::Adaptor::SingletonService&>(handle);
+}
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_SINGLETON_SERVICE_H__
index 83654f0..7215a73 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -58,10 +58,11 @@ Dali::SoundPlayer SoundPlayer::Get()
 {
   Dali::SoundPlayer player;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::SoundPlayer ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::SoundPlayer ) );
     if ( handle )
     {
       // If so, downcast the handle
@@ -69,9 +70,8 @@ Dali::SoundPlayer SoundPlayer::Get()
     }
     else
     {
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
       player = Dali::SoundPlayer( New() );
-      adaptorImpl.RegisterSingleton( typeid( player ), player );
+      service.Register( typeid( player ), player );
     }
   }
 
index ef701d5..58e02e2 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
 #include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -40,10 +41,14 @@ BaseHandle Create()
 
   if ( !handle && Adaptor::IsAvailable() )
   {
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-    Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
-    adaptorImpl.RegisterSingleton( typeid( styleMonitor ), styleMonitor );
-    handle = styleMonitor;
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+      Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
+      service.Register( typeid( styleMonitor ), styleMonitor );
+      handle = styleMonitor;
+    }
   }
 
   return handle;
@@ -56,10 +61,11 @@ Dali::StyleMonitor StyleMonitor::Get()
 {
   Dali::StyleMonitor styleMonitor;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::StyleMonitor ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
     if(handle)
     {
       // If so, downcast the handle
index 20b1e1a..2a0a0e0 100644 (file)
@@ -24,7 +24,7 @@
 #include <efl_assist_theme.h>
 
 // INTERNAL INCLUDES
-#include <common/adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace Dali
 {
@@ -50,10 +50,11 @@ Dali::ColorController ColorController::Get()
 {
   Dali::ColorController colorController;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ColorController ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ColorController ) );
     if(handle)
     {
       // If so, downcast the handle
@@ -61,9 +62,8 @@ Dali::ColorController ColorController::Get()
     }
     else
     {
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
       colorController = Dali::ColorController( new ColorController( ) );
-      adaptorImpl.RegisterSingleton( typeid( colorController ), colorController );
+      service.Register( typeid( colorController ), colorController );
     }
   }
 
index 1f54f67..136267f 100644 (file)
@@ -101,16 +101,6 @@ bool Adaptor::IsAvailable()
   return Internal::Adaptor::Adaptor::IsAvailable();
 }
 
-void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
-{
-  mImpl->RegisterSingleton(info, singleton);
-}
-
-BaseHandle Adaptor::GetSingleton(const std::type_info& info) const
-{
-  return mImpl->GetSingleton(info);
-}
-
 void Adaptor::NotifyLanguageChanged()
 {
   mImpl->NotifyLanguageChanged();
index 0f8c255..692185a 100644 (file)
@@ -189,26 +189,6 @@ public:
   static bool IsAvailable();
 
   /**
-   * @brief Registers the singleton of Dali handle with its type info.
-   *
-   * The singleton will be kept alive for the life time of the
-   * adaptor.
-   * @note This is not intended for application developers.
-   * @param[in] info The type info of the Dali handle generated by the compiler.
-   * @param[in] singleton The Dali handle to be registered
-   */
-  void RegisterSingleton(const std::type_info& info, BaseHandle singleton);
-
-  /**
-   * @brief Gets the singleton for the given type.
-   *
-   * @note This is not intended for application developers.
-   * @param[in] info The type info of the given type.
-   * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
-   */
-  BaseHandle GetSingleton(const std::type_info& info) const;
-
-  /**
    * @brief Call this method to notify Dali when the system language changes.
    *
    * Use this only when NOT using Dali::Application, As Application created using
index 5e87bac..586d596 100644 (file)
@@ -112,11 +112,6 @@ Window Application::GetWindow()
   return Internal::Adaptor::GetImplementation(*this).GetWindow();
 }
 
-Application Application::Get()
-{
-  return Internal::Adaptor::Application::Get();
-}
-
 void Application::SetViewMode( ViewMode viewMode )
 {
   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
index b07d9be..fb6c6b7 100644 (file)
@@ -229,14 +229,6 @@ public:
    */
   Window GetWindow();
 
-  /**
-   * Returns the local thread's instance of the Application class.
-   * @return A reference to the local thread's Application class instance.
-   * @pre The Application class has been initialised.
-   * @note This is only valid in the main thread.
-   */
-  static Application Get();
-
 public: // Stereoscopy
 
   /**
diff --git a/adaptors/public-api/adaptor-framework/singleton-service.cpp b/adaptors/public-api/adaptor-framework/singleton-service.cpp
new file mode 100644 (file)
index 0000000..9ef7fcb
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <singleton-service.h>
+
+// INTERNAL INCLUDES
+#include <singleton-service-impl.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+SingletonService::SingletonService()
+{
+}
+
+SingletonService SingletonService::Get()
+{
+  return Internal::Adaptor::SingletonService::Get();
+}
+
+SingletonService::~SingletonService()
+{
+}
+
+void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
+{
+  GetImplementation( *this ).Register( info, singleton );
+}
+
+BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const
+{
+  return GetImplementation( *this ).GetSingleton( info );
+}
+
+SingletonService::SingletonService( Internal::Adaptor::SingletonService* singletonService )
+: BaseHandle( singletonService )
+{
+}
+
+} // namespace Dali
diff --git a/adaptors/public-api/adaptor-framework/singleton-service.h b/adaptors/public-api/adaptor-framework/singleton-service.h
new file mode 100644 (file)
index 0000000..06cc717
--- /dev/null
@@ -0,0 +1,100 @@
+#ifndef __DALI_SINGELTON_SERVICE_H__
+#define __DALI_SINGELTON_SERVICE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <typeinfo>
+#include <dali/public-api/object/base-handle.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class SingletonService;
+}
+}
+
+/**
+ * @brief Allows the registration of a class as a singleton
+ *
+ * @note This class is created by the Application class and is destroyed when the Application class is destroyed.
+ *
+ * @see Application
+ */
+class SingletonService : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Create an uninitialized handle.
+   *
+   * This can be initialized by calling SingletonService::Get().
+   */
+  SingletonService();
+
+  /**
+   * @brief Retrieves a handle to the SingletonService.
+   *
+   * @return A handle to the SingletonService if it is available. This will be an empty handle if
+   *         the service is not available.
+   */
+  static SingletonService Get();
+
+  /**
+   * @brief Destructor
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~SingletonService();
+
+  /**
+   * @brief Registers the singleton of Dali handle with its type info.
+   *
+   * The singleton will be kept alive for the life time of the service.
+   *
+   * @note This is not intended for application developers.
+   * @param[in] info The type info of the Dali handle generated by the compiler.
+   * @param[in] singleton The Dali handle to be registered
+   */
+  void Register( const std::type_info& info, BaseHandle singleton );
+
+  /**
+   * @brief Gets the singleton for the given type.
+   *
+   * @note This is not intended for application developers.
+   * @param[in] info The type info of the given type.
+   * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
+   */
+  BaseHandle GetSingleton( const std::type_info& info ) const;
+
+public: // Not intended for application developers
+
+  /**
+   * @brief This constructor is used by SingletonService::Get().
+   * @param[in] singletonService A pointer to the internal singleton-service object.
+   */
+  SingletonService( Internal::Adaptor::SingletonService* singletonService );
+};
+
+} // namespace Dali
+
+#endif // __DALI_SINGELTON_SERVICE_H__
index 4b1d86a..a82c4ab 100644 (file)
@@ -48,6 +48,7 @@
 #include <dali/public-api/adaptor-framework/physical-keyboard.h>
 #include <dali/public-api/adaptor-framework/pixmap-image.h>
 #include <dali/public-api/adaptor-framework/render-surface.h>
+#include <dali/public-api/adaptor-framework/singleton-service.h>
 #include <dali/public-api/adaptor-framework/sound-player.h>
 #include <dali/public-api/adaptor-framework/style-change.h>
 #include <dali/public-api/adaptor-framework/style-monitor.h>
index ff9f234..0a0dd23 100644 (file)
@@ -16,6 +16,7 @@ public_api_src_files = \
   $(adaptor_public_api_dir)/adaptor-framework/physical-keyboard.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/render-surface.cpp \
+  $(adaptor_public_api_dir)/adaptor-framework/singleton-service.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/sound-player.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/style-monitor.cpp \
   $(adaptor_public_api_dir)/adaptor-framework/tilt-sensor.cpp \
@@ -52,6 +53,7 @@ public_api_adaptor_framework_header_files = \
   $(adaptor_public_api_dir)/adaptor-framework/physical-keyboard.h \
   $(adaptor_public_api_dir)/adaptor-framework/pixmap-image.h \
   $(adaptor_public_api_dir)/adaptor-framework/render-surface.h \
+  $(adaptor_public_api_dir)/adaptor-framework/singleton-service.h \
   $(adaptor_public_api_dir)/adaptor-framework/sound-player.h \
   $(adaptor_public_api_dir)/adaptor-framework/style-change.h \
   $(adaptor_public_api_dir)/adaptor-framework/style-monitor.h \
index 9cd164f..feb5551 100644 (file)
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/gesture-requests.h>
-#include "system-settings.h"
+
+// INTERNAL INCLUDES
+#include <singleton-service-impl.h>
+#include <system-settings.h>
 
 namespace Dali
 {
@@ -64,12 +67,15 @@ BaseHandle Create()
 {
   BaseHandle handle( AccessibilityManager::Get() );
 
-  if ( !handle && Adaptor::IsAvailable() )
+  if ( !handle )
   {
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-    Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
-    adaptorImpl.RegisterSingleton( typeid( manager ), manager );
-    handle = manager;
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
+      service.Register( typeid( manager ), manager );
+      handle = manager;
+    }
   }
 
   return handle;
@@ -82,10 +88,11 @@ Dali::AccessibilityManager AccessibilityManager::Get()
 {
   Dali::AccessibilityManager manager;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::AccessibilityManager ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityManager ) );
     if(handle)
     {
       // If so, downcast the handle
@@ -262,8 +269,11 @@ void AccessibilityManager::DisableAccessibility()
     mStatusChangedSignalV2.Emit( handle );
 
     // Destroy the TtsPlayer if exists.
-    Dali::Adaptor& adaptor = Dali::Adaptor::Get();
-    Adaptor::GetImplementation(adaptor).DestroyTtsPlayer(Dali::TtsPlayer::SCREEN_READER);
+    if ( Adaptor::IsAvailable() )
+    {
+      Dali::Adaptor& adaptor = Dali::Adaptor::Get();
+      Adaptor::GetImplementation( adaptor ).DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
+    }
   }
 }
 
index d171c6a..5a93b11 100644 (file)
@@ -30,7 +30,7 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 #ifdef __arm__
 #define SENSOR_ENABLED
@@ -75,10 +75,11 @@ Dali::TiltSensor TiltSensor::Get()
 {
   Dali::TiltSensor sensor;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the keyboard focus manager is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::TiltSensor ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TiltSensor ) );
     if(handle)
     {
       // If so, downcast the handle of singleton to keyboard focus manager
@@ -87,9 +88,8 @@ Dali::TiltSensor TiltSensor::Get()
     else
     {
       // Create a singleton instance
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
       sensor = TiltSensor::New();
-      adaptorImpl.RegisterSingleton( typeid( sensor ), sensor );
+      service.Register( typeid( sensor ), sensor );
       handle = sensor;
     }
   }
index cb8fc21..8c4214a 100644 (file)
@@ -24,6 +24,9 @@
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/gesture-requests.h>
+
+// INTERNAL INCLUDES
+#include <singleton-service-impl.h>
 #include "system-settings.h"
 
 namespace Dali
@@ -45,12 +48,15 @@ BaseHandle Create()
 {
   BaseHandle handle( AccessibilityManager::Get() );
 
-  if ( !handle && Adaptor::IsAvailable() )
+  if ( !handle )
   {
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-    Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
-    adaptorImpl.RegisterSingleton( typeid( manager ), manager );
-    handle = manager;
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
+    {
+      Dali::AccessibilityManager manager = Dali::AccessibilityManager( new AccessibilityManager() );
+      service.Register( typeid( manager ), manager );
+      handle = manager;
+    }
   }
 
   return handle;
@@ -63,10 +69,11 @@ Dali::AccessibilityManager AccessibilityManager::Get()
 {
   Dali::AccessibilityManager manager;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::AccessibilityManager ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityManager ) );
     if(handle)
     {
       // If so, downcast the handle
@@ -243,8 +250,11 @@ void AccessibilityManager::DisableAccessibility()
     mStatusChangedSignalV2.Emit( handle );
 
     // Destroy the TtsPlayer if exists.
-    Dali::Adaptor& adaptor = Dali::Adaptor::Get();
-    Adaptor::GetImplementation(adaptor).DestroyTtsPlayer(Dali::TtsPlayer::SCREEN_READER);
+    if ( Adaptor::IsAvailable() )
+    {
+      Dali::Adaptor& adaptor = Dali::Adaptor::Get();
+      Adaptor::GetImplementation( adaptor ).DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER );
+    }
   }
 }
 
index b30b0de..86aa653 100644 (file)
@@ -25,7 +25,7 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace // unnamed namespace
 {
@@ -66,10 +66,11 @@ Dali::TiltSensor TiltSensor::Get()
 {
   Dali::TiltSensor sensor;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the keyboard focus manager is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::TiltSensor ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TiltSensor ) );
     if(handle)
     {
       // If so, downcast the handle of singleton to keyboard focus manager
@@ -78,9 +79,8 @@ Dali::TiltSensor TiltSensor::Get()
     else
     {
       // Create a singleton instance
-      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
       sensor = TiltSensor::New();
-      adaptorImpl.RegisterSingleton( typeid( sensor ), sensor );
+      service.Register( typeid( sensor ), sensor );
       handle = sensor;
     }
   }
index 987530e..90fdcdc 100644 (file)
@@ -25,9 +25,8 @@
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <adaptor.h>
 #include <dali/public-api/object/any.h>
-#include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 
 namespace //unnamed namespace
 {
@@ -74,10 +73,11 @@ Dali::Clipboard Clipboard::Get()
 {
   Dali::Clipboard clipboard;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
     if(handle)
     {
       // If so, downcast the handle
index 5a6c3f4..3c0a841 100644 (file)
@@ -28,6 +28,7 @@
 // INTERNAL INCLUDES
 #include <window-render-surface.h>
 #include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 #include <virtual-keyboard-impl.h>
 
 namespace Dali
@@ -131,10 +132,11 @@ Dali::ImfManager ImfManager::Get()
 {
   Dali::ImfManager manager;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ImfManager ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ImfManager ) );
     if(handle)
     {
       // If so, downcast the handle
index dfa2786..3d0f0f9 100644 (file)
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <adaptor.h>
 #include <dali/public-api/object/any.h>
 #include <adaptor-impl.h>
 #include <ecore-x-window-interface.h>
+#include <singleton-service-impl.h>
 
 namespace //unnamed namespace
 {
@@ -62,23 +62,27 @@ BaseHandle Create()
 
   if ( !handle && Adaptor::IsAvailable() )
   {
-    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
-
-    // The Ecore_X_Window needs to use the Clipboard.
-    // Only when the render surface is window, we can get the Ecore_X_Window.
-    Ecore_X_Window ecoreXwin( 0 );
-    Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
-    if( surface.GetType() == Dali::RenderSurface::WINDOW )
+    Dali::SingletonService service( SingletonService::Get() );
+    if ( service )
     {
-      ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
+      Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
+
+      // The Ecore_X_Window needs to use the Clipboard.
+      // Only when the render surface is window, we can get the Ecore_X_Window.
+      Ecore_X_Window ecoreXwin( 0 );
+      Dali::RenderSurface& surface( adaptorImpl.GetSurface() );
+      if( surface.GetType() == Dali::RenderSurface::WINDOW )
+      {
+        ecoreXwin = AnyCast< Ecore_X_Window >( adaptorImpl.GetSurface().GetSurface() );
+      }
+
+      // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
+      // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
+      // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
+      Dali::Clipboard clipboard = Dali::Clipboard( new Clipboard( ecoreXwin ) );
+      service.Register( typeid( clipboard ), clipboard );
+      handle = clipboard;
     }
-
-    // If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
-    // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
-    // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-    Dali::Clipboard clipboard = Dali::Clipboard( new Clipboard( ecoreXwin ) );
-    adaptorImpl.RegisterSingleton( typeid( clipboard ), clipboard );
-    handle = clipboard;
   }
 
   return handle;
@@ -100,10 +104,11 @@ Dali::Clipboard Clipboard::Get()
 {
   Dali::Clipboard clipboard;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
     if(handle)
     {
       // If so, downcast the handle
index 2f7db66..3e681b0 100644 (file)
@@ -28,6 +28,7 @@
 // INTERNAL INCLUDES
 #include <window-render-surface.h>
 #include <adaptor-impl.h>
+#include <singleton-service-impl.h>
 #include <virtual-keyboard-impl.h>
 
 namespace Dali
@@ -120,7 +121,8 @@ BaseHandle Create()
 {
   BaseHandle handle( ImfManager::Get() );
 
-  if ( !handle && Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( !handle && Adaptor::IsAvailable() && service )
   {
     Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
 
@@ -138,7 +140,7 @@ BaseHandle Create()
     // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
 
     Dali::ImfManager manager = Dali::ImfManager( new ImfManager( ecoreXwin ) );
-    adaptorImpl.RegisterSingleton( typeid( manager ), manager );
+    service.Register( typeid( manager ), manager );
     handle = manager;
   }
 
@@ -153,10 +155,11 @@ Dali::ImfManager ImfManager::Get()
 {
   Dali::ImfManager manager;
 
-  if ( Adaptor::IsAvailable() )
+  Dali::SingletonService service( SingletonService::Get() );
+  if ( service )
   {
     // Check whether the singleton is already created
-    Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ImfManager ) );
+    Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ImfManager ) );
     if(handle)
     {
       // If so, downcast the handle