• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • libcore
context.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2002 - 2009 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include <QObject>
20 
21 #include "context.h"
22 
23 //---------------------------------------------------
24 // ProfileContext
25 
26 ProfileContext* ProfileContext::_contexts = 0;
27 QString* ProfileContext::_typeName = 0;
28 QString* ProfileContext::_i18nTypeName = 0;
29 
30 
31 ProfileContext::ProfileContext(ProfileContext::Type t)
32 {
33  _type = t;
34 }
35 
36 ProfileContext* ProfileContext::context(ProfileContext::Type t)
37 {
38  if (!_contexts) {
39  _contexts = new ProfileContext[MaxType+1];
40  for(int i=0;i<=MaxType;i++)
41  _contexts[i] = ProfileContext((ProfileContext::Type)i);
42  }
43  return &(_contexts[t]);
44 }
45 
46 void ProfileContext::cleanup()
47 {
48  if (_typeName) {
49  delete [] _typeName;
50  _typeName = 0;
51  }
52  if (_i18nTypeName) {
53  delete [] _i18nTypeName;
54  _i18nTypeName = 0;
55  }
56  if (_contexts) {
57  delete [] _contexts;
58  _contexts = 0;
59  }
60 }
61 
62 QString ProfileContext::typeName(ProfileContext::Type t)
63 {
64  if (!_typeName) {
65  _typeName = new QString [MaxType+1];
66  QString* strs = _typeName;
67  for(int i=0;i<=MaxType;i++)
68  strs[i] = QString("?");
69 
70  strs[InvalidType] = QT_TR_NOOP("Invalid Context");
71  strs[UnknownType] = QT_TR_NOOP("Unknown Context");
72  strs[PartLine] = QT_TR_NOOP("Part Source Line");
73  strs[Line] = QT_TR_NOOP("Source Line");
74  strs[PartLineCall] = QT_TR_NOOP("Part Line Call");
75  strs[LineCall] = QT_TR_NOOP("Line Call");
76  strs[PartLineJump] = QT_TR_NOOP("Part Jump");
77  strs[LineJump] = QT_TR_NOOP("Jump");
78  strs[PartInstr] = QT_TR_NOOP("Part Instruction");
79  strs[Instr] = QT_TR_NOOP("Instruction");
80  strs[PartInstrJump] = QT_TR_NOOP("Part Instruction Jump");
81  strs[InstrJump] = QT_TR_NOOP("Instruction Jump");
82  strs[PartInstrCall] = QT_TR_NOOP("Part Instruction Call");
83  strs[InstrCall] = QT_TR_NOOP("Instruction Call");
84  strs[PartCall] = QT_TR_NOOP("Part Call");
85  strs[Call] = QT_TR_NOOP("Call");
86  strs[PartFunction] = QT_TR_NOOP("Part Function");
87  strs[FunctionSource] = QT_TR_NOOP("Function Source File");
88  strs[Function] = QT_TR_NOOP("Function");
89  strs[FunctionCycle] = QT_TR_NOOP("Function Cycle");
90  strs[PartClass] = QT_TR_NOOP("Part Class");
91  strs[Class] = QT_TR_NOOP("Class");
92  strs[PartFile] = QT_TR_NOOP("Part Source File");
93  strs[File] = QT_TR_NOOP("Source File");
94  strs[PartObject] = QT_TR_NOOP("Part ELF Object");
95  strs[Object] = QT_TR_NOOP("ELF Object");
96  strs[Part] = QT_TR_NOOP("Profile Part");
97  strs[Data] = QT_TR_NOOP("Program Trace");
98  }
99  if (t<0 || t> MaxType) t = MaxType;
100  return _typeName[t];
101 }
102 
103 ProfileContext::Type ProfileContext::type(const QString& s)
104 {
105  // This is the default context type
106  if (s.isEmpty()) return Function;
107 
108  Type type;
109  for (int i=0; i<MaxType;i++) {
110  type = (Type) i;
111  if (typeName(type) == s)
112  return type;
113  }
114  return UnknownType;
115 }
116 
117 // all strings of typeName() are translatable because of QT_TR_NOOP there
118 QString ProfileContext::i18nTypeName(Type t)
119 {
120  if (!_i18nTypeName) {
121  _i18nTypeName = new QString [MaxType+1];
122  for(int i=0;i<=MaxType;i++)
123  _i18nTypeName[i] = QObject::tr(typeName((Type)i).toUtf8());
124  }
125  if (t<0 || t> MaxType) t = MaxType;
126  return _i18nTypeName[t];
127 }
128 
129 ProfileContext::Type ProfileContext::i18nType(const QString& s)
130 {
131  // This is the default context type
132  if (s.isEmpty()) return Function;
133 
134  Type type;
135  for (int i=0; i<MaxType;i++) {
136  type = (Type) i;
137  if (i18nTypeName(type) == s)
138  return type;
139  }
140  return UnknownType;
141 }
ProfileContext::type
ProfileContext::Type type()
Definition: context.h:55
ProfileContext::Data
Definition: context.h:50
ProfileContext::Line
Definition: context.h:39
ProfileContext::PartClass
Definition: context.h:47
ProfileContext::FunctionCycle
Definition: context.h:46
ProfileContext::LineCall
Definition: context.h:43
ProfileContext::LineJump
Definition: context.h:41
context.h
ProfileContext::File
Definition: context.h:48
ProfileContext::typeName
static QString typeName(Type)
Definition: context.cpp:62
ProfileContext::PartInstr
Definition: context.h:38
ProfileContext::PartFile
Definition: context.h:48
ProfileContext::Call
Definition: context.h:44
ProfileContext::Instr
Definition: context.h:38
ProfileContext::PartInstrCall
Definition: context.h:42
ProfileContext::PartCall
Definition: context.h:44
ProfileContext::PartLineJump
Definition: context.h:41
ProfileContext::Class
Definition: context.h:47
ProfileContext::i18nType
static Type i18nType(const QString &)
Definition: context.cpp:129
ProfileContext::PartLine
Definition: context.h:39
ProfileContext::PartFunction
Definition: context.h:46
ProfileContext
Base class for source contexts which event costs contained in a ProfileData instance, ie.
Definition: context.h:32
ProfileContext::PartInstrJump
Definition: context.h:40
ProfileContext::ProfileContext
ProfileContext(ProfileContext::Type=InvalidType)
Definition: context.cpp:31
ProfileContext::i18nTypeName
static QString i18nTypeName(Type)
Definition: context.cpp:118
ProfileContext::FunctionSource
Definition: context.h:46
ProfileContext::cleanup
static void cleanup()
Definition: context.cpp:46
ProfileContext::PartLineCall
Definition: context.h:43
ProfileContext::Type
Type
Definition: context.h:36
ProfileContext::PartObject
Definition: context.h:49
ProfileContext::Part
Definition: context.h:50
ProfileContext::InstrCall
Definition: context.h:42
ProfileContext::MaxType
Definition: context.h:51
ProfileContext::Object
Definition: context.h:49
ProfileContext::context
static ProfileContext * context(ProfileContext::Type)
Definition: context.cpp:36
ProfileContext::UnknownType
Definition: context.h:37
ProfileContext::InstrJump
Definition: context.h:40
ProfileContext::Function
Definition: context.h:46
ProfileContext::InvalidType
Definition: context.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal