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

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • view
  • structures
  • datatypes
topleveldatainformation.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Okteta Kasten Framework, made within the KDE community.
3  *
4  * Copyright 2010, 2011 Alex Richardson <alex.richardson@gmx.de>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) version 3, or any
10  * later version accepted by the membership of KDE e.V. (or its
11  * successor approved by the membership of KDE e.V.), which shall
12  * act as a proxy defined in Section 6 of version 3 of the license.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21  */
22 #ifndef TOPLEVELDATAINFORMATION_H_
23 #define TOPLEVELDATAINFORMATION_H_
24 
25 #include <QHash>
26 #include <QFileInfo>
27 #include <QSharedPointer>
28 #include <QQueue>
29 
30 #include <arraychangemetricslist.h>
31 #include "datainformationbase.h"
32 #include "../script/scripthandler.h"
33 
34 namespace Okteta
35 {
36 class AbstractByteArrayModel;
37 } // namespace Okteta
38 
39 class ScriptLogger;
40 class ScriptHandlerInfo;
41 class QScriptEngine;
42 class ScriptHandler;
43 class DataInformation;
44 class PointerDataInformation;
45 
46 class TopLevelDataInformation : public QObject, public DataInformationBase
47 {
48  Q_DISABLE_COPY(TopLevelDataInformation)
49  Q_OBJECT
50 public:
57  explicit TopLevelDataInformation(DataInformation* data, ScriptLogger* logger = 0,
58  QScriptEngine* engine = 0, const QFileInfo& structureFile = QFileInfo());
59  virtual ~TopLevelDataInformation();
60 
61  typedef QSharedPointer<TopLevelDataInformation> Ptr;
62  typedef QVector<Ptr> List;
63  static const quint64 INVALID_OFFSET;
64 
65 public:
66  void validate();
76  void read(Okteta::AbstractByteArrayModel* input, Okteta::Address address,
77  const Okteta::ArrayChangeMetricsList& changesList, bool forceRead);
78  QScriptEngine* scriptEngine() const;
79 
80  DataInformation* actualDataInformation() const;
81  void setActualDataInformation(DataInformation* newData);
82  bool isValid() const;
83  void lockPositionToOffset(Okteta::Address offset, const Okteta::AbstractByteArrayModel* model);
84  void unlockPosition(const Okteta::AbstractByteArrayModel* model);
85  bool isLockedFor(const Okteta::AbstractByteArrayModel* model) const;
86  quint64 lockPositionFor(const Okteta::AbstractByteArrayModel* model) const;
87  bool isLockedByDefault() const;
88  void setDefaultLockOffset(Okteta::Address offset);
89  int indexOf(const DataInformation* const data) const;
90  int index() const;
91  void setIndex(int newIndex);
92  ScriptHandler* scriptHandler() const;
93  ScriptLogger* logger() const;
94  void setChildDataChanged();
95  void enqueueReadData(PointerDataInformation* toRead);
96 
97  virtual bool isTopLevel() const;
98 
99  //only public so that DataInformation and subclasses can call them (TODO move)
100  void _childCountAboutToChange(DataInformation* sender, uint oldCount, uint newCount);
101  void _childCountChanged(DataInformation* sender, uint oldCount, uint newCount);
102 
103 private:
104  bool isReadingNecessary(Okteta::AbstractByteArrayModel* model, Okteta::Address address,
105  const Okteta::ArrayChangeMetricsList& changesList);
106 
107 public Q_SLOTS:
108  void resetValidationState();
109  void newModelActivated(Okteta::AbstractByteArrayModel* model);
110 private Q_SLOTS:
111  void removeByteArrayModelFromList(QObject* model);
112 Q_SIGNALS:
113  void dataChanged();
115  void childrenAboutToBeInserted(DataInformation* sender, uint startIndex, uint endIndex);
117  void childrenInserted(const DataInformation* sender, uint startIndex, uint endIndex);
119  void childrenAboutToBeRemoved(DataInformation* sender, uint startIndex, uint endIndex);
121  void childrenRemoved(const DataInformation* sender, uint startIndex, uint endIndex);
122 
123 private:
124  QScopedPointer<DataInformation> mData;
125  QScopedPointer<ScriptHandler> mScriptHandler;
126  QScopedPointer<ScriptLogger> mLogger;
127  QFileInfo mStructureFile;
132  QHash<const Okteta::AbstractByteArrayModel*, quint64> mLockedPositions;
133  int mIndex;
134  bool mValid :1;
135  bool mChildDataChanged :1;
136  quint64 mDefaultLockOffset;
137  quint64 mLastReadOffset;
138  Okteta::AbstractByteArrayModel* mLastModel;
139  QQueue<PointerDataInformation*> mDelayedRead;
140 
141  friend class LockToOffsetTest; //needs to call isReadingNecessary()
142 };
143 
144 inline DataInformation* TopLevelDataInformation::actualDataInformation() const
145 {
146  return mData.data();
147 }
148 
149 inline bool TopLevelDataInformation::isValid() const
150 {
151  return mValid;
152 }
153 
154 inline int TopLevelDataInformation::index() const
155 {
156  return mIndex;
157 }
158 
159 inline void TopLevelDataInformation::setIndex(int newIndex)
160 {
161  mIndex = newIndex;
162 }
163 
164 inline void TopLevelDataInformation::setChildDataChanged()
165 {
166  mChildDataChanged = true;
167 }
168 
169 inline bool TopLevelDataInformation::isTopLevel() const
170 {
171  return true;
172 }
173 
174 inline ScriptLogger* TopLevelDataInformation::logger() const
175 {
176  return mLogger.data();
177 }
178 
179 inline ScriptHandler* TopLevelDataInformation::scriptHandler() const
180 {
181  return mScriptHandler.data();
182 }
183 
184 inline void TopLevelDataInformation::_childCountAboutToChange(DataInformation* sender, uint oldCount, uint newCount)
185 {
186  if (newCount < oldCount) //newCount is smaller so oldCount is at least 1 -> no underflow
187  emit childrenAboutToBeRemoved(sender, newCount, oldCount - 1);
188  else if (newCount > oldCount) //newCount is larger so it is at least 1 -> no underflow
189  emit childrenAboutToBeInserted(sender, oldCount, newCount - 1);
190 }
191 
192 inline void TopLevelDataInformation::_childCountChanged(DataInformation* sender, uint oldCount, uint newCount)
193 {
194  if (newCount < oldCount) //newCount is smaller so oldCount is at least 1 -> no underflow
195  emit childrenRemoved(sender, newCount, oldCount - 1);
196  else if (newCount > oldCount) //newCount is larger so it is at least 1 -> no underflow
197  emit childrenInserted(sender, oldCount, newCount - 1);
198 }
199 
200 #endif /* TOPLEVELDATAINFORMATION_H_ */
DataInformation
Interface that must be implemented by all datatypes.
Definition: datainformation.h:67
TopLevelDataInformation::read
void read(Okteta::AbstractByteArrayModel *input, Okteta::Address address, const Okteta::ArrayChangeMetricsList &changesList, bool forceRead)
Reads the necessary data from input.
Definition: topleveldatainformation.cpp:81
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
TopLevelDataInformation::Ptr
QSharedPointer< TopLevelDataInformation > Ptr
Definition: topleveldatainformation.h:61
TopLevelDataInformation::_childCountAboutToChange
void _childCountAboutToChange(DataInformation *sender, uint oldCount, uint newCount)
Definition: topleveldatainformation.h:184
PointerDataInformation
Definition: pointerdatainformation.h:30
TopLevelDataInformation::_childCountChanged
void _childCountChanged(DataInformation *sender, uint oldCount, uint newCount)
Definition: topleveldatainformation.h:192
TopLevelDataInformation::childrenAboutToBeInserted
void childrenAboutToBeInserted(DataInformation *sender, uint startIndex, uint endIndex)
items are inserted before startIndex
TopLevelDataInformation::unlockPosition
void unlockPosition(const Okteta::AbstractByteArrayModel *model)
Definition: topleveldatainformation.cpp:198
TopLevelDataInformation::isTopLevel
virtual bool isTopLevel() const
Definition: topleveldatainformation.h:169
TopLevelDataInformation::childrenRemoved
void childrenRemoved(const DataInformation *sender, uint startIndex, uint endIndex)
items are inserted before startIndex
TopLevelDataInformation::dataChanged
void dataChanged()
QVector< Ptr >
QObject
TopLevelDataInformation::logger
ScriptLogger * logger() const
Definition: topleveldatainformation.h:174
TopLevelDataInformation::newModelActivated
void newModelActivated(Okteta::AbstractByteArrayModel *model)
Definition: topleveldatainformation.cpp:228
TopLevelDataInformation::setActualDataInformation
void setActualDataInformation(DataInformation *newData)
Definition: topleveldatainformation.cpp:261
TopLevelDataInformation::~TopLevelDataInformation
virtual ~TopLevelDataInformation()
Definition: topleveldatainformation.cpp:61
TopLevelDataInformation
Definition: topleveldatainformation.h:46
TopLevelDataInformation::isLockedByDefault
bool isLockedByDefault() const
Definition: topleveldatainformation.cpp:212
TopLevelDataInformation::resetValidationState
void resetValidationState()
Definition: topleveldatainformation.cpp:76
TopLevelDataInformation::enqueueReadData
void enqueueReadData(PointerDataInformation *toRead)
Definition: topleveldatainformation.cpp:115
ScriptHandler
Definition: scripthandler.h:39
TopLevelDataInformation::scriptEngine
QScriptEngine * scriptEngine() const
Definition: topleveldatainformation.cpp:71
TopLevelDataInformation::childrenAboutToBeRemoved
void childrenAboutToBeRemoved(DataInformation *sender, uint startIndex, uint endIndex)
items are removed before startIndex
ScriptLogger
NOT THREAD SAFE!
Definition: scriptlogger.h:35
Okteta::ArrayChangeMetricsList
Definition: arraychangemetricslist.h:36
TopLevelDataInformation::isLockedFor
bool isLockedFor(const Okteta::AbstractByteArrayModel *model) const
Definition: topleveldatainformation.cpp:242
TopLevelDataInformation::isValid
bool isValid() const
Definition: topleveldatainformation.h:149
TopLevelDataInformation::indexOf
int indexOf(const DataInformation *const data) const
Definition: topleveldatainformation.cpp:254
datainformationbase.h
TopLevelDataInformation::childrenInserted
void childrenInserted(const DataInformation *sender, uint startIndex, uint endIndex)
items are inserted before startIndex
arraychangemetricslist.h
TopLevelDataInformation::setDefaultLockOffset
void setDefaultLockOffset(Okteta::Address offset)
Definition: topleveldatainformation.cpp:217
TopLevelDataInformation::List
QVector< Ptr > List
Definition: topleveldatainformation.h:62
ScriptHandlerInfo
Definition: scripthandlerinfo.h:39
TopLevelDataInformation::scriptHandler
ScriptHandler * scriptHandler() const
Definition: topleveldatainformation.h:179
TopLevelDataInformation::index
int index() const
Definition: topleveldatainformation.h:154
TopLevelDataInformation::actualDataInformation
DataInformation * actualDataInformation() const
Definition: topleveldatainformation.h:144
DataInformationBase
Definition: datainformationbase.h:44
TopLevelDataInformation::setChildDataChanged
void setChildDataChanged()
Definition: topleveldatainformation.h:164
TopLevelDataInformation::LockToOffsetTest
friend class LockToOffsetTest
Definition: topleveldatainformation.h:141
TopLevelDataInformation::lockPositionFor
quint64 lockPositionFor(const Okteta::AbstractByteArrayModel *model) const
Definition: topleveldatainformation.cpp:248
TopLevelDataInformation::lockPositionToOffset
void lockPositionToOffset(Okteta::Address offset, const Okteta::AbstractByteArrayModel *model)
Definition: topleveldatainformation.cpp:184
TopLevelDataInformation::validate
void validate()
Definition: topleveldatainformation.cpp:65
TopLevelDataInformation::INVALID_OFFSET
static const quint64 INVALID_OFFSET
Definition: topleveldatainformation.h:63
TopLevelDataInformation::TopLevelDataInformation
TopLevelDataInformation(DataInformation *data, ScriptLogger *logger=0, QScriptEngine *engine=0, const QFileInfo &structureFile=QFileInfo())
create a new TopLevelDataInformation wrapping data
Definition: topleveldatainformation.cpp:43
TopLevelDataInformation::setIndex
void setIndex(int newIndex)
Definition: topleveldatainformation.h:159
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

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