GM6000 Digital Heater Controller Branch: main
SDX-1330
CrcChunk.h
Go to the documentation of this file.
1#ifndef Cpl_Persistent_Crc_Chunk_h_
2#define Cpl_Persistent_Crc_Chunk_h_
3/*-----------------------------------------------------------------------------
4* This file is part of the Colony.Core Project. The Colony.Core Project is an
5* open source project with a BSD type of licensing agreement. See the license
6* agreement (license.txt) in the top/ directory or on the Internet at
7* http://integerfox.com/colony.core/license.txt
8*
9* Copyright (c) 2014-2022 John T. Taylor
10*
11* Redistributions of the source code must retain the above copyright notice.
12*----------------------------------------------------------------------------*/
13/** @file */
14
15
18#include <stdint.h>
19
20///
21namespace Cpl {
22///
23namespace Persistent {
24
25
26/** This concrete class implements the Chunk interface by using a 32Bit CRC
27 for ensuring data integrity.
28 */
29class CrcChunk: public Chunk
30{
31public:
32 /// Start of data (aka overhead length)
33 constexpr static size_t FRAME_OFFSET_DATA = sizeof( size_t );
34
35 /// The size of the CRC
36 constexpr static size_t CRC_SIZE = sizeof( uint32_t );
37
38 /// Total overhead size
39 constexpr static size_t FRAME_OVERHEAD = FRAME_OFFSET_DATA + CRC_SIZE;
40
41public:
42 /// Constructor
44
45public:
46 /// See Cpl::Persistent::Chunk
47 void start( Cpl::Dm::MailboxServer& myMbox ) noexcept;
48
49 /// See Cpl::Persistent::Chunk
50 void stop() noexcept;
51
52 /// See Cpl::Persistent::Chunk
53 bool loadData( Payload& dstHandler, size_t index=0 ) noexcept;
54
55 /// See Cpl::Persistent::Chunk
56 bool updateData( Payload& srcHandler, size_t index=0, bool invalidate=false ) noexcept;
57
58
59 /// See Cpl::Persistent::Chunk
60 size_t getMetadataLength() const noexcept;
61
62protected:
63 /// Helper method. Encapsulates pushing data to the record
64 virtual bool pushToRecord( Payload& dstHandler );
65
66 /// Helper method. Encapsulates retrieving data from the record. Returns the length of the data
67 virtual size_t pullFromRecord( Payload& srcHandler );
68
69 /// Helper method. Encapsulates actions that occur when there is NO VALID data
70 virtual void reset();
71
72
73protected:
74 /// Region/Media
76
77 /// Data Length for the record
78 size_t m_dataLen;
79};
80
81
82}; // end namespaces
83};
84#endif // end header latch
This class extends the Cpl::Dm::EventLoop and Cpl::Itc:Mailbox classes to support the asynchronous ch...
Definition MailboxServer.h:43
This abstract class defines the interface for a Chunk.
Definition Chunk.h:30
This concrete class implements the Chunk interface by using a 32Bit CRC for ensuring data integrity.
Definition CrcChunk.h:30
void stop() noexcept
See Cpl::Persistent::Chunk.
virtual size_t pullFromRecord(Payload &srcHandler)
Helper method. Encapsulates retrieving data from the record. Returns the length of the data.
virtual void reset()
Helper method. Encapsulates actions that occur when there is NO VALID data.
size_t getMetadataLength() const noexcept
See Cpl::Persistent::Chunk.
static constexpr size_t CRC_SIZE
The size of the CRC.
Definition CrcChunk.h:36
static constexpr size_t FRAME_OFFSET_DATA
Start of data (aka overhead length)
Definition CrcChunk.h:33
bool updateData(Payload &srcHandler, size_t index=0, bool invalidate=false) noexcept
See Cpl::Persistent::Chunk.
size_t m_dataLen
Data Length for the record.
Definition CrcChunk.h:78
CrcChunk(RegionMedia &region)
Constructor.
static constexpr size_t FRAME_OVERHEAD
Total overhead size.
Definition CrcChunk.h:39
virtual bool pushToRecord(Payload &dstHandler)
Helper method. Encapsulates pushing data to the record.
bool loadData(Payload &dstHandler, size_t index=0) noexcept
See Cpl::Persistent::Chunk.
RegionMedia & m_region
Region/Media.
Definition CrcChunk.h:75
void start(Cpl::Dm::MailboxServer &myMbox) noexcept
See Cpl::Persistent::Chunk.
This abstract class defines the interface accessing the 'data payload' of an individual Record instan...
Definition Payload.h:29
This mostly abstract class defines the operations that can be performed on a persistent media.
Definition RegionMedia.h:33
The 'Cpl' namespace is the root name space for the Colony.
Definition Api16.h:20