Uniform map handling
[platform/core/uifw/dali-core.git] / dali / internal / event / common / object-registry-impl.cpp
index 7e1cad7..edd5232 100644 (file)
@@ -1,18 +1,19 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://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.
-//
+/*
+ * 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 <dali/internal/event/common/object-registry-impl.h>
@@ -23,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/event/common/thread-local-storage.h>
 #include <dali/public-api/object/object-registry.h>
+#include <dali/public-api/object/type-registry.h>
 
 namespace Dali
 {
@@ -30,9 +32,24 @@ namespace Dali
 namespace Internal
 {
 
+namespace
+{
+
+// Signals
+
+const char* const SIGNAL_OBJECT_CREATED =   "object-created";
+const char* const SIGNAL_OBJECT_DESTROYED = "object-destroyed";
+
+TypeRegistration mType( typeid( Dali::ObjectRegistry ), typeid( Dali::BaseHandle ), NULL );
+
+SignalConnectorType signalConnector1( mType, SIGNAL_OBJECT_CREATED,   &ObjectRegistry::DoConnectSignal );
+SignalConnectorType signalConnector2( mType, SIGNAL_OBJECT_DESTROYED, &ObjectRegistry::DoConnectSignal );
+
+}
+
 ObjectRegistryPtr ObjectRegistry::New()
 {
-  return ObjectRegistryPtr(new ObjectRegistry());
+  return ObjectRegistryPtr( new ObjectRegistry() );
 }
 
 ObjectRegistry::ObjectRegistry()
@@ -45,40 +62,31 @@ ObjectRegistry::~ObjectRegistry()
 
 void ObjectRegistry::RegisterObject( Dali::BaseObject* object )
 {
-  // Assert than an object is only registered once
-  DALI_ASSERT_DEBUG( mDebugRegistry.end() == mDebugRegistry.find( object ) );
-
-#ifdef DEBUG_ENABLED
-  // This allows us to assert that an object is only registered once (debug builds only)
-  mDebugRegistry.insert( object );
-#endif // DEBUG_ENABLED
-
-  if ( !mObjectCreatedSignalV2.Empty() )
+  if ( !mObjectCreatedSignal.Empty() )
   {
     Dali::BaseHandle handle( object );
-    mObjectCreatedSignalV2.Emit( handle );
+    mObjectCreatedSignal.Emit( handle );
   }
 }
 
 void ObjectRegistry::UnregisterObject( Dali::BaseObject* object )
 {
-#ifdef DEBUG_ENABLED
-  // This allows us to assert that an object is only registered once (debug builds only)
-  mDebugRegistry.erase( object );
-#endif // DEBUG_ENABLED
-
-  mObjectDestroyedSignalV2.Emit( object );
+  mObjectDestroyedSignal.Emit( object );
 }
 
 bool ObjectRegistry::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   bool connected( true );
-  ObjectRegistry* objectRegistry = dynamic_cast<ObjectRegistry*>(object);
+  ObjectRegistry* objectRegistry = dynamic_cast<ObjectRegistry*>( object );
 
-  if(Dali::ObjectRegistry::SIGNAL_OBJECT_CREATED == signalName)
+  if( 0 == strcmp( signalName.c_str(), SIGNAL_OBJECT_CREATED ) )
   {
     objectRegistry->ObjectCreatedSignal().Connect( tracker, functor );
   }
+  else if( 0 == strcmp( signalName.c_str(), SIGNAL_OBJECT_DESTROYED ) )
+  {
+    objectRegistry->ObjectDestroyedSignal().Connect( tracker, functor );
+  }
   else
   {
     // signalName does not match any signal