• 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
  • template
template_bytearraychecksumalgorithm.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  Public domain.
7 */
8 
12 #include "template_bytearraychecksumalgorithm.h"
14 
15 // Okteta core
16 #include <abstractbytearraymodel.h>
17 // KDE
18 #include <KLocale>
19 
20 
21 Template_ByteArrayChecksumAlgorithm::Template_ByteArrayChecksumAlgorithm()
22  : AbstractByteArrayChecksumAlgorithm(
25  i18nc("name of the checksum algorithm", "Template") )
27 {}
28 
29 AbstractByteArrayChecksumParameterSet* Template_ByteArrayChecksumAlgorithm::parameterSet() { return &mParameterSet; }
30 
31 bool Template_ByteArrayChecksumAlgorithm::calculateChecksum( QString* result,
32  const Okteta::AbstractByteArrayModel* model, const Okteta::AddressRange& range ) const
33 {
34  bool success = true;
35 
39  const int mask = ( 1 << mParameterSet.bitNumber() );
40 
41  int sum = 0;
42 
43  Okteta::Address nextBlockEnd = range.start() + CalculatedByteCountSignalLimit;
44  for( Okteta::Address i = range.start(); i<=range.end(); ++i )
45  {
46  sum ^= ( model->byte(i) & mask );
47 
48  if( i >= nextBlockEnd )
49  {
50  nextBlockEnd += CalculatedByteCountSignalLimit;
51  emit calculatedBytes( range.localIndex(i)+1 );
52  }
53  }
54 
55  *result = QString::fromLatin1("%1").arg( sum );
57 
58  return success;
59 }
60 
61 Template_ByteArrayChecksumAlgorithm::~Template_ByteArrayChecksumAlgorithm() {}
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
template_bytearraychecksumalgorithm.h
KDE::NumberRange< Address, Size >
KDE::Range::start
T start() const
Definition: range.h:86
AbstractByteArrayChecksumAlgorithm::CalculatedByteCountSignalLimit
static const int CalculatedByteCountSignalLimit
Definition: abstractbytearraychecksumalgorithm.h:43
Template_ByteArrayChecksumAlgorithm::mParameterSet
Template_ByteArrayChecksumParameterSet mParameterSet
Definition: template_bytearraychecksumalgorithm.h:44
Template_ByteArrayChecksumAlgorithm::~Template_ByteArrayChecksumAlgorithm
virtual ~Template_ByteArrayChecksumAlgorithm()
Definition: template_bytearraychecksumalgorithm.cpp:61
KDE::NumberRange::localIndex
N localIndex(N index) const
Definition: numberrange.h:199
KDE::Range::end
T end() const
Definition: range.h:88
Template_ByteArrayChecksumAlgorithm::calculateChecksum
virtual bool calculateChecksum(QString *result, const Okteta::AbstractByteArrayModel *model, const Okteta::AddressRange &range) const
Definition: template_bytearraychecksumalgorithm.cpp:31
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...
Template_ByteArrayChecksumAlgorithm::parameterSet
virtual AbstractByteArrayChecksumParameterSet * parameterSet()
used by the editor to get write access to the parameters
Definition: template_bytearraychecksumalgorithm.cpp:29
AbstractByteArrayChecksumParameterSet
Definition: abstractbytearraychecksumparameterset.h:27
Template_ByteArrayChecksumParameterSet::bitNumber
int bitNumber() const
Definition: template_bytearraychecksumparameterset.cpp:38
Template_ByteArrayChecksumAlgorithm::Template_ByteArrayChecksumAlgorithm
Template_ByteArrayChecksumAlgorithm()
Definition: template_bytearraychecksumalgorithm.cpp:21
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: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