Apply deprecate macro and LOG
[platform/core/uifw/dali-core.git] / dali / public-api / common / dali-common.h
index c5920c1..c49d4ca 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_COMMON_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
  */
 
 // EXTERNAL INCLUDES
-#include <cstdio>
 
 #ifdef EMSCRIPTEN
 #include <emscripten/emscripten.h>
 #endif
+
 /*
  * Definitions for shared library support
  *
 #  define DALI_INTERNAL
 #endif
 
+#ifdef DEPRECATION_WARNING
+#define DALI_DEPRECATED_API __attribute__((__visibility__("default"), deprecated))
+#else
+#define DALI_DEPRECATED_API
+#endif
+
 #if defined (__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
 // C++0x support
 #define _CPP11
 #endif
 
 /**
+ * @brief Two macros to provide branch predictor information.
+ * DALI_LIKELY should be used when a branch is taken in almost all cases so the
+ * branch predictor can avoid pre-fetching the code for else branch
+ * DALI_UNLIKELY should be used when a branch is almost never taken
+ * @SINCE_1_0.0
+ */
+#define DALI_LIKELY(expression)   __builtin_expect( !!(expression), 1 )
+#define DALI_UNLIKELY(expression) __builtin_expect( !!(expression), 0 )
+
+/**
  * @brief The DALi namespace
+ * @SINCE_1_0.0
  */
 namespace Dali
 {
+/**
+ * @addtogroup dali_core_common
+ * @{
+ */
 
 /**
  * @brief Method to log assertion message in DALI_ASSERT_ALWAYS macro below.
  *
+ * @SINCE_1_0.0
  * @param[in] location Where the assertion occurred
  * @param[in] condition The assertion condition
  */
@@ -91,6 +113,7 @@ DALI_IMPORT_API void DaliAssertMessage( const char* location, const char* condit
 
 /**
  * @brief Exception class for Dali Core library - Raised by assertions in codebase.
+ * @SINCE_1_0.0
  */
 class DALI_IMPORT_API DaliException
 {
@@ -100,8 +123,9 @@ public:
    *
    * Will always display a backtrace when raised in a debug build.
    *
-   * @param[in] location  - the location of the assertion
-   * @param[in] condition - The assertion condition
+   * @SINCE_1_0.0
+   * @param[in] location The location of the assertion
+   * @param[in] condition The assertion condition
    */
   DaliException( const char* location, const char* condition );
 
@@ -109,6 +133,9 @@ public:
   const char* condition;
 };
 
+/**
+ * @}
+ */
 }// Dali
 
 /**
@@ -133,8 +160,9 @@ public:
  */
 
 /**
- * Strip assert location for release builds, assert text is descriptive enough
+ * @brief Strip assert location for release builds, assert text is descriptive enough
  * This is to save space for low spec devices
+ * @SINCE_1_0.0
  */
 #if defined(DEBUG_ENABLED)
 #define ASSERT_LOCATION __PRETTY_FUNCTION__
@@ -145,7 +173,7 @@ public:
 #ifdef EMSCRIPTEN
 
 #define DALI_ASSERT_ALWAYS(cond)                \
-  if(!(cond)) \
+  if(DALI_UNLIKELY(!(cond))) \
   { \
     Dali::DaliAssertMessage( ASSERT_LOCATION, #cond );   \
     throw Dali::DaliException( ASSERT_LOCATION, #cond );  \
@@ -154,7 +182,7 @@ public:
 #else
 
 #define DALI_ASSERT_ALWAYS(cond)                \
-  if(!(cond)) \
+  if(DALI_UNLIKELY(!(cond))) \
   { \
     Dali::DaliAssertMessage( ASSERT_LOCATION, #cond );   \
     throw Dali::DaliException( ASSERT_LOCATION, #cond );  \
@@ -165,6 +193,7 @@ public:
  * @brief An invariant concurrent assertion to ensure its argument evaluates TRUE in debug builds.
  *
  * Use this to sanity check algorithms and prevent internal programming errors
+ * @SINCE_1_0.0
  */
 #if defined(DEBUG_ENABLED)
 #define DALI_ASSERT_DEBUG(cond) DALI_ASSERT_ALWAYS(cond)