From 43cd86b5521c9920c7a96788136192041b04c458 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 17 Jan 2023 13:34:52 +0800 Subject: [PATCH] update: RawCode module --- include/klotski.h | 3 --- src/raw_code/CMakeLists.txt | 2 +- src/raw_code/convert.cc | 11 +++++++++++ src/raw_code/raw_code.cc | 4 ++++ src/raw_code/raw_code.h | 11 +++++++++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/raw_code/convert.cc diff --git a/include/klotski.h b/include/klotski.h index 4238978..8eb305d 100644 --- a/include/klotski.h +++ b/include/klotski.h @@ -20,9 +20,6 @@ //#define F_2x1 uint64_t(0x7007) //#define F_2x2 uint64_t(0x3F03F) -//uint64_t compact_code(uint64_t code); -//uint64_t extract_code(uint64_t code); - #endif /* diff --git a/src/raw_code/CMakeLists.txt b/src/raw_code/CMakeLists.txt index e7863a0..c5707cd 100644 --- a/src/raw_code/CMakeLists.txt +++ b/src/raw_code/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.0) -add_library(raw_code raw_code.cc) +add_library(raw_code convert.cc raw_code.cc) target_link_libraries(raw_code utils common_code) diff --git a/src/raw_code/convert.cc b/src/raw_code/convert.cc new file mode 100644 index 0000000..6b83c2e --- /dev/null +++ b/src/raw_code/convert.cc @@ -0,0 +1,11 @@ +#include "raw_code.h" + +uint64_t RawCode::compact(uint64_t raw_code) { // raw code --> common code + return 0; + // TODO: should we throw error here? +} + +/// NOTE: ensure that input common code is valid !!! +uint64_t RawCode::extract(uint64_t common_code) { // common code --> raw code + return 0; +} diff --git a/src/raw_code/raw_code.cc b/src/raw_code/raw_code.cc index c844a11..f2d0f7a 100644 --- a/src/raw_code/raw_code.cc +++ b/src/raw_code/raw_code.cc @@ -88,3 +88,7 @@ std::string RawCode::dump_case() const { } return result; } + + + + diff --git a/src/raw_code/raw_code.h b/src/raw_code/raw_code.h index b83e469..363d478 100644 --- a/src/raw_code/raw_code.h +++ b/src/raw_code/raw_code.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "common_code.h" class CommonCode; @@ -10,10 +12,19 @@ public: uint64_t unwrap() const; std::string dump_case() const; CommonCode to_common_code() const; +// friend std::ostream& operator<<(std::ostream &out, const RawCode &self); explicit RawCode(const CommonCode &common_code); explicit RawCode(uint64_t raw_code) : code(raw_code) {} +// static RawCode create(uint64_t raw_code); +// static RawCode from_common_code(const CommonCode &common_code); + + // TODO: mirror functions + private: uint64_t code; + + static uint64_t compact(uint64_t raw_code); + static uint64_t extract(uint64_t common_code); };