Merge "Expose custom performance timers" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / common / performance-logger-impl.h
1 #ifndef __DALI_INTERNAL_PERFORMANCE_LOGGER_H__
2 #define __DALI_INTERNAL_PERFORMANCE_LOGGER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #include <base/interfaces/performance-interface.h>
22
23 // EXTERNAL INCLUDES
24 #include <dali/public-api/object/base-object.h>
25 #include <performance-logger.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace Adaptor
34 {
35
36 class PerformanceLogger;
37
38 typedef IntrusivePtr<PerformanceLogger> PerformanceLoggerPtr;
39
40 /**
41  * @brief Interface for the performance logger
42  */
43 class PerformanceLogger : public BaseObject
44 {
45 public:
46
47   /**
48    * @brief Create a new logger
49    *
50    * @param[in] name The name of the logger. This needs to be a compile-time literal and alive for the whole lifetime of the performance logger.
51    * @return a new logger
52    */
53   static PerformanceLoggerPtr New( const char* name );
54
55   /**
56    * Constructor
57    * @param[in] name The name to assing to the logger
58    */
59   PerformanceLogger( const char* name );
60
61   /**
62    * Destructor.
63    */
64   virtual ~PerformanceLogger();
65
66   /**
67    * Add a performance marker
68    *
69    * @param markerType Performance marker type
70    */
71   void AddMarker( Dali::PerformanceLogger::Marker markerType );
72
73   /**
74    * Set the logging frequency
75    *
76    * @param logFrequency how often to log out in seconds
77    */
78   void SetLoggingFrequency( unsigned int logFrequency);
79
80   /**
81    * Set logging on or off for this logger
82    *
83    * @param[in] enable Enable logging or not
84    */
85   void EnableLogging( bool enable );
86
87 private: // Implementation
88
89   // not implemented
90   PerformanceLogger( const PerformanceLogger& );
91   PerformanceLogger& operator=( const PerformanceLogger& );
92
93 private:
94
95   PerformanceInterface::ContextId mContext;   ///< Context of this logger
96
97 };
98
99 // Helpers for public-api forwarding methods
100
101 inline static Internal::Adaptor::PerformanceLogger& GetImplementation( Dali::PerformanceLogger& logger )
102 {
103   DALI_ASSERT_ALWAYS( logger && "PerformanceLogger handle is empty" );
104
105   BaseObject& handle = logger.GetBaseObject();
106
107   return static_cast< Internal::Adaptor::PerformanceLogger& >( handle );
108 }
109
110 inline static const  Internal::Adaptor::PerformanceLogger& GetImplementation( const Dali::PerformanceLogger& logger )
111 {
112   DALI_ASSERT_ALWAYS( logger && "PerformanceLogger handle is empty" );
113
114   const BaseObject& handle = logger.GetBaseObject();
115
116   return static_cast< const Internal::Adaptor::PerformanceLogger& >( handle );
117 }
118
119 } // namespace Adaptor
120
121 } // namespace Internal
122
123 } // namespace Dali
124
125 #endif // __DALI_INTERNAL_PERFORMANCE_LOGGER_H__