• 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
  • primitive
  • bitfield
abstractbitfielddatainformation.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 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 ABSTRACTBITFIELDDATAINFORMATION_H_
23 #define ABSTRACTBITFIELDDATAINFORMATION_H_
24 
25 #include "../primitivedatainformation.h"
26 #include "../../../allprimitivetypes.h"
27 
28 class AbstractBitfieldDataInformation : public PrimitiveDataInformation
29 {
30 public:
31  AbstractBitfieldDataInformation(const QString& name, BitCount32 width, DataInformation* parent = 0);
32  virtual ~AbstractBitfieldDataInformation();
33 
34  BitCount32 width() const;
35  void setWidth(BitCount32 newWidth);
36  virtual BitCount32 size() const;
37  quint64 mask() const;
38  virtual AllPrimitiveTypes value() const;
39  virtual void setValue(AllPrimitiveTypes newVal);
40  virtual PrimitiveDataType type() const;
41  virtual QString sizeString() const;
42  virtual bool isBitfield() const;
43  virtual Qt::ItemFlags flags(int column, bool fileLoaded) const;
44  virtual qint64 readData(Okteta::AbstractByteArrayModel *input,
45  Okteta::Address address, BitCount64 bitsRemaining, quint8* bitOffset);
46  bool setData(const QVariant& valueVariant, Okteta::AbstractByteArrayModel *out,
47  Okteta::Address address, BitCount64 bitsRemaining, quint8 bitOffset);
48 
49 protected:
50  AbstractBitfieldDataInformation(const AbstractBitfieldDataInformation& d);
51  virtual AllPrimitiveTypes fromVariant(const QVariant& variant, bool* ok) const;
52 private:
53  virtual QScriptClass* scriptClass(ScriptHandlerInfo* handlerInfo) const;
54 protected:
55  AllPrimitiveTypes mValue;
56  quint8 mWidth; //cannot be more than 64 since a quint64 is used for storage
57 };
58 
59 inline Qt::ItemFlags AbstractBitfieldDataInformation::flags(int column, bool fileLoaded) const
60 {
61  if (column == (int) DataInformation::ColumnValue && fileLoaded)
62  return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
63  else
64  return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
65 }
66 
67 inline quint64 AbstractBitfieldDataInformation::mask() const
68 {
69  /* same as:
70  *
71  * quint64 ret = 0;
72  * for (int i = 0; i < width(); i++)
73  * ret |= 1 << i;
74  * return ret;
75  */
76  if (Q_UNLIKELY(mWidth == 64u))
77  return ~quint64(0);
78  return (quint64(1) << mWidth) - 1;
79 }
80 
81 inline BitCount32 AbstractBitfieldDataInformation::size() const
82 {
83  return mWidth;
84 }
85 
86 inline BitCount32 AbstractBitfieldDataInformation::width() const
87 {
88  return mWidth;
89 }
90 
91 inline void AbstractBitfieldDataInformation::setWidth(BitCount32 newWidth)
92 {
93  Q_ASSERT(newWidth > 0 && newWidth <= 64);
94  mWidth = qMin(newWidth, BitCount32(64u)); //maximum width is 64 bits
95 }
96 
97 inline bool AbstractBitfieldDataInformation::isBitfield() const
98 {
99  return true;
100 }
101 
102 #endif /* ABSTRACTBITFIELDDATAINFORMATION_H_ */
DataInformation
Interface that must be implemented by all datatypes.
Definition: datainformation.h:67
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
DataInformation::name
QString name() const
Definition: datainformation.h:258
AbstractBitfieldDataInformation::sizeString
virtual QString sizeString() const
needs to be virtual for bitfields
Definition: abstractbitfielddatainformation.cpp:31
AbstractBitfieldDataInformation::width
BitCount32 width() const
Definition: abstractbitfielddatainformation.h:86
QScriptClass
AbstractBitfieldDataInformation::readData
virtual qint64 readData(Okteta::AbstractByteArrayModel *input, Okteta::Address address, BitCount64 bitsRemaining, quint8 *bitOffset)
Reads the necessary data from input and returns the number of bytes read.
Definition: abstractbitfielddatainformation.cpp:68
BitCount64
quint64 BitCount64
Definition: datainformationbase.h:42
AbstractBitfieldDataInformation::mWidth
quint8 mWidth
Definition: abstractbitfielddatainformation.h:56
AbstractBitfieldDataInformation::fromVariant
virtual AllPrimitiveTypes fromVariant(const QVariant &variant, bool *ok) const
Definition: abstractbitfielddatainformation.cpp:110
BitCount32
quint32 BitCount32
Definition: datainformationbase.h:37
DataInformation::ColumnValue
Definition: datainformation.h:84
AbstractBitfieldDataInformation::value
virtual AllPrimitiveTypes value() const
Definition: abstractbitfielddatainformation.cpp:36
AbstractBitfieldDataInformation::~AbstractBitfieldDataInformation
virtual ~AbstractBitfieldDataInformation()
Definition: abstractbitfielddatainformation.cpp:59
PrimitiveDataType
Definition: primitivedatatype.h:54
AbstractBitfieldDataInformation::size
virtual BitCount32 size() const
the size in bits of this element
Definition: abstractbitfielddatainformation.h:81
AbstractBitfieldDataInformation::flags
virtual Qt::ItemFlags flags(int column, bool fileLoaded) const
Definition: abstractbitfielddatainformation.h:59
AbstractBitfieldDataInformation::AbstractBitfieldDataInformation
AbstractBitfieldDataInformation(const QString &name, BitCount32 width, DataInformation *parent=0)
Definition: abstractbitfielddatainformation.cpp:52
ScriptHandlerInfo
Definition: scripthandlerinfo.h:39
DataInformation::parent
DataInformationBase * parent() const
Definition: datainformation.h:309
AbstractBitfieldDataInformation::type
virtual PrimitiveDataType type() const
Definition: abstractbitfielddatainformation.cpp:47
AbstractBitfieldDataInformation::mask
quint64 mask() const
Definition: abstractbitfielddatainformation.h:67
AbstractBitfieldDataInformation::isBitfield
virtual bool isBitfield() const
Definition: abstractbitfielddatainformation.h:97
AllPrimitiveTypes
This union holds the value of one primitive datatype.
Definition: allprimitivetypes.h:70
AbstractBitfieldDataInformation::mValue
AllPrimitiveTypes mValue
Definition: abstractbitfielddatainformation.h:55
AbstractBitfieldDataInformation::setData
bool setData(const QVariant &valueVariant, Okteta::AbstractByteArrayModel *out, Okteta::Address address, BitCount64 bitsRemaining, quint8 bitOffset)
Writes the current data contained in this object to out.
Definition: abstractbitfielddatainformation.cpp:93
AbstractBitfieldDataInformation::setWidth
void setWidth(BitCount32 newWidth)
Definition: abstractbitfielddatainformation.h:91
AbstractBitfieldDataInformation
Definition: abstractbitfielddatainformation.h:28
PrimitiveDataInformation
A base class for all primitive data elements (e.g.
Definition: primitivedatainformation.h:34
AbstractBitfieldDataInformation::setValue
virtual void setValue(AllPrimitiveTypes newVal)
Definition: abstractbitfielddatainformation.cpp:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:06 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