1 | /******************************************************************** |
2 | * Copyright (c) 2013 - 2014, Pivotal Inc. |
3 | * All rights reserved. |
4 | * |
5 | * Author: Zhanwei Wang |
6 | ********************************************************************/ |
7 | /******************************************************************** |
8 | * 2014 - |
9 | * open source under Apache License Version 2.0 |
10 | ********************************************************************/ |
11 | /** |
12 | * Licensed to the Apache Software Foundation (ASF) under one |
13 | * or more contributor license agreements. See the NOTICE file |
14 | * distributed with this work for additional information |
15 | * regarding copyright ownership. The ASF licenses this file |
16 | * to you under the Apache License, Version 2.0 (the |
17 | * "License"); you may not use this file except in compliance |
18 | * with the License. You may obtain a copy of the License at |
19 | * |
20 | * http://www.apache.org/licenses/LICENSE-2.0 |
21 | * |
22 | * Unless required by applicable law or agreed to in writing, software |
23 | * distributed under the License is distributed on an "AS IS" BASIS, |
24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
25 | * See the License for the specific language governing permissions and |
26 | * limitations under the License. |
27 | */ |
28 | #ifndef _HDFS_LIBHDFS3_COMMON_CHECKSUM_H_ |
29 | #define _HDFS_LIBHDFS3_COMMON_CHECKSUM_H_ |
30 | |
31 | #include <stdint.h> |
32 | |
33 | #define CHECKSUM_TYPE_SIZE 1 |
34 | #define CHECKSUM_BYTES_PER_CHECKSUM_SIZE 4 |
35 | #define CHECKSUM_TYPE_CRC32C 2 |
36 | |
37 | namespace Hdfs { |
38 | namespace Internal { |
39 | |
40 | /** |
41 | * An abstract base CRC class. |
42 | */ |
43 | class Checksum { |
44 | public: |
45 | /** |
46 | * @return Returns the current checksum value. |
47 | */ |
48 | virtual uint32_t getValue() = 0; |
49 | |
50 | /** |
51 | * Resets the checksum to its initial value. |
52 | */ |
53 | virtual void reset() = 0; |
54 | |
55 | /** |
56 | * Updates the current checksum with the specified array of bytes. |
57 | * @param b The buffer of data. |
58 | * @param len The buffer length. |
59 | */ |
60 | virtual void update(const void * b, int len) = 0; |
61 | |
62 | /** |
63 | * Destroy the instance. |
64 | */ |
65 | virtual ~Checksum() { |
66 | } |
67 | }; |
68 | |
69 | } |
70 | } |
71 | |
72 | #endif /* _HDFS_LIBHDFS3_COMMON_CHECKSUM_H_ */ |
73 | |