some fixes [multithreading,..]

needed interface changes [new options]
logger for android
wifi-ap-optimization
new test-cases
This commit is contained in:
2016-09-28 12:19:14 +02:00
parent 91e3367372
commit 4f511d907e
62 changed files with 1418 additions and 175 deletions

View File

@@ -6,6 +6,8 @@
#include <unordered_map>
#include <algorithm>
#include "../Assertions.h"
#include "../Exception.h"
#include "GridPoint.h"
#include "GridNode.h"
@@ -47,8 +49,11 @@ public:
/** ctor with the grid's size (in cm) */
Grid(const int gridSize_cm) : gridSize_cm(gridSize_cm) {
static_assert((sizeof(T::_idx) > 0), "T must inherit from GridNode!");
static_assert((sizeof(T::x_cm) > 0), "T must inherit from GridPoint!");
//static_assert((sizeof(T::_idx) > 0), "T must inherit from GridNode!");
//static_assert((sizeof(T::x_cm) > 0), "T must inherit from GridPoint!");
StaticAssert::AinheritsB<T, GridNode>(); // "T must inherit from GridNode!"
StaticAssert::AinheritsB<T, GridPoint>(); // "T must inherit from GridPoint!"
Log::add(name, "empty grid with " + std::to_string(gridSize_cm) + "cm grid-size");
}
/** no-copy */
@@ -395,11 +400,13 @@ public:
/** serialize into the given stream */
void write(std::ostream& out) {
// serialize static
T::staticSerialize(out);
// size (in bytes) one node has. this is a sanity check whether the file matches the code!
const int nodeSize = sizeof(T);
out.write((const char*) &nodeSize, sizeof(nodeSize));
// number of nodes
const int numNodes = nodes.size();
Assert::isTrue(numNodes > 0, "grid says it contains 0 nodes. there must be some error!");
out.write((const char*) &numNodes, sizeof(numNodes));
// serialize
@@ -407,23 +414,37 @@ public:
out.write((const char*) &node, sizeof(T));
}
// serialize static parameters
T::staticSerialize(out);
out.flush();
}
/** deserialize from the given stream */
void read(std::istream& inp) {
// deserialize static
T::staticDeserialize(inp);
Log::add(name, "loading grid from input-stream");
// size (in bytes) one node has. this is a sanity check whether the file matches the code!
int nodeSize;
inp.read((char*) &nodeSize, sizeof(nodeSize));
Assert::equal(nodeSize, (int)sizeof(T), "sizeof(node) of the saved grid does not match sizeof(node) for the code!");
// number of nodes
int numNodes;
inp.read((char*) &numNodes, sizeof(numNodes));
Assert::isTrue(numNodes > 0, "grid-file says it contains 0 nodes. there must be some error!");
// allocate node-space
nodes.resize(numNodes);
// deserialize
inp.read((char*) nodes.data(), numNodes*sizeof(T));
Log::add(name, "deserialized " + std::to_string(nodes.size()) + " nodes");
// deserialize static parameters
T::staticDeserialize(inp);
// update
rebuildHashes();