Merge "(Build) Specify vconf package so there is no ambiguity" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / base / performance-logging / performance-server.h
1 #ifndef __DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H__
2 #define __DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_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 // INTERNAL INCLUDES
22 #include <base/performance-logging/frame-time-stats.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <base/interfaces/adaptor-internal-services.h>
25 #include <base/performance-logging/performance-marker.h>
26 #include <base/performance-logging/statistics/stat-context-manager.h>
27
28 // EXTERNAL INCLUDES
29 #include <boost/thread/mutex.hpp>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 class EnvironmentOptions;
41 class StatContext;
42 /**
43  * Concrete implementation of performance interface.
44  * Adaptor classes should never include this file, they
45  * just need to include the abstract class performance-interface.h
46  */
47 class PerformanceServer : public PerformanceInterface, public StatContextLogInterface
48 {
49 public:
50
51   /**
52    * @brief Constructor
53    * @param[in] adaptorServices adaptor internal services
54    * @param[in] environmentOptions environment options
55    */
56   PerformanceServer( AdaptorInternalServices& adaptorServices,
57                      const EnvironmentOptions& environmentOptions );
58
59   /**
60    * Destructor
61    */
62   virtual ~PerformanceServer();
63
64   /**
65    * @copydoc PerformanceLogger::AddContext()
66    */
67   virtual ContextId AddContext( const char* name );
68
69   /**
70    * @copydoc PerformanceLogger::RemoveContext()
71    */
72   virtual void RemoveContext( ContextId contextId );
73
74   /**
75    * @copydoc PerformanceInterface::AddMarker( MarkerType markerType )
76    */
77   virtual void AddMarker( MarkerType markerType );
78
79   /**
80    * @copydoc PerformanceLogger::AddMarker( MarkerType markerType, ContextId contextId )
81    */
82   virtual void AddMarker( MarkerType markerType, ContextId contextId );
83
84   /**
85    * @copydoc PerformanceInterface::SetLogging()
86    */
87   virtual void SetLogging( unsigned int statisticsLogOptions,
88                            unsigned int timeStampOutput,
89                            unsigned int logFrequency );
90
91   /**
92    * @copydoc PerformanceLogger::SetLoggingFrequency()
93    */
94   virtual void SetLoggingFrequency( unsigned int logFrequency, ContextId contextId );
95
96   /**
97    * @copydoc PerformanceLogger::EnableLogging()
98    */
99   virtual void EnableLogging( bool enable, ContextId contextId );
100
101 public: //StatLogInterface
102
103   /**
104    * @copydoc StatLogInterface::LogContextStatistics()
105    */
106   virtual void LogContextStatistics( const char* const text );
107
108 private:
109
110   /**
111    * @brief log the marker out to kernel/ DALi log
112    * @param[in] marker performance marker
113    * @param[in] description marker description
114    */
115   void LogMarker( const PerformanceMarker& marker, const char* const description );
116
117 private:
118
119   Integration::PlatformAbstraction& mPlatformAbstraction; ///< platform abstraction
120   const EnvironmentOptions& mEnvironmentOptions;          ///< environment options
121   KernelTraceInterface& mKernelTrace;                     ///< kernel trace interface
122   boost::mutex mDataMutex;                                ///< mutex
123   StatContextManager mStatContextManager;                 ///< Stat context manager
124   unsigned int mStatisticsLogBitmask;                     ///< statistics log level
125   unsigned int mPerformanceOutputBitmask;                 ///< performance marker output
126   bool mLoggingEnabled:1;                                 ///< whether logging update / render to a log is enabled
127   bool mLogFunctionInstalled:1;                           ///< whether the log function is installed
128 };
129
130
131 } // namespace Internal
132
133 } // namespace Adaptor
134
135 } // namespace Dali
136
137 #endif