F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Checksum.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title CFDP/Checksum/Checksum.hpp
3 // \author bocchino
4 // \brief hpp file for CFDP checksum class
5 //
6 // \copyright
7 // Copyright 2009-2016, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef CFDP_Checksum_HPP
14 #define CFDP_Checksum_HPP
15 
16 #include "Fw/Types/BasicTypes.hpp"
17 
18 namespace CFDP {
19 
23  class Checksum {
24 
25  public:
26 
27  // ----------------------------------------------------------------------
28  // Types
29  // ----------------------------------------------------------------------
30 
31  public:
32 
33  // ----------------------------------------------------------------------
34  // Construction and destruction
35  // ----------------------------------------------------------------------
36 
38  Checksum();
39 
41  Checksum(const U32 value);
42 
44  Checksum(const Checksum &original);
45 
47  ~Checksum();
48 
49  public:
50 
51  // ----------------------------------------------------------------------
52  // Public instance methods
53  // ----------------------------------------------------------------------
54 
56  const Checksum& operator=(const Checksum& checksum);
57 
59  bool operator==(const Checksum& checksum) const;
60 
62  bool operator!=(const Checksum& checksum) const;
63 
65  void update(
66  const U8 *const data,
67  const U32 offset,
68  const U32 length
69  );
70 
72  U32 getValue(void) const;
73 
74  PRIVATE:
75 
76  // ----------------------------------------------------------------------
77  // Private instance methods
78  // ----------------------------------------------------------------------
79 
81  void addWordAligned(
82  const U8 *const word
83  );
84 
86  void addWordUnaligned(
87  const U8 *const word,
88  const U8 position,
89  const U8 length
90  );
91 
93  void addByteAtOffset(
94  const U8 byte,
95  const U8 offset
96  );
97 
98  PRIVATE:
99 
100  // ----------------------------------------------------------------------
101  // Private member variables
102  // ----------------------------------------------------------------------
103 
105  U32 value;
106 
107  };
108 
109 }
110 
111 #endif
CFDP::Checksum::operator!=
bool operator!=(const Checksum &checksum) const
Compare checksum and this for inequality.
Definition: Checksum.cpp:60
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
CFDP::Checksum::update
void update(const U8 *const data, const U32 offset, const U32 length)
Update the checksum value by accumulating the words in the data.
Definition: Checksum.cpp:72
CFDP::Checksum::getValue
U32 getValue(void) const
Get the checksum value.
Definition: Checksum.cpp:66
CFDP::Checksum::Checksum
Checksum()
Construct a fresh Checksum object.
Definition: Checksum.cpp:23
CFDP::Checksum::operator=
const Checksum & operator=(const Checksum &checksum)
Assign checksum to this.
Definition: Checksum.cpp:47
CFDP::Checksum::operator==
bool operator==(const Checksum &checksum) const
Compare checksum and this for equality.
Definition: Checksum.cpp:54
CFDP
Definition: Checksum.cpp:20
CFDP::Checksum::~Checksum
~Checksum()
Destroy a Checksum object.
Definition: Checksum.cpp:41
CFDP::Checksum
Class representing a CFDP checksum.
Definition: Checksum.hpp:23
BasicTypes.hpp
Declares ISF basic types.