[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / performance-logger.h
1 #ifndef DALI_PERFORMANCE_LOGGER_H
2 #define DALI_PERFORMANCE_LOGGER_H
3
4 /*
5  * Copyright (c) 2020 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29 namespace Internal DALI_INTERNAL
30 {
31 namespace Adaptor
32 {
33 class PerformanceLogger;
34 }
35 } // namespace DALI_INTERNAL
36
37 /**
38  * @brief Performance logger class
39  */
40 class DALI_ADAPTOR_API PerformanceLogger : public BaseHandle
41 {
42 public:
43   /**
44    * Enum for events that can be logged
45    */
46   enum Marker
47   {
48     START_EVENT, ///< The start of timing
49     END_EVENT    ///< The end of timing
50   };
51
52   /**
53    * @brief Constructor, creates an uninitialized logger.
54    *
55    * Call New to fully construct a logger.
56    */
57   PerformanceLogger();
58
59   /**
60    * @brief Create a new logger
61    *
62    * @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.
63    * @return a new logger
64    */
65   static PerformanceLogger New(const char* name);
66
67   /**
68    * @brief Copy constructor.
69    *
70    * @param[in] logger The handle to copy. The copied handle will point at the same implementation
71    */
72   PerformanceLogger(const PerformanceLogger& logger);
73
74   /**
75    * @brief Assignment operator.
76    *
77    * @param[in] logger The handle to copy. This handle will point at the same implementation
78    * as the copied handle.
79    * @return Reference to this logger handle
80    */
81   PerformanceLogger& operator=(const PerformanceLogger& logger);
82
83   /**
84    * @brief Destructor
85    *
86    * This is non-virtual since derived Handle types must not contain data or virtual methods.
87    */
88   ~PerformanceLogger();
89
90   /**
91    * @brief Downcast an Object handle to PerformanceLogger handle.
92    *
93    * If handle points to a PerformanceLogger object the downcast produces a valid
94    * handle. If not the returned handle is left uninitialized.
95    *
96    * @param[in] handle to An object
97    * @return handle to a PerformanceLogger object or an uninitialized handle
98    */
99   static PerformanceLogger DownCast(BaseHandle handle);
100
101   /**
102    * Add a performance marker
103    *
104    * @param markerType Performance marker type
105    */
106   void AddMarker(Marker markerType);
107
108   /**
109    * Set the logging frequency
110    *
111    * @param logFrequency how often to log out in seconds
112    */
113   void SetLoggingFrequency(unsigned int logFrequency);
114
115   /**
116    * Set logging on or off for this logger
117    *
118    * @param[in] enable Enable logging or not
119    */
120   void EnableLogging(bool enable);
121
122   // Not intended for application developers
123
124   /**
125    * Creates a new handle from the implementation.
126    * @param[in] impl A pointer to the object.
127    */
128   explicit DALI_INTERNAL PerformanceLogger(Internal::Adaptor::PerformanceLogger* impl);
129 };
130
131 } // namespace Dali
132
133 #endif // DALI_PERFORMANCE_LOGGER_H