• 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
  • libbytearraychecksum
  • algorithm
modsum8bytearraychecksumalgorithm.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
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 
23 #include "modsum8bytearraychecksumalgorithm.h"
24 
25 // Okteta core
26 #include <abstractbytearraymodel.h>
27 // KDE
28 #include <KLocale>
29 // Qt
30 #include <QtCore/QtGlobal>
31 
32 
33 
34 ModSum8ByteArrayChecksumAlgorithm::ModSum8ByteArrayChecksumAlgorithm()
35  : AbstractByteArrayChecksumAlgorithm(
36  i18nc("name of the checksum algorithm", "Modular sum 8-bit") )
37 {}
38 
39 AbstractByteArrayChecksumParameterSet* ModSum8ByteArrayChecksumAlgorithm::parameterSet() { return &mParameterSet; }
40 
41 bool ModSum8ByteArrayChecksumAlgorithm::calculateChecksum( QString* result,
42  const Okteta::AbstractByteArrayModel* model, const Okteta::AddressRange& range ) const
43 {
44  quint8 modSum = 0x00;
45  Okteta::Address nextBlockEnd = range.start() + CalculatedByteCountSignalLimit;
46  for( Okteta::Address i = range.start(); i<=range.end(); ++i )
47  {
48  modSum += (quint8)( model->byte(i) );
49 #if 0
50  const uchar value = (crcBits & 0xFF) + model->datum( i );
51  crcBits >>= 8;
52  crcBits ^= lookupTable[value];
53 #endif
54  if( i >= nextBlockEnd )
55  {
56  nextBlockEnd += CalculatedByteCountSignalLimit;
57  emit calculatedBytes( range.localIndex(i)+1 );
58  }
59  }
60  modSum = ~modSum + 1;
61 
62  *result = QString::fromLatin1("%1").arg( modSum, 2, 16, QChar::fromLatin1('0') );
63  return true;
64 }
65 
66 ModSum8ByteArrayChecksumAlgorithm::~ModSum8ByteArrayChecksumAlgorithm() {}
ModSum8ByteArrayChecksumAlgorithm::~ModSum8ByteArrayChecksumAlgorithm
virtual ~ModSum8ByteArrayChecksumAlgorithm()
Definition: modsum8bytearraychecksumalgorithm.cpp:66
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
abstractbytearraymodel.h
AbstractByteArrayChecksumAlgorithm
Definition: abstractbytearraychecksumalgorithm.h:38
ModSum8ByteArrayChecksumAlgorithm::mParameterSet
NoByteArrayChecksumParameterSet mParameterSet
Definition: modsum8bytearraychecksumalgorithm.h:43
KDE::NumberRange< Address, Size >
KDE::Range::start
T start() const
Definition: range.h:86
AbstractByteArrayChecksumAlgorithm::CalculatedByteCountSignalLimit
static const int CalculatedByteCountSignalLimit
Definition: abstractbytearraychecksumalgorithm.h:43
ModSum8ByteArrayChecksumAlgorithm::parameterSet
virtual AbstractByteArrayChecksumParameterSet * parameterSet()
used by the editor to get write access to the parameters
Definition: modsum8bytearraychecksumalgorithm.cpp:39
KDE::NumberRange::localIndex
N localIndex(N index) const
Definition: numberrange.h:199
KDE::Range::end
T end() const
Definition: range.h:88
Okteta::AbstractByteArrayModel::byte
virtual Byte byte(Address offset) const =0
locates working range The idea behind is to tell buffer which range will be requested in the followin...
ModSum8ByteArrayChecksumAlgorithm::calculateChecksum
virtual bool calculateChecksum(QString *result, const Okteta::AbstractByteArrayModel *model, const Okteta::AddressRange &range) const
Definition: modsum8bytearraychecksumalgorithm.cpp:41
ModSum8ByteArrayChecksumAlgorithm::ModSum8ByteArrayChecksumAlgorithm
ModSum8ByteArrayChecksumAlgorithm()
Definition: modsum8bytearraychecksumalgorithm.cpp:34
modsum8bytearraychecksumalgorithm.h
AbstractByteArrayChecksumParameterSet
Definition: abstractbytearraychecksumparameterset.h:27
AbstractByteArrayChecksumAlgorithm::calculatedBytes
void calculatedBytes(int bytes) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 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