Skip to content

Commit

Permalink
GCC compile errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Oct 14, 2023
1 parent ad0ed11 commit 873c84c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
12 changes: 6 additions & 6 deletions source/EngineInterface/GenomeDescriptionConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace
}
}

std::vector<uint8_t> GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription const& genome, EncodingSpecification const& spec)
std::vector<uint8_t> GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec)
{
auto const& cells = genome.cells;
std::vector<uint8_t> result;
Expand Down Expand Up @@ -236,7 +236,7 @@ namespace
std::vector<uint8_t> const& data,
size_t maxBytePosition,
size_t maxEntries,
GenomeDescriptionConverter::EncodingSpecification const& spec)
GenomeEncodingSpecification const& spec)
{
SimulationParameters parameters;
ConversionResult result;
Expand Down Expand Up @@ -349,24 +349,24 @@ namespace

}

GenomeDescription GenomeDescriptionConverter::convertBytesToDescription(std::vector<uint8_t> const& data, EncodingSpecification const& spec)
GenomeDescription GenomeDescriptionConverter::convertBytesToDescription(std::vector<uint8_t> const& data, GenomeEncodingSpecification const& spec)
{
return convertBytesToDescriptionIntern(data, data.size(), data.size(), spec).genome;
}

int GenomeDescriptionConverter::convertNodeAddressToNodeIndex(std::vector<uint8_t> const& data, int nodeAddress, EncodingSpecification const& spec)
int GenomeDescriptionConverter::convertNodeAddressToNodeIndex(std::vector<uint8_t> const& data, int nodeAddress, GenomeEncodingSpecification const& spec)
{
//wasteful approach but sufficient for GUI
return convertBytesToDescriptionIntern(data, nodeAddress, data.size(), spec).genome.cells.size();
}

int GenomeDescriptionConverter::convertNodeIndexToNodeAddress(std::vector<uint8_t> const& data, int nodeIndex, EncodingSpecification const& spec)
int GenomeDescriptionConverter::convertNodeIndexToNodeAddress(std::vector<uint8_t> const& data, int nodeIndex, GenomeEncodingSpecification const& spec)
{
//wasteful approach but sufficient for GUI
return convertBytesToDescriptionIntern(data, data.size(), nodeIndex, spec).lastBytePosition;
}

int GenomeDescriptionConverter::getNumNodesRecursively(std::vector<uint8_t> const& data, bool includeRepetitions, EncodingSpecification const& spec)
int GenomeDescriptionConverter::getNumNodesRecursively(std::vector<uint8_t> const& data, bool includeRepetitions, GenomeEncodingSpecification const& spec)
{
auto genome = convertBytesToDescriptionIntern(data, data.size(), data.size(), spec).genome;
auto result = toInt(genome.cells.size());
Expand Down
23 changes: 11 additions & 12 deletions source/EngineInterface/GenomeDescriptionConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
#include "GenomeDescriptions.h"
#include "SimulationParameters.h"

struct GenomeEncodingSpecification
{
MEMBER_DECLARATION(GenomeEncodingSpecification, bool, numRepetitions, true);
MEMBER_DECLARATION(GenomeEncodingSpecification, bool, concatenationAngle1, true);
MEMBER_DECLARATION(GenomeEncodingSpecification, bool, concatenationAngle2, true);
};

class GenomeDescriptionConverter
{
public:
struct EncodingSpecification
{
MEMBER_DECLARATION(EncodingSpecification, bool, numRepetitions, true);
MEMBER_DECLARATION(EncodingSpecification, bool, concatenationAngle1, true);
MEMBER_DECLARATION(EncodingSpecification, bool, concatenationAngle2, true);
};

static std::vector<uint8_t> convertDescriptionToBytes(GenomeDescription const& genome, EncodingSpecification const& spec = EncodingSpecification());
static GenomeDescription convertBytesToDescription(std::vector<uint8_t> const& data, EncodingSpecification const& spec = EncodingSpecification());
static std::vector<uint8_t> convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification());
static GenomeDescription convertBytesToDescription(std::vector<uint8_t> const& data, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification());

static int convertNodeAddressToNodeIndex(std::vector<uint8_t> const& data, int nodeAddress, EncodingSpecification const& spec = EncodingSpecification());
static int convertNodeIndexToNodeAddress(std::vector<uint8_t> const& data, int nodeIndex, EncodingSpecification const& spec = EncodingSpecification());
static int getNumNodesRecursively(std::vector<uint8_t> const& data, bool includeRepetitions, EncodingSpecification const& spec = EncodingSpecification());
static int convertNodeAddressToNodeIndex(std::vector<uint8_t> const& data, int nodeAddress, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification());
static int convertNodeIndexToNodeAddress(std::vector<uint8_t> const& data, int nodeIndex, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification());
static int getNumNodesRecursively(std::vector<uint8_t> const& data, bool includeRepetitions, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification());
};
2 changes: 1 addition & 1 deletion source/EngineInterface/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ namespace cereal
data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc);

auto oldVersionSpec =
GenomeDescriptionConverter::EncodingSpecification().numRepetitions(false).concatenationAngle1(false).concatenationAngle2(false);
GenomeEncodingSpecification().numRepetitions(false).concatenationAngle1(false).concatenationAngle2(false);
auto oldGenome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc, oldVersionSpec);
data.isConstructionBuilt = toInt(oldGenome.size()) <= data.genomeCurrentNodeIndex; //in old versions genomeCurrentNodeIndex was the byte index
data.genomeCurrentNodeIndex = GenomeDescriptionConverter::convertNodeAddressToNodeIndex(oldGenome, data.genomeCurrentNodeIndex, oldVersionSpec);
Expand Down

0 comments on commit 873c84c

Please sign in to comment.