1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
puzzle-wuzzle-generator/include/data.hpp
2014-03-04 14:38:13 +01:00

67 lines
1.5 KiB
C++

#pragma once
#include <boost/serialization/vector.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/serialization.hpp>
#include <vector>
struct BasicRulesBase {
unsigned int min_size;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/){
ar & min_size;
}
};
template <typename Grid>
struct Solutions {
using Trace = std::vector<typename Grid::Position>;
std::vector<Trace> traces;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/){
ar & traces;
}
};
template <typename Grid>
struct AnalyzedGrid {
Grid grid;
Solutions<Grid> solutions;
BasicRulesBase rules;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/){
ar & grid & solutions & rules;
}
};
struct DynamicGridBase {
using Position = std::pair<int, int>;
int W;
int H;
std::vector<int> grid;
std::vector<Position> positions;
DynamicGridBase() = default;
DynamicGridBase(int width, int height, std::vector<int> && data)
: W(width), H(height), grid(std::move(data))
{}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/){
ar & W & H & grid & positions;
// archiving positions is redundant (I'm being lazy here)
// consider make_nvp for readable json
}
};