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

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
topducontextdynamicdata.h
Go to the documentation of this file.
1 /* This is part of KDevelop
2  Copyright 2008 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library 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  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. 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 KDEVPLATFORM_TOPDUCONTEXTDYNAMICDATA_H
20 #define KDEVPLATFORM_TOPDUCONTEXTDYNAMICDATA_H
21 
22 #include <QVector>
23 #include <QByteArray>
24 #include "problem.h"
25 
26 class QFile;
27 
28 namespace KDevelop {
29 class TopDUContext;
30 class DUContext;
31 class Declaration;
32 class IndexedString;
33 class IndexedDUContext;
34 class DUChainBaseData;
35 
37 class TopDUContextDynamicData
38 {
39 public:
40  explicit TopDUContextDynamicData(TopDUContext* topContext);
41  ~TopDUContextDynamicData();
42 
43  void clear();
44 
51  uint allocateDeclarationIndex(Declaration* decl, bool temporary);
52 
53  Declaration* declarationForIndex(uint index) const;
54 
55  bool isDeclarationForIndexLoaded(uint index) const;
56 
57  void clearDeclarationIndex(Declaration* decl);
58 
65  uint allocateContextIndex(DUContext* ctx, bool temporary);
66 
67  DUContext* contextForIndex(uint index) const;
68 
69  bool isContextForIndexLoaded(uint index) const;
70 
71  void clearContextIndex(DUContext* ctx);
72 
77  uint allocateProblemIndex(const ProblemPointer& problem);
78  ProblemPointer problemForIndex(uint index) const;
79  void clearProblems();
80 
82  void store();
83 
85  void deleteOnDisk();
86 
88  bool isOnDisk() const;
89 
92  static TopDUContext* load(uint topContextIndex);
93 
95  static IndexedString loadUrl(uint topContextIndex);
96 
97  static bool fileExists(uint topContextIndex);
98 
100  static QList<IndexedDUContext> loadImporters(uint topContextIndex);
101 
102  static QList<IndexedDUContext> loadImports(uint topContextIndex);
103 
104  bool isTemporaryContextIndex(uint index) const;
105  bool isTemporaryDeclarationIndex(uint index) const;
106 
107  bool m_deleting;
108 
109  struct ItemDataInfo
110  {
111  uint dataOffset;
112  uint parentContext;
113  };
114 
115  struct ArrayWithPosition
116  {
117  QByteArray array;
118  uint position;
119  };
120 
121 private:
122  bool hasChanged() const;
123 
124  void unmap();
125  //Converts away from an mmap opened file to a data array
126 
127  QString filePath() const;
128 
129  void loadData() const;
130 
131  const char* pointerInData(uint offset) const;
132 
133  ItemDataInfo writeDataInfo(const ItemDataInfo& info, const DUChainBaseData* data, uint& totalDataOffset);
134 
135  TopDUContext* m_topContext;
136 
137  template <class Item>
138  struct DUChainItemStorage
139  {
140  explicit DUChainItemStorage(TopDUContextDynamicData* data);
141  ~DUChainItemStorage();
142 
143  void clearItems();
144  bool itemsHaveChanged() const;
145 
146  void storeData(uint& currentDataOffset, const QVector<ArrayWithPosition>& oldData);
147  Item itemForIndex(uint index) const;
148 
149  void clearItemIndex(const Item& item, const uint index);
150 
151  uint allocateItemIndex(const Item& item, const bool temporary);
152 
153  void deleteOnDisk();
154  bool isItemForIndexLoaded(uint index) const;
155 
156  void loadData(QFile* file) const;
157  void writeData(QFile* file);
158 
159  //May contain zero items if they were deleted
160  mutable QVector<Item> items;
161  mutable QVector<ItemDataInfo> offsets;
162  QVector<Item> temporaryItems;
163  TopDUContextDynamicData* const data;
164  };
165 
166  DUChainItemStorage<DUContext*> m_contexts;
167  DUChainItemStorage<Declaration*> m_declarations;
168  DUChainItemStorage<ProblemPointer> m_problems;
169 
170  //For temporary declarations that will not be stored to disk, like template instantiations
171 
172  mutable QVector<ArrayWithPosition> m_data;
173  mutable QVector<ArrayWithPosition> m_topContextData;
174  bool m_onDisk;
175  mutable bool m_dataLoaded;
176 
177  mutable QFile* m_mappedFile;
178  mutable uchar* m_mappedData;
179  mutable size_t m_mappedDataSize;
180  mutable bool m_itemRetrievalForbidden;
181 };
182 }
183 
184 Q_DECLARE_TYPEINFO(KDevelop::TopDUContextDynamicData::ItemDataInfo, Q_PRIMITIVE_TYPE);
185 Q_DECLARE_TYPEINFO(KDevelop::TopDUContextDynamicData::ArrayWithPosition, Q_MOVABLE_TYPE);
186 
187 #endif
KDevelop::TopDUContextDynamicData::ArrayWithPosition::position
uint position
Definition: topducontextdynamicdata.h:118
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KDevelop::TopDUContextDynamicData::ItemDataInfo, Q_PRIMITIVE_TYPE)
KDevelop::TopDUContextDynamicData::isTemporaryContextIndex
bool isTemporaryContextIndex(uint index) const
Definition: topducontextdynamicdata.cpp:826
KDevelop::TopDUContextDynamicData::isContextForIndexLoaded
bool isContextForIndexLoaded(uint index) const
Definition: topducontextdynamicdata.cpp:821
KDevelop::TopDUContextDynamicData::load
static TopDUContext * load(uint topContextIndex)
Loads the top-context from disk, or returns zero on failure.
Definition: topducontextdynamicdata.cpp:594
KDevelop::TopDUContextDynamicData::contextForIndex
DUContext * contextForIndex(uint index) const
Definition: topducontextdynamicdata.cpp:836
KDevelop::TopDUContextDynamicData::~TopDUContextDynamicData
~TopDUContextDynamicData()
Definition: topducontextdynamicdata.cpp:495
KDevelop::TopDUContextDynamicData::ItemDataInfo
Flag used during destruction.
Definition: topducontextdynamicdata.h:109
KDevelop::TopDUContextDynamicData::clearProblems
void clearProblems()
Definition: topducontextdynamicdata.cpp:874
KDevelop::TopDUContextDynamicData::ItemDataInfo::parentContext
uint parentContext
Offset of the data.
Definition: topducontextdynamicdata.h:112
QList
KDevelop::TopDUContextDynamicData::ItemDataInfo::dataOffset
uint dataOffset
Definition: topducontextdynamicdata.h:111
KDevelop::TopDUContextDynamicData::allocateDeclarationIndex
uint allocateDeclarationIndex(Declaration *decl, bool temporary)
Allocates an index for the given declaration in this top-context.
Definition: topducontextdynamicdata.cpp:801
KDevelop::TopDUContextDynamicData::declarationForIndex
Declaration * declarationForIndex(uint index) const
Definition: topducontextdynamicdata.cpp:848
KDevelop::Declaration
Represents a single declaration in a definition-use chain.
Definition: declaration.h:51
KDevelop::TopDUContextDynamicData::ArrayWithPosition
Definition: topducontextdynamicdata.h:115
problem.h
KDevelop::TopDUContextDynamicData::loadImports
static QList< IndexedDUContext > loadImports(uint topContextIndex)
Definition: topducontextdynamicdata.cpp:524
QExplicitlySharedDataPointer
Definition: topducontext.h:28
KDevelop::TopDUContextDynamicData
This class contains dynamic data of a top-context, and also the repository that contains all the data...
Definition: topducontextdynamicdata.h:37
KDevelop::TopDUContextDynamicData::allocateContextIndex
uint allocateContextIndex(DUContext *ctx, bool temporary)
Allocates an index for the given context in this top-context.
Definition: topducontextdynamicdata.cpp:806
KDevelop::TopDUContextDynamicData::TopDUContextDynamicData
TopDUContextDynamicData(TopDUContext *topContext)
Definition: topducontextdynamicdata.cpp:473
QString
KDevelop::TopDUContextDynamicData::clearDeclarationIndex
void clearDeclarationIndex(Declaration *decl)
Definition: topducontextdynamicdata.cpp:864
KDevelop::TopDUContext
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
KDevelop::TopDUContextDynamicData::isDeclarationForIndexLoaded
bool isDeclarationForIndexLoaded(uint index) const
Definition: topducontextdynamicdata.cpp:816
KDevelop::TopDUContextDynamicData::loadUrl
static IndexedString loadUrl(uint topContextIndex)
Loads only the url out of the data stored on disk for the top-context.
Definition: topducontextdynamicdata.cpp:535
KDevelop::TopDUContextDynamicData::clearContextIndex
void clearContextIndex(DUContext *ctx)
Definition: topducontextdynamicdata.cpp:869
KDevelop::TopDUContextDynamicData::allocateProblemIndex
uint allocateProblemIndex(const ProblemPointer &problem)
Allocates an index for the given problem in this top-context.
Definition: topducontextdynamicdata.cpp:811
KDevelop::TopDUContextDynamicData::isTemporaryDeclarationIndex
bool isTemporaryDeclarationIndex(uint index) const
Definition: topducontextdynamicdata.cpp:831
KDevelop::TopDUContextDynamicData::problemForIndex
ProblemPointer problemForIndex(uint index) const
Definition: topducontextdynamicdata.cpp:856
KDevelop::TopDUContextDynamicData::fileExists
static bool fileExists(uint topContextIndex)
Definition: topducontextdynamicdata.cpp:508
KDevelop::TopDUContextDynamicData::loadImporters
static QList< IndexedDUContext > loadImporters(uint topContextIndex)
Loads only the list of importers out of the data stored on disk for the top-context.
Definition: topducontextdynamicdata.cpp:513
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::DUContext
A single context in source code, represented as a node in a directed acyclic graph.
Definition: ducontext.h:72
KDevelop::TopDUContextDynamicData::isOnDisk
bool isOnDisk() const
Whether this top-context is on disk(Either has been loaded, or has been stored)
Definition: topducontextdynamicdata.cpp:629
QVector
KDevelop::TopDUContextDynamicData::clear
void clear()
Definition: topducontextdynamicdata.cpp:488
KDevelop::TopDUContextDynamicData::m_deleting
bool m_deleting
Definition: topducontextdynamicdata.h:107
QFile
KDevelop::DUChainBaseData
Definition: duchainbase.h:59
KDevelop::TopDUContextDynamicData::store
void store()
Stores this top-context to disk.
Definition: topducontextdynamicdata.cpp:669
QByteArray
KDevelop::TopDUContextDynamicData::ArrayWithPosition::array
QByteArray array
Definition: topducontextdynamicdata.h:117
KDevelop::TopDUContextDynamicData::deleteOnDisk
void deleteOnDisk()
Stores all remnants of this top-context that are on disk. The top-context will be fully dynamic after...
Definition: topducontextdynamicdata.cpp:634
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 9 2021 23:29:59 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

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