Added mechanism to get type info of CustomActor 33/134433/2
authorDavid Steele <david.steele@samsung.com>
Thu, 15 Jun 2017 15:57:14 +0000 (16:57 +0100)
committerDavid Steele <david.steele@samsung.com>
Mon, 19 Jun 2017 10:12:06 +0000 (11:12 +0100)
For non-native derived classes of CustomActor, it is useful to be
able to get the registered type name without using the native
"typeid" mechanism, which usually gets to the most-derived native
class. Instead, if the glue layer registers the non-native typenames
with the type registry using DevelHandle::SetTypeInfo, then

Change-Id: Ic79ce1a239a965e5c2c74ea2b8980c2f9ca29f8c
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali/utc-Dali-CustomActor.cpp
dali/devel-api/actors/custom-actor-devel.cpp [new file with mode: 0644]
dali/devel-api/actors/custom-actor-devel.h [new file with mode: 0644]
dali/devel-api/file.list
dali/internal/event/actors/custom-actor-internal.cpp
dali/internal/event/actors/custom-actor-internal.h

index 0449f34..34392ad 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <dali/public-api/dali-core.h>
 
+#include <dali/devel-api/actors/custom-actor-devel.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
@@ -1329,3 +1330,18 @@ int UtcDaliCustomActorSetGetProperty(void)
 
   END_TEST;
 }
+
+
+int utcDaliActorGetTypeInfo(void)
+{
+  TestApplication application;
+  tet_infoline( "Get the type info of a derived actor" );
+
+  Test::TestCustomActor customActor = Test::TestCustomActor::New();
+
+  Dali::TypeInfo typeInfo = Dali::DevelCustomActor::GetTypeInfo( customActor );
+
+  DALI_TEST_EQUALS( typeInfo.GetName(), std::string("TestCustomActor"), TEST_LOCATION );
+
+  END_TEST;
+}
diff --git a/dali/devel-api/actors/custom-actor-devel.cpp b/dali/devel-api/actors/custom-actor-devel.cpp
new file mode 100644 (file)
index 0000000..3c1d7bb
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/actors/custom-actor-devel.h>
+#include <dali/internal/event/actors/custom-actor-internal.h>
+#include <dali/public-api/actors/custom-actor-impl.h>
+#include <dali/public-api/object/type-info.h>
+
+namespace Dali
+{
+
+namespace DevelCustomActor
+{
+
+const Dali::TypeInfo GetTypeInfo( CustomActor actor )
+{
+  return actor.GetImplementation().GetOwner()->GetTypeInfo();
+}
+
+} // namespace DevelCustomActor
+
+} // namespace Dali
diff --git a/dali/devel-api/actors/custom-actor-devel.h b/dali/devel-api/actors/custom-actor-devel.h
new file mode 100644 (file)
index 0000000..f5906af
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef DALI_CUSTOM_ACTOR_DEVEL_H
+#define DALI_CUSTOM_ACTOR_DEVEL_H
+
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/custom-actor.h>
+
+namespace Dali
+{
+
+namespace DevelCustomActor
+{
+
+/**
+ * Get the type info for the CustomActor.
+ * This is useful when the type information has been set via
+ * DevelHandle::SetTypeInfo() for this object.
+ * @param[in] actor The custom actor of which to get the type information
+ * @return the TypeInfo of this actor
+ */
+DALI_IMPORT_API const Dali::TypeInfo GetTypeInfo( CustomActor actor );
+
+} // namespace DevelCustomActor
+
+} // namespace Dali
+
+#endif // DALI_CUSTOM_ACTOR_DEVEL_H
index baab797..6d8abde 100644 (file)
@@ -1,6 +1,7 @@
 # Add devel source files here for DALi internal developer files used by Adaptor & Toolkit
 devel_api_src_files = \
   $(devel_api_src_dir)/actors/actor-devel.cpp \
+  $(devel_api_src_dir)/actors/custom-actor-devel.cpp \
   $(devel_api_src_dir)/animation/animation-data.cpp \
   $(devel_api_src_dir)/animation/animation-devel.cpp \
   $(devel_api_src_dir)/animation/path-constrainer.cpp \
@@ -25,6 +26,7 @@ devel_api_src_files = \
 
 devel_api_core_actors_header_files = \
   $(devel_api_src_dir)/actors/actor-devel.h \
+  $(devel_api_src_dir)/actors/custom-actor-devel.h \
   $(devel_api_src_dir)/actors/layer-devel.h
 
 devel_api_core_animation_header_files = \
index acfd82c..0ff93f9 100644 (file)
@@ -17,6 +17,7 @@
 
 // CLASS HEADER
 #include <dali/internal/event/actors/custom-actor-internal.h>
+#include <dali/public-api/object/type-info.h>
 
 namespace Dali
 {
@@ -49,6 +50,12 @@ CustomActor::~CustomActor()
 {
 }
 
+Dali::TypeInfo CustomActor::GetTypeInfo()
+{
+  Dali::TypeInfo handle ( const_cast<Dali::Internal::TypeInfo*>(Object::GetTypeInfo()) );
+  return handle;
+}
+
 } // namespace Internal
 
 } // namespace Dali
index f4bef9f..259b785 100644 (file)
@@ -58,6 +58,13 @@ public:
     return *mImpl;
   }
 
+  /**
+   * Get the type info associated with this object.
+   *
+   * @return The type info
+   */
+  Dali::TypeInfo GetTypeInfo();
+
 protected:
 
   /**