F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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 <FpConfig.hpp>
17
18namespace 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 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() 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
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
C++-compatible configuration header for fprime configuration.
Class representing a CFDP checksum.
Definition Checksum.hpp:23
Checksum & operator=(const Checksum &checksum)
Assign checksum to this.
Definition Checksum.cpp:47
U32 getValue() const
Get the checksum value.
Definition Checksum.cpp:66
~Checksum()
Destroy a Checksum object.
Definition Checksum.cpp:41
bool operator!=(const Checksum &checksum) const
Compare checksum and this for inequality.
Definition Checksum.cpp:60
bool operator==(const Checksum &checksum) const
Compare checksum and this for equality.
Definition Checksum.cpp:54
Checksum()
Construct a fresh Checksum object.
Definition Checksum.cpp:23
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