aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/Checksum.hpp
blob: 5b33f55d60dd7d88a1aa5b96d116f9383670659c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include "xxHash/include/xxhash.h"
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
namespace OpenVic {
   class Checksum : public Object {
      GDCLASS(Checksum, Object)
      
      // INIT PART
      inline static Checksum* _checksum = nullptr;

   private:
      XXH64_hash_t hash_checksum;

   protected:
      static void _bind_methods();

   public:
      inline static Checksum* get_singleton() { return _checksum; }

      inline Checksum() {
         ERR_FAIL_COND(_checksum != nullptr);
         _checksum = this;
      }
      inline ~Checksum() {
         ERR_FAIL_COND(_checksum != this);
         _checksum = nullptr;
      }
      // END INIT
      void checksum_dir(XXH3_state_t* const state, PackedByteArray buffer, String directory_path);
      void calculate_checksum(String directory_path);
      XXH64_hash_t get_checksum() const;
   };
}