+ DALI_ASSERT_ALWAYS(gAdaptor);
+ return *gAdaptor;
+}
+
+Adaptor::Adaptor()
+{
+}
+
+Adaptor::~Adaptor()
+{
+ gAdaptor = nullptr;
+}
+
+void Adaptor::Start(Dali::Window window)
+{
+ AddWindow(&GetImplementation(window));
+}
+
+Integration::Scene Adaptor::GetScene(Dali::Window window)
+{
+ return window.GetScene();
+}
+
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
+{
+ if(hasReturnValue)
+ {
+ mReturnCallbacks.PushBack(callback);
+ }
+ else
+ {
+ mCallbacks.PushBack(callback);
+ }
+ return true;
+}
+
+void Adaptor::RemoveIdle(CallbackBase* callback)
+{
+ mCallbacks.Erase(std::remove_if(mCallbacks.Begin(), mCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mCallbacks.End());
+ mReturnCallbacks.Erase(std::remove_if(mReturnCallbacks.Begin(), mReturnCallbacks.End(), [&callback](CallbackBase* current) { return callback == current; }), mReturnCallbacks.End());
+}
+
+void Adaptor::RunIdles()
+{
+ Dali::Vector<CallbackBase*> reusedCallbacks;
+ for(auto& callback : mReturnCallbacks)
+ {
+ bool retValue = CallbackBase::ExecuteReturn<bool>(*callback);
+ if(retValue)
+ {
+ reusedCallbacks.PushBack(callback);
+ }
+ }
+ for(auto& callback : mCallbacks)
+ {
+ CallbackBase::Execute(*callback);
+ }
+
+ mCallbacks.Clear();
+ mReturnCallbacks.Clear();
+ mReturnCallbacks.Swap(reusedCallbacks);