Dali 3D User Interface Engine
test-trace-call-stack.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include "test-trace-call-stack.h"
19 
20 namespace Dali
21 {
25 TraceCallStack::TraceCallStack() : mTraceActive(false) { }
26 
31 
35 void TraceCallStack::Enable(bool enable) { mTraceActive = enable; }
36 
37 bool TraceCallStack::IsEnabled() { return mTraceActive; }
38 
44 void TraceCallStack::PushCall(std::string method, std::string params)
45 {
46  if(mTraceActive)
47  {
48  std::vector< std::string > functionCall;
49  functionCall.push_back(method);
50  functionCall.push_back(params);
51  mCallStack.push_back( functionCall );
52  }
53 }
54 
60 bool TraceCallStack::FindMethod(std::string method) const
61 {
62  bool found = false;
63  for( size_t i=0; i < mCallStack.size(); i++ )
64  {
65  if( 0 == mCallStack[i][0].compare(method) )
66  {
67  found = true;
68  break;
69  }
70  }
71  return found;
72 }
73 
74 int TraceCallStack::CountMethod(std::string method) const
75 {
76  int numCalls = 0;
77  for( size_t i=0; i < mCallStack.size(); i++ )
78  {
79  if( 0 == mCallStack[i][0].compare(method) )
80  {
81  numCalls++;
82  }
83  }
84  return numCalls;
85 }
86 
93 bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const
94 {
95  return FindIndexFromMethodAndParams( method, params ) > -1;
96 }
97 
104 int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const
105 {
106  int index = -1;
107  for( size_t i=0; i < mCallStack.size(); i++ )
108  {
109  if( 0 == mCallStack[i][0].compare(method) && 0 == mCallStack[i][1].compare(params) )
110  {
111  index = i;
112  break;
113  }
114  }
115  return index;
116 }
117 
124 bool TraceCallStack::TestMethodAndParams(int index, std::string method, std::string params) const
125 {
126  return ( 0 == mCallStack[index][0].compare(method) && 0 == mCallStack[index][1].compare(params) );
127 }
128 
133 {
134  mCallStack.clear();
135 }
136 
137 
138 } // namespace Dali
Dali Docs Home
Read more about Dali