F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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/FPrimeBasicTypes.hpp>
17 
18 namespace CFDP {
19 
53 class Checksum {
54  public:
55  // ----------------------------------------------------------------------
56  // Types
57  // ----------------------------------------------------------------------
58 
59  public:
60  // ----------------------------------------------------------------------
61  // Construction and destruction
62  // ----------------------------------------------------------------------
63 
65  Checksum();
66 
68  Checksum(const U32 value);
69 
71  Checksum(const Checksum& original);
72 
74  ~Checksum();
75 
76  public:
77  // ----------------------------------------------------------------------
78  // Public instance methods
79  // ----------------------------------------------------------------------
80 
82  Checksum& operator=(const Checksum& checksum);
83 
85  bool operator==(const Checksum& checksum) const;
86 
88  bool operator!=(const Checksum& checksum) const;
89 
97  void update(const U8* const data,
98  const U32 offset,
99  const U32 length
100  );
101 
103  U32 getValue() const;
104 
105  private:
106  // ----------------------------------------------------------------------
107  // Private instance methods
108  // ----------------------------------------------------------------------
109 
111  void addWordAligned(const U8* const word
112  );
113 
115  void addWordUnaligned(const U8* const word,
116  const U8 position,
117  const U8 length
118  );
119 
121  void addByteAtOffset(const U8 byte,
122  const U8 offset
123  );
124 
125  private:
126  // ----------------------------------------------------------------------
127  // Private member variables
128  // ----------------------------------------------------------------------
129 
131  U32 m_value;
132 };
133 
134 } // namespace CFDP
135 
136 #endif
Checksum & operator=(const Checksum &checksum)
Assign checksum to this.
Definition: Checksum.cpp:32
Checksum()
Construct a fresh Checksum object.
Definition: Checksum.cpp:22
bool operator!=(const Checksum &checksum) const
Compare checksum and this for inequality.
Definition: Checksum.cpp:41
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol.
Definition: Checksum.hpp:53
~Checksum()
Destroy a Checksum object.
Definition: Checksum.cpp:30
void update(const U8 *const data, const U32 offset, const U32 length)
Definition: Checksum.cpp:49
U32 getValue() const
Get the checksum value.
Definition: Checksum.cpp:45
bool operator==(const Checksum &checksum) const
Compare checksum and this for equality.
Definition: Checksum.cpp:37
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53