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

kcachegrind

  • sources
  • kde-4.14
  • kdesdk
  • kcachegrind
  • libcore
eventtype.h
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 #ifndef EVENTTYPE_H
20 #define EVENTTYPE_H
21 
22 #include <QString>
23 
24 #include "subcost.h"
25 #include "costitem.h"
26 
27 class EventTypeSet;
28 
43 class EventType
44 {
45 public:
46 
53  explicit EventType(const QString& name,
54  const QString& longName = QString(),
55  const QString& formula = QString());
56 
57  void setName(const QString& n) { _name = n; }
58  void setLongName(const QString& n) { _longName = n; }
59  void setEventTypeSet(EventTypeSet* m);
60  // enforces event to be derived, even with empty formula
61  void setFormula(const QString&);
62  // default arg is for specifying a real type, but index unknown
63  void setRealIndex(int r = ProfileCostArray::MaxRealIndex);
64 
65  const QString& name() { return _name; }
66  const QString& longName() { return _longName; }
67  const QString& formula() { return _formula; }
68  EventTypeSet* set() { return _set; }
69  int realIndex() { return _realIndex; }
70  bool isReal() { return _isReal; }
71 
72  /*
73  * returns true if all cost type names can be resolved in formula
74  */
75  bool parseFormula();
76  QString parsedFormula();
77  QString parsedRealFormula();
78 
79  SubCost subCost(ProfileCostArray*);
80 
81  /*
82  * For virtual costs, returns a histogram for use with
83  * partitionPixmap().
84  * Returns maximal real index.
85  */
86  int histCost(ProfileCostArray* c, double total, double* hist);
87 
88  // application wide known types, referenced by short name
89  // next 2 functions return a new type object instance
90  static EventType* knownRealType(const QString&);
91  static EventType* knownDerivedType(const QString&);
92  static void add(EventType*, bool overwriteExisting = true);
93  static bool remove(const QString&);
94  static int knownTypeCount();
95  static EventType* knownType(int);
96 
97 private:
98 
99  QString _name, _longName, _formula, _parsedFormula;
100  EventTypeSet* _set;
101  bool _parsed, _inParsing, _isReal;
102  // index MaxRealIndex is for constant addition
103  int _coefficient[MaxRealIndexValue];
104  int _realIndex;
105 
106  static QList<EventType*>* _knownTypes;
107 };
108 
109 
117 class EventTypeSet
118 {
119 public:
120  EventTypeSet();
121  ~EventTypeSet();
122 
127  EventTypeMapping* createMapping(const QString& types);
128 
129  // "knows" about some real types
130  int addReal(const QString&);
131  int add(EventType*);
132  bool remove(EventType*);
133  int realCount() { return _realCount; }
134  int derivedCount() { return _derivedCount; }
135  int minDerivedIndex() { return ProfileCostArray::MaxRealIndex; }
136  EventType* type(int);
137  EventType* realType(int);
138  EventType* derivedType(int);
139  EventType* type(const QString&);
140  EventType* typeForLong(const QString&);
141  int realIndex(const QString&);
142  int index(const QString&);
143 
147  int addKnownDerivedTypes();
148 
149 private:
150  // we support only a fixed number of real and derived types
151  EventType* _real[MaxRealIndexValue];
152  EventType* _derived[MaxRealIndexValue];
153  int _realCount, _derivedCount;
154 };
155 
170 class EventTypeMapping
171 {
172 public:
173  EventTypeMapping(EventTypeSet*);
174 
175  bool append(const QString&, bool create=true);
176  bool append(int);
177  void clear();
178 
179  EventTypeSet* set() { return _set; }
180 
184  int count() { return _count; }
185 
190  bool isIdentity() { return _isIdentity; }
191  int realIndex(int i)
192  { return (i<0 || i>=_count) ? ProfileCostArray::InvalidIndex : _realIndex[i]; }
193 
197  int maxRealIndex(int count);
198 
204  int firstUnused() { return _firstUnused; }
205  int nextUnused(int i) {
206  if (i<0 || i>=ProfileCostArray::MaxRealIndex) return ProfileCostArray::InvalidIndex;
207  return _nextUnused[i]; }
208 
209 private:
210  EventTypeSet* _set;
211  int _count, _firstUnused;
212  bool _isIdentity;
213  int _realIndex[MaxRealIndexValue];
214  int _nextUnused[MaxRealIndexValue];
215 };
216 
217 
218 #endif // EVENTTYPE_H
EventTypeMapping::firstUnused
int firstUnused()
Allows an iteration over the sorted list of all real indexes not used in this mapping, up to topIndex (use ProfileCostArray::MaxRealIndex for all).
Definition: eventtype.h:204
EventTypeSet::realCount
int realCount()
Definition: eventtype.h:133
EventType::EventType
EventType(const QString &name, const QString &longName=QString(), const QString &formula=QString())
is a short (non-localized) identifier for the cost type, e.g.
Definition: eventtype.cpp:31
EventType::setEventTypeSet
void setEventTypeSet(EventTypeSet *m)
Definition: eventtype.cpp:55
ProfileCostArray::MaxRealIndex
static const int MaxRealIndex
Definition: costitem.h:150
EventType::parsedFormula
QString parsedFormula()
Definition: eventtype.cpp:161
EventTypeMapping::nextUnused
int nextUnused(int i)
Definition: eventtype.h:205
MaxRealIndexValue
#define MaxRealIndexValue
Definition: costitem.h:136
EventType::setFormula
void setFormula(const QString &)
Definition: eventtype.cpp:47
ProfileCostArray::InvalidIndex
static const int InvalidIndex
Definition: costitem.h:151
EventTypeSet::addKnownDerivedTypes
int addKnownDerivedTypes()
Adds all known derived event types that can be parsed.
Definition: eventtype.cpp:536
EventTypeSet::type
EventType * type(int)
Definition: eventtype.cpp:475
EventTypeMapping::clear
void clear()
Definition: eventtype.cpp:571
EventTypeMapping
A index list into a EventTypeSet.
Definition: eventtype.h:170
EventType
A cost type, e.g.
Definition: eventtype.h:43
EventType::knownDerivedType
static EventType * knownDerivedType(const QString &)
Definition: eventtype.cpp:249
EventTypeSet::typeForLong
EventType * typeForLong(const QString &)
Definition: eventtype.cpp:500
EventType::knownRealType
static EventType * knownRealType(const QString &)
Definition: eventtype.cpp:236
EventTypeMapping::set
EventTypeSet * set()
Definition: eventtype.h:179
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
EventTypeMapping::realIndex
int realIndex(int i)
Definition: eventtype.h:191
costitem.h
subcost.h
EventType::parseFormula
bool parseFormula()
Definition: eventtype.cpp:74
EventTypeMapping::EventTypeMapping
EventTypeMapping(EventTypeSet *)
Definition: eventtype.cpp:565
EventType::parsedRealFormula
QString parsedRealFormula()
Definition: eventtype.cpp:169
EventType::knownTypeCount
static int knownTypeCount()
Definition: eventtype.cpp:291
EventType::formula
const QString & formula()
Definition: eventtype.h:67
EventTypeSet::derivedCount
int derivedCount()
Definition: eventtype.h:134
EventTypeMapping::maxRealIndex
int maxRealIndex(int count)
Get maximal real index for the first mapping indexes.
Definition: eventtype.cpp:582
QString
QList< EventType * >
EventType::isReal
bool isReal()
Definition: eventtype.h:70
EventTypeSet::addReal
int addReal(const QString &)
Definition: eventtype.cpp:387
EventTypeSet::minDerivedIndex
int minDerivedIndex()
Definition: eventtype.h:135
EventTypeSet::add
int add(EventType *)
Definition: eventtype.cpp:403
EventType::subCost
SubCost subCost(ProfileCostArray *)
Definition: eventtype.cpp:196
EventTypeSet::createMapping
EventTypeMapping * createMapping(const QString &types)
Defines a mapping from indexes into a list of costs to real event types If is false...
Definition: eventtype.cpp:341
EventTypeSet::realIndex
int realIndex(const QString &)
Definition: eventtype.cpp:514
EventTypeSet::realType
EventType * realType(int)
Definition: eventtype.cpp:462
EventType::knownType
static EventType * knownType(int)
Definition: eventtype.cpp:312
EventTypeSet::EventTypeSet
EventTypeSet()
Definition: eventtype.cpp:324
EventTypeSet::index
int index(const QString &)
Definition: eventtype.cpp:523
EventType::add
static void add(EventType *, bool overwriteExisting=true)
Definition: eventtype.cpp:263
SubCost
Cost event counter, simple wrapper around a 64bit entity.
Definition: subcost.h:32
EventType::setName
void setName(const QString &n)
Definition: eventtype.h:57
EventTypeSet::~EventTypeSet
~EventTypeSet()
Definition: eventtype.cpp:332
EventType::longName
const QString & longName()
Definition: eventtype.h:66
EventTypeSet
A class for managing a set of event types.
Definition: eventtype.h:117
EventType::setRealIndex
void setRealIndex(int r=ProfileCostArray::MaxRealIndex)
Definition: eventtype.cpp:63
EventTypeMapping::isIdentity
bool isIdentity()
Is this mapping the identity( i.e.
Definition: eventtype.h:190
EventType::realIndex
int realIndex()
Definition: eventtype.h:69
EventType::setLongName
void setLongName(const QString &n)
Definition: eventtype.h:58
EventTypeSet::derivedType
EventType * derivedType(int)
Definition: eventtype.cpp:468
EventTypeMapping::append
bool append(const QString &, bool create=true)
Definition: eventtype.cpp:594
EventType::set
EventTypeSet * set()
Definition: eventtype.h:68
EventType::histCost
int histCost(ProfileCostArray *c, double total, double *hist)
Definition: eventtype.cpp:214
EventType::name
const QString & name()
Definition: eventtype.h:65
EventTypeMapping::count
int count()
Get number of used indexes.
Definition: eventtype.h:184
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:50 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
  • 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