From 670e3584c32095584f16fc2ce6bbc51d899f56c8 Mon Sep 17 00:00:00 2001 From: Christian Heinemann Date: Sat, 28 Oct 2023 08:25:08 +0200 Subject: [PATCH] renaming certain classes with pure static members to services --- ...ser.cpp => AuxiliaryDataParserService.cpp} | 10 +- ...aParser.h => AuxiliaryDataParserService.h} | 2 +- source/EngineInterface/CMakeLists.txt | 16 +-- ...nHelper.cpp => DescriptionEditService.cpp} | 58 ++++----- ...ptionHelper.h => DescriptionEditService.h} | 2 +- source/EngineInterface/Descriptions.cpp | 6 +- ...erter.cpp => GenomeDescriptionService.cpp} | 14 +-- ...Converter.h => GenomeDescriptionService.h} | 2 +- ...rter.cpp => PreviewDescriptionService.cpp} | 8 +- ...onverter.h => PreviewDescriptionService.h} | 2 +- source/EngineInterface/Serializer.cpp | 42 +++---- source/EngineTests/AttackerTests.cpp | 6 +- source/EngineTests/CellConnectionTests.cpp | 4 +- source/EngineTests/ConstructorTests.cpp | 114 +++++++++--------- source/EngineTests/DataTransferTests.cpp | 2 +- source/EngineTests/DefenderTests.cpp | 8 +- source/EngineTests/DescriptionHelperTests.cpp | 6 +- source/EngineTests/DetonatorTests.cpp | 4 +- source/EngineTests/InjectorTests.cpp | 16 +-- source/EngineTests/MuscleTests.cpp | 2 +- source/EngineTests/MutationTests.cpp | 74 ++++++------ source/EngineTests/NerveTests.cpp | 2 +- source/EngineTests/NeuronTests.cpp | 2 +- source/EngineTests/SensorTests.cpp | 22 ++-- source/EngineTests/StatisticsTests.cpp | 16 +-- source/EngineTests/TransmitterTests.cpp | 8 +- source/Gui/BrowserWindow.cpp | 4 +- source/Gui/CreatorWindow.cpp | 20 +-- source/Gui/CreatorWindow.h | 4 +- source/Gui/EditorController.cpp | 22 ++-- source/Gui/EditorModel.cpp | 6 +- source/Gui/GenomeEditorWindow.cpp | 24 ++-- source/Gui/ImageToPatternDialog.cpp | 4 +- source/Gui/InspectorWindow.cpp | 24 ++-- source/Gui/MassOperationsDialog.cpp | 12 +- source/Gui/MultiplierWindow.cpp | 4 +- source/Gui/MultiplierWindow.h | 6 +- source/Gui/PatternEditorWindow.cpp | 6 +- source/Gui/ResizeWorldDialog.cpp | 6 +- source/Gui/UploadSimulationDialog.cpp | 6 +- 40 files changed, 298 insertions(+), 298 deletions(-) rename source/EngineInterface/{AuxiliaryDataParser.cpp => AuxiliaryDataParserService.cpp} (98%) rename source/EngineInterface/{AuxiliaryDataParser.h => AuxiliaryDataParserService.h} (94%) rename source/EngineInterface/{DescriptionHelper.cpp => DescriptionEditService.cpp} (90%) rename source/EngineInterface/{DescriptionHelper.h => DescriptionEditService.h} (99%) rename source/EngineInterface/{GenomeDescriptionConverter.cpp => GenomeDescriptionService.cpp} (95%) rename source/EngineInterface/{GenomeDescriptionConverter.h => GenomeDescriptionService.h} (97%) rename source/EngineInterface/{PreviewDescriptionConverter.cpp => PreviewDescriptionService.cpp} (98%) rename source/EngineInterface/{PreviewDescriptionConverter.h => PreviewDescriptionService.h} (88%) diff --git a/source/EngineInterface/AuxiliaryDataParser.cpp b/source/EngineInterface/AuxiliaryDataParserService.cpp similarity index 98% rename from source/EngineInterface/AuxiliaryDataParser.cpp rename to source/EngineInterface/AuxiliaryDataParserService.cpp index ee1d091bd..d1d64c78f 100644 --- a/source/EngineInterface/AuxiliaryDataParser.cpp +++ b/source/EngineInterface/AuxiliaryDataParserService.cpp @@ -1,4 +1,4 @@ -#include "AuxiliaryDataParser.h" +#include "AuxiliaryDataParserService.h" #include "GeneralSettings.h" #include "Settings.h" @@ -883,28 +883,28 @@ namespace } } -boost::property_tree::ptree AuxiliaryDataParser::encodeAuxiliaryData(AuxiliaryData const& data) +boost::property_tree::ptree AuxiliaryDataParserService::encodeAuxiliaryData(AuxiliaryData const& data) { boost::property_tree::ptree tree; encodeDecode(tree, const_cast(data), ParserTask::Encode); return tree; } -AuxiliaryData AuxiliaryDataParser::decodeAuxiliaryData(boost::property_tree::ptree tree) +AuxiliaryData AuxiliaryDataParserService::decodeAuxiliaryData(boost::property_tree::ptree tree) { AuxiliaryData result; encodeDecode(tree, result, ParserTask::Decode); return result; } -boost::property_tree::ptree AuxiliaryDataParser::encodeSimulationParameters(SimulationParameters const& data) +boost::property_tree::ptree AuxiliaryDataParserService::encodeSimulationParameters(SimulationParameters const& data) { boost::property_tree::ptree tree; encodeDecode(tree, const_cast(data), ParserTask::Encode); return tree; } -SimulationParameters AuxiliaryDataParser::decodeSimulationParameters(boost::property_tree::ptree tree) +SimulationParameters AuxiliaryDataParserService::decodeSimulationParameters(boost::property_tree::ptree tree) { SimulationParameters result; encodeDecode(tree, result, ParserTask::Decode); diff --git a/source/EngineInterface/AuxiliaryDataParser.h b/source/EngineInterface/AuxiliaryDataParserService.h similarity index 94% rename from source/EngineInterface/AuxiliaryDataParser.h rename to source/EngineInterface/AuxiliaryDataParserService.h index e039cbbb2..d78350a3a 100644 --- a/source/EngineInterface/AuxiliaryDataParser.h +++ b/source/EngineInterface/AuxiliaryDataParserService.h @@ -8,7 +8,7 @@ #include "AuxiliaryData.h" #include "Definitions.h" -class AuxiliaryDataParser +class AuxiliaryDataParserService { public: static boost::property_tree::ptree encodeAuxiliaryData(AuxiliaryData const& data); diff --git a/source/EngineInterface/CMakeLists.txt b/source/EngineInterface/CMakeLists.txt index b5abb7fd4..2dd12a192 100644 --- a/source/EngineInterface/CMakeLists.txt +++ b/source/EngineInterface/CMakeLists.txt @@ -2,19 +2,19 @@ add_library(alien_engine_interface_lib ArraySizes.h AuxiliaryData.h - AuxiliaryDataParser.cpp - AuxiliaryDataParser.h + AuxiliaryDataParserService.cpp + AuxiliaryDataParserService.h CellFunctionConstants.h Colors.h Definitions.h - DescriptionHelper.cpp - DescriptionHelper.h + DescriptionEditService.cpp + DescriptionEditService.h Descriptions.cpp Descriptions.h FundamentalConstants.h GenomeConstants.h - GenomeDescriptionConverter.cpp - GenomeDescriptionConverter.h + GenomeDescriptionService.cpp + GenomeDescriptionService.h GenomeDescriptions.h GeneralSettings.h GpuSettings.h @@ -22,8 +22,8 @@ add_library(alien_engine_interface_lib Motion.h MutationType.h OverlayDescriptions.h - PreviewDescriptionConverter.cpp - PreviewDescriptionConverter.h + PreviewDescriptionService.cpp + PreviewDescriptionService.h PreviewDescriptions.h RadiationSource.h SelectionShallowData.h diff --git a/source/EngineInterface/DescriptionHelper.cpp b/source/EngineInterface/DescriptionEditService.cpp similarity index 90% rename from source/EngineInterface/DescriptionHelper.cpp rename to source/EngineInterface/DescriptionEditService.cpp index abe275c64..60002f71d 100644 --- a/source/EngineInterface/DescriptionHelper.cpp +++ b/source/EngineInterface/DescriptionEditService.cpp @@ -1,4 +1,4 @@ -#include "DescriptionHelper.h" +#include "DescriptionEditService.h" #include #include @@ -8,9 +8,9 @@ #include "Base/Math.h" #include "GenomeDescriptions.h" #include "SpaceCalculator.h" -#include "GenomeDescriptionConverter.h" +#include "GenomeDescriptionService.h" -DataDescription DescriptionHelper::createRect(CreateRectParameters const& parameters) +DataDescription DescriptionEditService::createRect(CreateRectParameters const& parameters) { DataDescription result; auto creatureId = parameters._randomCreatureId ? toInt(NumberGenerator::getInstance().getRandomInt(std::numeric_limits::max())) : 0; @@ -35,7 +35,7 @@ DataDescription DescriptionHelper::createRect(CreateRectParameters const& parame return result; } -DataDescription DescriptionHelper::createHex(CreateHexParameters const& parameters) +DataDescription DescriptionEditService::createHex(CreateHexParameters const& parameters) { DataDescription result; auto creatureId = parameters._randomCreatureId ? toInt(NumberGenerator::getInstance().getRandomInt(std::numeric_limits::max())) : 0; @@ -78,7 +78,7 @@ DataDescription DescriptionHelper::createHex(CreateHexParameters const& paramete return result; } -DataDescription DescriptionHelper::createUnconnectedCircle(CreateUnconnectedCircleParameters const& parameters) +DataDescription DescriptionEditService::createUnconnectedCircle(CreateUnconnectedCircleParameters const& parameters) { DataDescription result; auto creatureId = parameters._randomCreatureId ? toInt(NumberGenerator::getInstance().getRandomInt(std::numeric_limits::max())) : 0; @@ -162,7 +162,7 @@ namespace } } -void DescriptionHelper::duplicate(ClusteredDataDescription& data, IntVector2D const& origSize, IntVector2D const& size) +void DescriptionEditService::duplicate(ClusteredDataDescription& data, IntVector2D const& origSize, IntVector2D const& size) { ClusteredDataDescription result; @@ -232,7 +232,7 @@ namespace } } -DataDescription DescriptionHelper::gridMultiply(DataDescription const& input, GridMultiplyParameters const& parameters) +DataDescription DescriptionEditService::gridMultiply(DataDescription const& input, GridMultiplyParameters const& parameters) { DataDescription result; auto clone = input; @@ -261,7 +261,7 @@ DataDescription DescriptionHelper::gridMultiply(DataDescription const& input, Gr return result; } -DataDescription DescriptionHelper::randomMultiply( +DataDescription DescriptionEditService::randomMultiply( DataDescription const& input, RandomMultiplyParameters const& parameters, IntVector2D const& worldSize, @@ -334,7 +334,7 @@ DataDescription DescriptionHelper::randomMultiply( return result; } -void DescriptionHelper::addIfSpaceAvailable( +void DescriptionEditService::addIfSpaceAvailable( DataDescription& result, Occupancy& cellOccupancy, DataDescription const& toAdd, @@ -351,7 +351,7 @@ void DescriptionHelper::addIfSpaceAvailable( } } -void DescriptionHelper::reconnectCells(DataDescription& data, float maxDistance) +void DescriptionEditService::reconnectCells(DataDescription& data, float maxDistance) { std::unordered_map>> cellIndicesBySlot; @@ -378,14 +378,14 @@ void DescriptionHelper::reconnectCells(DataDescription& data, float maxDistance) } } -void DescriptionHelper::removeStickiness(DataDescription& data) +void DescriptionEditService::removeStickiness(DataDescription& data) { for (auto& cell : data.cells) { cell.maxConnections = toInt(cell.connections.size()); } } -void DescriptionHelper::correctConnections(ClusteredDataDescription& data, IntVector2D const& worldSize) +void DescriptionEditService::correctConnections(ClusteredDataDescription& data, IntVector2D const& worldSize) { auto threshold = std::min(worldSize.x, worldSize.y) /3; std::unordered_map cellById; @@ -416,7 +416,7 @@ void DescriptionHelper::correctConnections(ClusteredDataDescription& data, IntVe } } -void DescriptionHelper::randomizeCellColors(ClusteredDataDescription& data, std::vector const& colorCodes) +void DescriptionEditService::randomizeCellColors(ClusteredDataDescription& data, std::vector const& colorCodes) { for (auto& cluster : data.clusters) { auto newColor = colorCodes[NumberGenerator::getInstance().getRandomInt(toInt(colorCodes.size()))]; @@ -430,18 +430,18 @@ namespace { void colorizeGenomeNodes(std::vector& genome, int color) { - auto desc = GenomeDescriptionConverter::convertBytesToDescription(genome); + auto desc = GenomeDescriptionService::convertBytesToDescription(genome); for (auto& node : desc.cells) { node.color = color; if (node.hasGenome()) { colorizeGenomeNodes(node.getGenomeRef(), color); } } - genome = GenomeDescriptionConverter::convertDescriptionToBytes(desc); + genome = GenomeDescriptionService::convertDescriptionToBytes(desc); } } -void DescriptionHelper::randomizeGenomeColors(ClusteredDataDescription& data, std::vector const& colorCodes) +void DescriptionEditService::randomizeGenomeColors(ClusteredDataDescription& data, std::vector const& colorCodes) { for (auto& cluster : data.clusters) { auto newColor = colorCodes[NumberGenerator::getInstance().getRandomInt(toInt(colorCodes.size()))]; @@ -453,7 +453,7 @@ void DescriptionHelper::randomizeGenomeColors(ClusteredDataDescription& data, st } } -void DescriptionHelper::randomizeEnergies(ClusteredDataDescription& data, float minEnergy, float maxEnergy) +void DescriptionEditService::randomizeEnergies(ClusteredDataDescription& data, float minEnergy, float maxEnergy) { for (auto& cluster : data.clusters) { auto energy = NumberGenerator::getInstance().getRandomReal(toDouble(minEnergy), toDouble(maxEnergy)); @@ -463,7 +463,7 @@ void DescriptionHelper::randomizeEnergies(ClusteredDataDescription& data, float } } -void DescriptionHelper::randomizeAges(ClusteredDataDescription& data, int minAge, int maxAge) +void DescriptionEditService::randomizeAges(ClusteredDataDescription& data, int minAge, int maxAge) { for (auto& cluster : data.clusters) { auto age = NumberGenerator::getInstance().getRandomReal(toDouble(minAge), toDouble(maxAge)); @@ -473,7 +473,7 @@ void DescriptionHelper::randomizeAges(ClusteredDataDescription& data, int minAge } } -void DescriptionHelper::randomizeCountdowns(ClusteredDataDescription& data, int minValue, int maxValue) +void DescriptionEditService::randomizeCountdowns(ClusteredDataDescription& data, int minValue, int maxValue) { for (auto& cluster : data.clusters) { auto countdown = NumberGenerator::getInstance().getRandomReal(toDouble(minValue), toDouble(maxValue)); @@ -485,7 +485,7 @@ void DescriptionHelper::randomizeCountdowns(ClusteredDataDescription& data, int } } -void DescriptionHelper::generateExecutionOrderNumbers(DataDescription& data, std::unordered_set const& cellIds, int maxBranchNumbers) +void DescriptionEditService::generateExecutionOrderNumbers(DataDescription& data, std::unordered_set const& cellIds, int maxBranchNumbers) { std::unordered_map idToIndexMap; for (auto const& [index, cell] : data.cells | boost::adaptors::indexed(0)) { @@ -536,7 +536,7 @@ void DescriptionHelper::generateExecutionOrderNumbers(DataDescription& data, std } while (origNumVisitedCells != visitedCellIds.size()); } -void DescriptionHelper::removeMetadata(DataDescription& data) +void DescriptionEditService::removeMetadata(DataDescription& data) { for(auto& cell : data.cells) { removeMetadata(cell); @@ -562,7 +562,7 @@ namespace } -void DescriptionHelper::generateNewCreatureIds(DataDescription& data) +void DescriptionEditService::generateNewCreatureIds(DataDescription& data) { std::unordered_map origToNewCreatureIdMap; for (auto& cell : data.cells) { @@ -576,7 +576,7 @@ void DescriptionHelper::generateNewCreatureIds(DataDescription& data) } } -void DescriptionHelper::generateNewCreatureIds(ClusteredDataDescription& data) +void DescriptionEditService::generateNewCreatureIds(ClusteredDataDescription& data) { std::unordered_map origToNewCreatureIdMap; for (auto& cluster: data.clusters) { @@ -593,13 +593,13 @@ void DescriptionHelper::generateNewCreatureIds(ClusteredDataDescription& data) } -void DescriptionHelper::removeMetadata(CellDescription& cell) +void DescriptionEditService::removeMetadata(CellDescription& cell) { cell.metadata.description.clear(); cell.metadata.name.clear(); } -bool DescriptionHelper::isCellPresent(Occupancy const& cellPosBySlot, SpaceCalculator const& spaceCalculator, RealVector2D const& posToCheck, float distance) +bool DescriptionEditService::isCellPresent(Occupancy const& cellPosBySlot, SpaceCalculator const& spaceCalculator, RealVector2D const& posToCheck, float distance) { auto intPos = toIntVector2D(posToCheck); @@ -632,7 +632,7 @@ bool DescriptionHelper::isCellPresent(Occupancy const& cellPosBySlot, SpaceCalcu return false; } -uint64_t DescriptionHelper::getId(CellOrParticleDescription const& entity) +uint64_t DescriptionEditService::getId(CellOrParticleDescription const& entity) { if (std::holds_alternative(entity)) { return std::get(entity).id; @@ -640,7 +640,7 @@ uint64_t DescriptionHelper::getId(CellOrParticleDescription const& entity) return std::get(entity).id; } -RealVector2D DescriptionHelper::getPos(CellOrParticleDescription const& entity) +RealVector2D DescriptionEditService::getPos(CellOrParticleDescription const& entity) { if (std::holds_alternative(entity)) { return std::get(entity).pos; @@ -648,7 +648,7 @@ RealVector2D DescriptionHelper::getPos(CellOrParticleDescription const& entity) return std::get(entity).pos; } -std::vector DescriptionHelper::getObjects( +std::vector DescriptionEditService::getObjects( DataDescription const& data) { std::vector result; @@ -685,7 +685,7 @@ namespace } } -std::vector DescriptionHelper::getConstructorToMainGenomes(DataDescription const& data) +std::vector DescriptionEditService::getConstructorToMainGenomes(DataDescription const& data) { std::map, size_t> genomeToCellIndex; for (auto const& [index, cell] : data.cells | boost::adaptors::indexed(0)) { diff --git a/source/EngineInterface/DescriptionHelper.h b/source/EngineInterface/DescriptionEditService.h similarity index 99% rename from source/EngineInterface/DescriptionHelper.h rename to source/EngineInterface/DescriptionEditService.h index 8031ddf8e..4b7cc4a10 100644 --- a/source/EngineInterface/DescriptionHelper.h +++ b/source/EngineInterface/DescriptionEditService.h @@ -3,7 +3,7 @@ #include "Base/Definitions.h" #include "Descriptions.h" -class DescriptionHelper +class DescriptionEditService { public: struct CreateRectParameters diff --git a/source/EngineInterface/Descriptions.cpp b/source/EngineInterface/Descriptions.cpp index 962c6668a..adbc2b956 100644 --- a/source/EngineInterface/Descriptions.cpp +++ b/source/EngineInterface/Descriptions.cpp @@ -2,18 +2,18 @@ #include -#include "GenomeDescriptionConverter.h" +#include "GenomeDescriptionService.h" #include "Base/Math.h" #include "Base/Physics.h" ConstructorDescription::ConstructorDescription() { - genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()); + genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()); } InjectorDescription::InjectorDescription() { - genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()); + genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()); } CellFunction CellDescription::getCellFunctionType() const diff --git a/source/EngineInterface/GenomeDescriptionConverter.cpp b/source/EngineInterface/GenomeDescriptionService.cpp similarity index 95% rename from source/EngineInterface/GenomeDescriptionConverter.cpp rename to source/EngineInterface/GenomeDescriptionService.cpp index 4a455357f..0bbc6ac66 100644 --- a/source/EngineInterface/GenomeDescriptionConverter.cpp +++ b/source/EngineInterface/GenomeDescriptionService.cpp @@ -1,4 +1,4 @@ -#include "GenomeDescriptionConverter.h" +#include "GenomeDescriptionService.h" #include @@ -151,7 +151,7 @@ namespace } } -std::vector GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec) +std::vector GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec) { auto const& cells = genome.cells; std::vector result; @@ -379,24 +379,24 @@ namespace } -GenomeDescription GenomeDescriptionConverter::convertBytesToDescription(std::vector const& data, GenomeEncodingSpecification const& spec) +GenomeDescription GenomeDescriptionService::convertBytesToDescription(std::vector const& data, GenomeEncodingSpecification const& spec) { return convertBytesToDescriptionIntern(data, data.size(), data.size(), spec).genome; } -int GenomeDescriptionConverter::convertNodeAddressToNodeIndex(std::vector const& data, int nodeAddress, GenomeEncodingSpecification const& spec) +int GenomeDescriptionService::convertNodeAddressToNodeIndex(std::vector 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 const& data, int nodeIndex, GenomeEncodingSpecification const& spec) +int GenomeDescriptionService::convertNodeIndexToNodeAddress(std::vector 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 const& data, bool includeRepetitions, GenomeEncodingSpecification const& spec) +int GenomeDescriptionService::getNumNodesRecursively(std::vector const& data, bool includeRepetitions, GenomeEncodingSpecification const& spec) { auto genome = convertBytesToDescriptionIntern(data, data.size(), data.size(), spec).genome; auto result = toInt(genome.cells.size()); @@ -410,7 +410,7 @@ int GenomeDescriptionConverter::getNumNodesRecursively(std::vector cons return includeRepetitions ? result * numRepetitions : result; } -int GenomeDescriptionConverter::getNumRepetitions(std::vector const& data) +int GenomeDescriptionService::getNumRepetitions(std::vector const& data) { return convertByteToByteWithInfinity(data.at(Const::GenomeHeaderNumRepetitionsPos)); } diff --git a/source/EngineInterface/GenomeDescriptionConverter.h b/source/EngineInterface/GenomeDescriptionService.h similarity index 97% rename from source/EngineInterface/GenomeDescriptionConverter.h rename to source/EngineInterface/GenomeDescriptionService.h index 5aa8dbd9a..f867e4e97 100644 --- a/source/EngineInterface/GenomeDescriptionConverter.h +++ b/source/EngineInterface/GenomeDescriptionService.h @@ -12,7 +12,7 @@ struct GenomeEncodingSpecification MEMBER_DECLARATION(GenomeEncodingSpecification, bool, concatenationAngle2, true); }; -class GenomeDescriptionConverter +class GenomeDescriptionService { public: static std::vector convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec = GenomeEncodingSpecification()); diff --git a/source/EngineInterface/PreviewDescriptionConverter.cpp b/source/EngineInterface/PreviewDescriptionService.cpp similarity index 98% rename from source/EngineInterface/PreviewDescriptionConverter.cpp rename to source/EngineInterface/PreviewDescriptionService.cpp index 4adc387db..cb2d8aa84 100644 --- a/source/EngineInterface/PreviewDescriptionConverter.cpp +++ b/source/EngineInterface/PreviewDescriptionService.cpp @@ -1,4 +1,4 @@ -#include "PreviewDescriptionConverter.h" +#include "PreviewDescriptionService.h" #include #include @@ -6,7 +6,7 @@ #include "GenomeConstants.h" #include "ShapeGenerator.h" #include "Base/Math.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" namespace { @@ -311,7 +311,7 @@ namespace } targetAngle += constructor.constructionAngle1; auto direction = Math::unitVectorOfAngle(targetAngle); - auto subGenome = GenomeDescriptionConverter::convertBytesToDescription(data); + auto subGenome = GenomeDescriptionService::convertBytesToDescription(data); auto previewPart = convertToPreviewDescriptionIntern( subGenome, cellIntern.nodeIndex, constructor.constructionAngle2, cellIntern.pos + direction, targetAngle, parameters); insert(result, previewPart); @@ -386,7 +386,7 @@ namespace } PreviewDescription -PreviewDescriptionConverter::convert(GenomeDescription const& genome, std::optional selectedNode, SimulationParameters const& parameters) +PreviewDescriptionService::convert(GenomeDescription const& genome, std::optional selectedNode, SimulationParameters const& parameters) { auto cellInternDescriptions = convertToPreviewDescriptionIntern(genome, std::nullopt, std::nullopt, std::nullopt, std::nullopt, parameters); return createPreviewDescription(cellInternDescriptions, parameters); diff --git a/source/EngineInterface/PreviewDescriptionConverter.h b/source/EngineInterface/PreviewDescriptionService.h similarity index 88% rename from source/EngineInterface/PreviewDescriptionConverter.h rename to source/EngineInterface/PreviewDescriptionService.h index bbb957156..a5213da6a 100644 --- a/source/EngineInterface/PreviewDescriptionConverter.h +++ b/source/EngineInterface/PreviewDescriptionService.h @@ -5,7 +5,7 @@ #include "PreviewDescriptions.h" -class PreviewDescriptionConverter +class PreviewDescriptionService { public: static PreviewDescription convert(GenomeDescription const& genome, std::optional selectedNode, SimulationParameters const& parameters); diff --git a/source/EngineInterface/Serializer.cpp b/source/EngineInterface/Serializer.cpp index 496124d4f..af5c51bbf 100644 --- a/source/EngineInterface/Serializer.cpp +++ b/source/EngineInterface/Serializer.cpp @@ -23,10 +23,10 @@ #include "Descriptions.h" #include "SimulationParameters.h" -#include "AuxiliaryDataParser.h" +#include "AuxiliaryDataParserService.h" #include "GenomeConstants.h" #include "GenomeDescriptions.h" -#include "GenomeDescriptionConverter.h" +#include "GenomeDescriptionService.h" #define SPLIT_SERIALIZATION(Classname) \ template \ @@ -255,7 +255,7 @@ namespace cereal if (std::holds_alternative(genomeData)) { data.genome = MakeGenomeCopy(); } else { - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(std::get(genomeData)); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(std::get(genomeData)); } } else { std::variant> genomeData; @@ -273,7 +273,7 @@ namespace cereal genomeDesc.header.separateConstruction = std::get(auxiliaries.at(Id_ConstructorGenome_SeparateConstruction)); genomeDesc.header.angleAlignment = std::get(auxiliaries.at(Id_ConstructorGenome_AngleAlignment)); genomeDesc.header.stiffness = std::get(auxiliaries.at(Id_ConstructorGenome_Stiffness)); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); if (!genomeDesc.cells.empty()) { data.constructionAngle1 = genomeDesc.cells.front().referenceAngle; data.constructionAngle2 = genomeDesc.cells.back().referenceAngle; @@ -286,7 +286,7 @@ namespace cereal if (std::holds_alternative(data.genome)) { genomeData = MakeGenomeCopy(); } else { - genomeData = GenomeDescriptionConverter::convertBytesToDescription(std::get>(data.genome)); + genomeData = GenomeDescriptionService::convertBytesToDescription(std::get>(data.genome)); } ar(genomeData); } @@ -345,7 +345,7 @@ namespace cereal if (std::holds_alternative(genomeData)) { data.genome = MakeGenomeCopy(); } else { - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(std::get(genomeData)); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(std::get(genomeData)); } } else { std::variant> genomeData; @@ -355,7 +355,7 @@ namespace cereal } else { GenomeDescription genomeDesc; genomeDesc.cells = std::get>(genomeData); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); } } } else { @@ -363,7 +363,7 @@ namespace cereal if (std::holds_alternative(data.genome)) { genomeData = MakeGenomeCopy(); } else { - genomeData = GenomeDescriptionConverter::convertBytesToDescription(std::get>(data.genome)); + genomeData = GenomeDescriptionService::convertBytesToDescription(std::get>(data.genome)); } ar(genomeData); } @@ -517,7 +517,7 @@ namespace cereal if (hasGenomeHeader && useNewGenomeIndex) { GenomeDescription genomeDesc; ar(genomeDesc); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); } //compatibility with older versions @@ -529,7 +529,7 @@ namespace cereal genomeDesc.header.separateConstruction = std::get(auxiliaries.at(Id_Constructor_SeparateConstruction)); genomeDesc.header.angleAlignment = std::get(auxiliaries.at(Id_Constructor_AngleAlignment)); genomeDesc.header.stiffness = std::get(auxiliaries.at(Id_Constructor_Stiffness)); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); data.isConstructionBuilt = toInt(data.genome.size()) <= data.genomeCurrentNodeIndex; //in old versions genomeCurrentNodeIndex was the byte index data.genomeCurrentNodeIndex = 0; @@ -543,13 +543,13 @@ namespace cereal if (hasGenomeHeader && !useNewGenomeIndex) { GenomeDescription genomeDesc; ar(genomeDesc); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); auto oldVersionSpec = GenomeEncodingSpecification().numRepetitions(false).concatenationAngle1(false).concatenationAngle2(false); - auto oldGenome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc, oldVersionSpec); + auto oldGenome = GenomeDescriptionService::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); + data.genomeCurrentNodeIndex = GenomeDescriptionService::convertNodeAddressToNodeIndex(oldGenome, data.genomeCurrentNodeIndex, oldVersionSpec); if (data.genomeCurrentNodeIndex >= toInt(genomeDesc.cells.size())) { data.genomeCurrentNodeIndex = 0; } @@ -557,7 +557,7 @@ namespace cereal //<<< } else { - GenomeDescription genomeDesc = GenomeDescriptionConverter::convertBytesToDescription(data.genome); + GenomeDescription genomeDesc = GenomeDescriptionService::convertBytesToDescription(data.genome); ar(genomeDesc); } } @@ -617,14 +617,14 @@ namespace cereal if (hasGenomeHeader) { GenomeDescription genomeDesc; ar(genomeDesc); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); } else { GenomeDescription genomeDesc; ar(genomeDesc.cells); - data.genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + data.genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); } } else { - GenomeDescription genomeDesc = GenomeDescriptionConverter::convertBytesToDescription(data.genome); + GenomeDescription genomeDesc = GenomeDescriptionService::convertBytesToDescription(data.genome); ar(genomeDesc); } } @@ -993,26 +993,26 @@ void Serializer::deserializeDataDescription(ClusteredDataDescription& data, std: void Serializer::serializeAuxiliaryData(AuxiliaryData const& auxiliaryData, std::ostream& stream) { - boost::property_tree::json_parser::write_json(stream, AuxiliaryDataParser::encodeAuxiliaryData(auxiliaryData)); + boost::property_tree::json_parser::write_json(stream, AuxiliaryDataParserService::encodeAuxiliaryData(auxiliaryData)); } void Serializer::deserializeAuxiliaryData(AuxiliaryData& auxiliaryData, std::istream& stream) { boost::property_tree::ptree tree; boost::property_tree::read_json(stream, tree); - auxiliaryData = AuxiliaryDataParser::decodeAuxiliaryData(tree); + auxiliaryData = AuxiliaryDataParserService::decodeAuxiliaryData(tree); } void Serializer::serializeSimulationParameters(SimulationParameters const& parameters, std::ostream& stream) { - boost::property_tree::json_parser::write_json(stream, AuxiliaryDataParser::encodeSimulationParameters(parameters)); + boost::property_tree::json_parser::write_json(stream, AuxiliaryDataParserService::encodeSimulationParameters(parameters)); } void Serializer::deserializeSimulationParameters(SimulationParameters& parameters, std::istream& stream) { boost::property_tree::ptree tree; boost::property_tree::read_json(stream, tree); - parameters = AuxiliaryDataParser::decodeSimulationParameters(tree); + parameters = AuxiliaryDataParserService::decodeSimulationParameters(tree); } bool Serializer::wrapGenome(ClusteredDataDescription& output, std::vector const& input) diff --git a/source/EngineTests/AttackerTests.cpp b/source/EngineTests/AttackerTests.cpp index 52d86c8ef..9f46dead7 100644 --- a/source/EngineTests/AttackerTests.cpp +++ b/source/EngineTests/AttackerTests.cpp @@ -1,9 +1,9 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/GenomeDescriptions.h" #include "IntegrationTestFramework.h" @@ -229,7 +229,7 @@ TEST_F(AttackerTests, successDistributeToTwoTransmittersWithDifferentColor) TEST_F(AttackerTests, successDistributeToTransmitterAndConstructor) { - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ diff --git a/source/EngineTests/CellConnectionTests.cpp b/source/EngineTests/CellConnectionTests.cpp index d912814f9..2afbef193 100644 --- a/source/EngineTests/CellConnectionTests.cpp +++ b/source/EngineTests/CellConnectionTests.cpp @@ -1,7 +1,7 @@ #include #include "Base/NumberGenerator.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" @@ -21,7 +21,7 @@ TEST_F(CellConnectionTests, decay) _parameters.baseValues.radiationAbsorption[0] = 0; _simController->setSimulationParameters(_parameters); auto origData = - DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().width(10).height(10).energy(_parameters.baseValues.cellMinEnergy[0] / 2)); + DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().width(10).height(10).energy(_parameters.baseValues.cellMinEnergy[0] / 2)); _simController->setSimulationData(origData); for (int i = 0; i < 1000; ++i) { diff --git a/source/EngineTests/ConstructorTests.cpp b/source/EngineTests/ConstructorTests.cpp index 4e6050a85..01a5bf74f 100644 --- a/source/EngineTests/ConstructorTests.cpp +++ b/source/EngineTests/ConstructorTests.cpp @@ -3,9 +3,9 @@ #include "Base/Math.h" #include "Base/NumberGenerator.h" #include "EngineInterface/GenomeConstants.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" @@ -45,7 +45,7 @@ class ConstructorTests : public IntegrationTestFramework TEST_F(ConstructorTests, noEnergy) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -74,7 +74,7 @@ TEST_F(ConstructorTests, alreadyFinished) { DataDescription data; - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSingleConstruction(true)).setCells({CellGenomeDescription()})); auto constructor = ConstructorDescription().setGenome(genome).setIsConstructionBuilt(true); @@ -103,7 +103,7 @@ TEST_F(ConstructorTests, notActivated) { DataDescription data; - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSingleConstruction(true)).setCells({CellGenomeDescription()})); auto constructor = ConstructorDescription().setGenome(genome); @@ -127,7 +127,7 @@ TEST_F(ConstructorTests, notActivated) TEST_F(ConstructorTests, manualConstruction_noInputActivity) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCell( @@ -154,7 +154,7 @@ TEST_F(ConstructorTests, manualConstruction_noInputActivity) TEST_F(ConstructorTests, constructFirstCell_correctCycle) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); _simController->calcTimesteps(1); @@ -177,7 +177,7 @@ TEST_F(ConstructorTests, constructFirstCell_correctCycle) TEST_F(ConstructorTests, constructFirstCell_infiniteRepetitions) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setInfiniteRepetitions()).setCells({CellGenomeDescription()})); _simController->calcTimesteps(1); @@ -203,7 +203,7 @@ TEST_F(ConstructorTests, constructFirstCell_infiniteRepetitions) TEST_F(ConstructorTests, constructFirstCell_wrongCycle) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setCells({CellGenomeDescription()})); _simController->calcTimesteps(1); @@ -229,8 +229,8 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_constructionNotBui { auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -266,8 +266,8 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_repeatedConstructi { auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setNumRepetitions(2)).setCells({CellGenomeDescription()})); DataDescription data; @@ -304,8 +304,8 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_constructionBuilt) { auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -341,8 +341,8 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_infiniteConstructi { auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setInfiniteRepetitions()).setCells({CellGenomeDescription()})); DataDescription data; @@ -378,12 +378,12 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_infiniteConstructi TEST_F(ConstructorTests, constructFirstCell_completenessCheck_largeCluster) { auto constexpr RectLength = 50; - auto rect = DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().height(RectLength).width(RectLength)); + auto rect = DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().height(RectLength).width(RectLength)); auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); auto& cell1 = rect.cells.at(0); cell1.setEnergy(_parameters.cellNormalEnergy[0] * 3).setExecutionOrderNumber(0).setCellFunction(ConstructorDescription().setGenome(genome)); @@ -405,8 +405,8 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_underConstruction) { auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -448,7 +448,7 @@ TEST_F(ConstructorTests, constructFirstCell_completenessCheck_underConstruction) TEST_F(ConstructorTests, constructFirstCell_noSeparation) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription() .setHeader(GenomeHeaderDescription().setSeparateConstruction(false).setStiffness(0.35f)) .setCells({CellGenomeDescription().setColor(2).setExecutionOrderNumber(4).setInputExecutionOrderNumber(5).setOutputBlocked(true)})); @@ -492,7 +492,7 @@ TEST_F(ConstructorTests, constructFirstCell_noSeparation) TEST_F(ConstructorTests, constructFirstCell_notFinished) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription() .setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription(), CellGenomeDescription()})); @@ -522,7 +522,7 @@ TEST_F(ConstructorTests, constructFirstCell_notFinished) TEST_F(ConstructorTests, constructFirstCell_separation) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(true)).setCells({CellGenomeDescription()})); DataDescription data; @@ -552,7 +552,7 @@ TEST_F(ConstructorTests, constructFirstCell_separation) TEST_F(ConstructorTests, constructFirstCell_singleConstruction) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(true).setSingleConstruction(true)).setCells({CellGenomeDescription()})); DataDescription data; @@ -583,7 +583,7 @@ TEST_F(ConstructorTests, constructFirstCell_singleConstruction) TEST_F(ConstructorTests, constructFirstCell_manualConstruction) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; @@ -626,7 +626,7 @@ TEST_F(ConstructorTests, constructFirstCell_manualConstruction) TEST_F(ConstructorTests, constructFirstCell_differentAngle1) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -662,7 +662,7 @@ TEST_F(ConstructorTests, constructFirstCell_differentAngle1) TEST_F(ConstructorTests, constructFirstCell_differentAngle2) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setReferenceAngle(-90.0f)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setReferenceAngle(-90.0f)})); DataDescription data; data.addCells( @@ -703,7 +703,7 @@ TEST_F(ConstructorTests, constructNeuronCell) neuron.weights[7][1] = -1.9f; neuron.biases[3] = 3.8f; - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(neuron)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(neuron)})); DataDescription data; data.addCell( @@ -739,7 +739,7 @@ TEST_F(ConstructorTests, constructConstructorCell) auto constructorGenome = ConstructorGenomeDescription().setMode(0).setConstructionActivationTime(123).setGenome(createRandomGenome(MAX_GENOME_BYTES / 2)); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructorGenome)})); DataDescription data; @@ -768,7 +768,7 @@ TEST_F(ConstructorTests, constructConstructorCell) TEST_F(ConstructorTests, constructNerveCell) { auto nerveDesc = NerveGenomeDescription().setPulseMode(2).setAlternationMode(4); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(nerveDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(nerveDesc)})); DataDescription data; data.addCell(CellDescription() @@ -794,7 +794,7 @@ TEST_F(ConstructorTests, constructNerveCell) TEST_F(ConstructorTests, constructAttackerCell) { auto attackerDesc = AttackerGenomeDescription().setMode(EnergyDistributionMode_TransmittersAndConstructors); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(attackerDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(attackerDesc)})); DataDescription data; data.addCell(CellDescription() @@ -820,7 +820,7 @@ TEST_F(ConstructorTests, constructAttackerCell) TEST_F(ConstructorTests, constructDefenderCell) { auto defenderDesc = DefenderGenomeDescription().setMode(DefenderMode_DefendAgainstInjector); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(defenderDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(defenderDesc)})); DataDescription data; data.addCell(CellDescription() @@ -847,7 +847,7 @@ TEST_F(ConstructorTests, constructTransmitterCell) { auto transmitterDesc = TransmitterGenomeDescription().setMode(EnergyDistributionMode_TransmittersAndConstructors); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(transmitterDesc)})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(transmitterDesc)})); DataDescription data; data.addCell(CellDescription() @@ -873,7 +873,7 @@ TEST_F(ConstructorTests, constructTransmitterCell) TEST_F(ConstructorTests, constructMuscleCell) { auto muscleDesc = MuscleGenomeDescription().setMode(MuscleMode_ContractionExpansion); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(muscleDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(muscleDesc)})); DataDescription data; data.addCell(CellDescription() @@ -901,7 +901,7 @@ TEST_F(ConstructorTests, constructMuscleCell) TEST_F(ConstructorTests, constructSensorCell) { auto sensorDesc = SensorGenomeDescription().setFixedAngle(90.0f).setColor(2).setMinDensity(0.5f); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(sensorDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(sensorDesc)})); DataDescription data; data.addCell(CellDescription() @@ -930,7 +930,7 @@ TEST_F(ConstructorTests, constructSensorCell) TEST_F(ConstructorTests, constructInjectorCell) { auto injectorDesc = InjectorGenomeDescription().setMode(InjectorMode_InjectOnlyEmptyCells).setGenome(createRandomGenome(MAX_GENOME_BYTES / 2)); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(injectorDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(injectorDesc)})); DataDescription data; data.addCell(CellDescription() @@ -958,7 +958,7 @@ TEST_F(ConstructorTests, constructReconnectorCell) { auto reconnectorDesc = ReconnectorGenomeDescription().setColor(2); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(reconnectorDesc)})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(reconnectorDesc)})); DataDescription data; data.addCell(CellDescription() @@ -984,7 +984,7 @@ TEST_F(ConstructorTests, constructReconnectorCell) TEST_F(ConstructorTests, constructDetonatorCell) { auto detonatorDesc = DetonatorGenomeDescription().setCountDown(25); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(detonatorDesc)})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(detonatorDesc)})); DataDescription data; data.addCell(CellDescription() @@ -1011,7 +1011,7 @@ TEST_F(ConstructorTests, constructConstructorCell_nestingGenomeTooLarge) { auto constructedConstructor = ConstructorGenomeDescription().setMode(0).setGenome(createRandomGenome(MAX_GENOME_BYTES)); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructedConstructor)})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructedConstructor)})); DataDescription data; @@ -1044,7 +1044,7 @@ TEST_F(ConstructorTests, constructConstructorCell_copyGenome) auto constructedConstructor = ConstructorGenomeDescription().setMode(0).setMakeSelfCopy(); auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructedConstructor)})); + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription().setCellFunction(constructedConstructor)})); DataDescription data; data.addCell(CellDescription() @@ -1069,7 +1069,7 @@ TEST_F(ConstructorTests, constructConstructorCell_copyGenome) TEST_F(ConstructorTests, constructSecondCell_separation) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(true)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1115,7 +1115,7 @@ TEST_F(ConstructorTests, constructSecondCell_separation) TEST_F(ConstructorTests, constructSecondCell_constructionStateTransitions) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(true)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1170,7 +1170,7 @@ TEST_F(ConstructorTests, constructSecondCell_constructionStateTransitions) TEST_F(ConstructorTests, constructSecondCell_noSeparation) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1224,7 +1224,7 @@ TEST_F(ConstructorTests, constructSecondCell_noSeparation) TEST_F(ConstructorTests, constructSecondCell_noSpace) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1264,7 +1264,7 @@ TEST_F(ConstructorTests, constructSecondCell_noSpace) TEST_F(ConstructorTests, constructSecondCell_notFinished) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription(), CellGenomeDescription()})); DataDescription data; @@ -1308,7 +1308,7 @@ TEST_F(ConstructorTests, constructSecondCell_notFinished) TEST_F(ConstructorTests, constructSecondCell_differentAngle1) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1357,7 +1357,7 @@ TEST_F(ConstructorTests, constructSecondCell_differentAngle1) TEST_F(ConstructorTests, constructSecondCell_differentAngle2) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1406,7 +1406,7 @@ TEST_F(ConstructorTests, constructSecondCell_differentAngle2) TEST_F(ConstructorTests, constructThirdCell_multipleConnections_upperPart) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1464,7 +1464,7 @@ TEST_F(ConstructorTests, constructThirdCell_multipleConnections_upperPart) TEST_F(ConstructorTests, constructThirdCell_multipleConnections_bottomPart) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1522,7 +1522,7 @@ TEST_F(ConstructorTests, constructThirdCell_multipleConnections_bottomPart) TEST_F(ConstructorTests, constructSecondCell_noSeparation_singleConstruction) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false).setSingleConstruction(true)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1555,7 +1555,7 @@ TEST_F(ConstructorTests, constructSecondCell_noSeparation_singleConstruction) TEST_F(ConstructorTests, constructFourthCell_noOverlappingConnection) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setSeparateConstruction(false)).setCells({CellGenomeDescription()})); DataDescription data; @@ -1622,7 +1622,7 @@ TEST_F(ConstructorTests, constructFourthCell_noOverlappingConnection) TEST_F(ConstructorTests, constructLastCellFirstRepetition) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setNumRepetitions(2)).setCells({CellGenomeDescription(), CellGenomeDescription()})); DataDescription data; @@ -1657,7 +1657,7 @@ TEST_F(ConstructorTests, constructLastCellFirstRepetition) TEST_F(ConstructorTests, constructLastCellLastRepetition) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto genome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setNumRepetitions(2)).setCells({CellGenomeDescription(), CellGenomeDescription()})); DataDescription data; @@ -1693,7 +1693,7 @@ TEST_F(ConstructorTests, constructLastCellLastRepetition) TEST_F(ConstructorTests, restartIfNoLastConstructedCellFound) { auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription() + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription() .setHeader(GenomeHeaderDescription().setNumRepetitions(2)) .setCells({CellGenomeDescription(), CellGenomeDescription(), CellGenomeDescription()})); @@ -1732,7 +1732,7 @@ TEST_F(ConstructorTests, restartIfNoLastConstructedCellFound) TEST_F(ConstructorTests, restartIfLastConstructedCellHasLowNumConnections) { auto genome = - GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription() + GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription() .setHeader(GenomeHeaderDescription().setNumRepetitions(2)) .setCells({CellGenomeDescription(), CellGenomeDescription(), CellGenomeDescription()})); diff --git a/source/EngineTests/DataTransferTests.cpp b/source/EngineTests/DataTransferTests.cpp index 5a9ea5cf8..e24b91801 100644 --- a/source/EngineTests/DataTransferTests.cpp +++ b/source/EngineTests/DataTransferTests.cpp @@ -1,7 +1,7 @@ #include #include "Base/NumberGenerator.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" diff --git a/source/EngineTests/DefenderTests.cpp b/source/EngineTests/DefenderTests.cpp index 96a2939ad..5b00e875d 100644 --- a/source/EngineTests/DefenderTests.cpp +++ b/source/EngineTests/DefenderTests.cpp @@ -1,8 +1,8 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" @@ -124,7 +124,7 @@ TEST_F(DefenderTests, attackerVsAntiInjector) TEST_F(DefenderTests, injectorVsAntiAttacker) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -176,7 +176,7 @@ TEST_F(DefenderTests, injectorVsAntiAttacker) TEST_F(DefenderTests, injectorVsAntiInjector) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ diff --git a/source/EngineTests/DescriptionHelperTests.cpp b/source/EngineTests/DescriptionHelperTests.cpp index 6d00e9d51..2455d6cf9 100644 --- a/source/EngineTests/DescriptionHelperTests.cpp +++ b/source/EngineTests/DescriptionHelperTests.cpp @@ -2,7 +2,7 @@ #include "Base/Definitions.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" @@ -38,11 +38,11 @@ class DescriptionHelperTests TEST_F(DescriptionHelperTests, correctConnections) { - auto data = DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().width(10).height(10).center({50.0f, 99.0f})); + auto data = DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().width(10).height(10).center({50.0f, 99.0f})); _simController->setSimulationData(data); auto clusteredData = _simController->getClusteredSimulationData(); - DescriptionHelper::correctConnections(clusteredData, {100, 100}); + DescriptionEditService::correctConnections(clusteredData, {100, 100}); EXPECT_TRUE(areAngelsCorrect(clusteredData)); } diff --git a/source/EngineTests/DetonatorTests.cpp b/source/EngineTests/DetonatorTests.cpp index 1b125dd0e..204f1e70f 100644 --- a/source/EngineTests/DetonatorTests.cpp +++ b/source/EngineTests/DetonatorTests.cpp @@ -1,9 +1,9 @@ #include #include "Base/Math.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/GenomeDescriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" diff --git a/source/EngineTests/InjectorTests.cpp b/source/EngineTests/InjectorTests.cpp index c94243e1b..143b5378a 100644 --- a/source/EngineTests/InjectorTests.cpp +++ b/source/EngineTests/InjectorTests.cpp @@ -1,9 +1,9 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "IntegrationTestFramework.h" @@ -67,7 +67,7 @@ TEST_F(InjectorTests, nothingFound) TEST_F(InjectorTests, matchButNoInjection) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells( @@ -112,7 +112,7 @@ TEST_F(InjectorTests, matchButNoInjection) TEST_F(InjectorTests, injection) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -155,8 +155,8 @@ TEST_F(InjectorTests, injection) TEST_F(InjectorTests, injectOnlyEmptyCells_failed) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription(), CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription(), CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -204,8 +204,8 @@ TEST_F(InjectorTests, injectOnlyEmptyCells_failed) TEST_F(InjectorTests, injectOnlyEmptyCells_success) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); - auto otherGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription(), CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto otherGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription(), CellGenomeDescription()})); DataDescription data; data.addCells({ diff --git a/source/EngineTests/MuscleTests.cpp b/source/EngineTests/MuscleTests.cpp index d714f3cd7..39bbe570e 100644 --- a/source/EngineTests/MuscleTests.cpp +++ b/source/EngineTests/MuscleTests.cpp @@ -1,7 +1,7 @@ #include #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" diff --git a/source/EngineTests/MutationTests.cpp b/source/EngineTests/MutationTests.cpp index e5b87e3dd..32eb8ff7f 100644 --- a/source/EngineTests/MutationTests.cpp +++ b/source/EngineTests/MutationTests.cpp @@ -7,10 +7,10 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "IntegrationTestFramework.h" @@ -27,9 +27,9 @@ class MutationTests : public IntegrationTestFramework std::vector const genomeCellColors = {1, 4, 5}; std::vector createGenomeWithMultipleCellsWithDifferentFunctions() const { - std::vector subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()); + std::vector subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()); for (int i = 0; i < 15; ++i) { - subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(genomeCellColors[0]), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(genomeCellColors[1]), CellGenomeDescription().setColor(genomeCellColors[2]), @@ -39,7 +39,7 @@ class MutationTests : public IntegrationTestFramework .setColor(genomeCellColors[0]), })); } - return GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + return GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(genomeCellColors[0]), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(genomeCellColors[1]), CellGenomeDescription().setColor(genomeCellColors[0]), @@ -57,10 +57,10 @@ class MutationTests : public IntegrationTestFramework std::vector createGenomeWithUniformColorPerSubgenome() const { - std::vector subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()); + std::vector subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()); for (int i = 0; i < 15; ++i) { auto color = genomeCellColors[i % genomeCellColors.size()]; - subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(color), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(color), CellGenomeDescription().setColor(color), @@ -70,7 +70,7 @@ class MutationTests : public IntegrationTestFramework .setColor(color), })); }; - return GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + return GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(genomeCellColors[0]), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(genomeCellColors[0]), CellGenomeDescription().setColor(genomeCellColors[0]), @@ -89,9 +89,9 @@ class MutationTests : public IntegrationTestFramework std::vector createGenomeWithUniformColor() const { auto color = genomeCellColors[0]; - std::vector subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()); + std::vector subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()); for (int i = 0; i < 15; ++i) { - subGenome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + subGenome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(color), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(color), CellGenomeDescription().setColor(color), @@ -99,7 +99,7 @@ class MutationTests : public IntegrationTestFramework CellGenomeDescription().setCellFunction(ConstructorGenomeDescription().setGenome(subGenome).setMode(std::rand() % 100)).setColor(color), })); }; - return GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + return GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()).setColor(color), CellGenomeDescription().setCellFunction(TransmitterGenomeDescription()).setColor(color), CellGenomeDescription().setColor(color), @@ -119,7 +119,7 @@ class MutationTests : public IntegrationTestFramework { for (auto const& cell : input.cells) { if (auto subGenomeBytes = cell.getGenome()) { - auto subGenome = GenomeDescriptionConverter::convertBytesToDescription(*subGenomeBytes); + auto subGenome = GenomeDescriptionService::convertBytesToDescription(*subGenomeBytes); rollout(subGenome, result); auto cellClone = cell; cellClone.setGenome({}); @@ -135,8 +135,8 @@ class MutationTests : public IntegrationTestFramework if (expected.size() != actual.size()) { return false; } - auto expectedGenome = GenomeDescriptionConverter::convertBytesToDescription(expected); - auto actualGenome = GenomeDescriptionConverter::convertBytesToDescription(actual); + auto expectedGenome = GenomeDescriptionService::convertBytesToDescription(expected); + auto actualGenome = GenomeDescriptionService::convertBytesToDescription(actual); if (expectedGenome.header.shape != actualGenome.header.shape) { return false; } @@ -196,8 +196,8 @@ class MutationTests : public IntegrationTestFramework if (expected.size() != actual.size()) { return false; } - auto expectedGenome = GenomeDescriptionConverter::convertBytesToDescription(expected); - auto actualGenome = GenomeDescriptionConverter::convertBytesToDescription(actual); + auto expectedGenome = GenomeDescriptionService::convertBytesToDescription(expected); + auto actualGenome = GenomeDescriptionService::convertBytesToDescription(actual); if (expectedGenome.header != actualGenome.header) { return false; } @@ -250,8 +250,8 @@ class MutationTests : public IntegrationTestFramework if (expected.size() != actual.size()) { return false; } - auto expectedGenome = GenomeDescriptionConverter::convertBytesToDescription(expected); - auto actualGenome = GenomeDescriptionConverter::convertBytesToDescription(actual); + auto expectedGenome = GenomeDescriptionService::convertBytesToDescription(expected); + auto actualGenome = GenomeDescriptionService::convertBytesToDescription(actual); if (expectedGenome.cells.size() != actualGenome.cells.size()) { return false; } @@ -312,8 +312,8 @@ class MutationTests : public IntegrationTestFramework if (expected.size() != actual.size()) { return false; } - auto expectedGenome = GenomeDescriptionConverter::convertBytesToDescription(expected); - auto actualGenome = GenomeDescriptionConverter::convertBytesToDescription(actual); + auto expectedGenome = GenomeDescriptionService::convertBytesToDescription(expected); + auto actualGenome = GenomeDescriptionService::convertBytesToDescription(actual); expectedGenome.header.shape = ConstructionShape_Custom; //compare all expect shape actualGenome.header.shape = ConstructionShape_Custom; if (expectedGenome.header != actualGenome.header) { @@ -378,8 +378,8 @@ class MutationTests : public IntegrationTestFramework bool compareCellFunctionMutation(std::vector const& expected, std::vector const& actual) { - auto expectedGenome = GenomeDescriptionConverter::convertBytesToDescription(expected); - auto actualGenome = GenomeDescriptionConverter::convertBytesToDescription(actual); + auto expectedGenome = GenomeDescriptionService::convertBytesToDescription(expected); + auto actualGenome = GenomeDescriptionService::convertBytesToDescription(actual); if (expectedGenome.header != actualGenome.header) { return false; } @@ -414,8 +414,8 @@ class MutationTests : public IntegrationTestFramework bool compareInsertMutation(std::vector const& before, std::vector const& after) { - auto beforeGenome = GenomeDescriptionConverter::convertBytesToDescription(before); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(after); + auto beforeGenome = GenomeDescriptionService::convertBytesToDescription(before); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(after); if (afterGenome.header != beforeGenome.header) { return false; } @@ -462,8 +462,8 @@ class MutationTests : public IntegrationTestFramework bool compareDeleteMutation(std::vector const& before, std::vector const& after) { - auto beforeGenome = GenomeDescriptionConverter::convertBytesToDescription(before); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(after); + auto beforeGenome = GenomeDescriptionService::convertBytesToDescription(before); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(after); if (afterGenome.header != beforeGenome.header) { return false; } @@ -510,8 +510,8 @@ class MutationTests : public IntegrationTestFramework bool compareTranslateMutation(std::vector const& before, std::vector const& after) { - auto beforeGenome = GenomeDescriptionConverter::convertBytesToDescription(before); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(after); + auto beforeGenome = GenomeDescriptionService::convertBytesToDescription(before); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(after); std::set beforeGenomeRollout; rollout(beforeGenome, beforeGenomeRollout); @@ -523,8 +523,8 @@ class MutationTests : public IntegrationTestFramework bool compareColorMutation(std::vector const& before, std::vector const& after, std::set const& allowedColors) { - auto beforeGenome = GenomeDescriptionConverter::convertBytesToDescription(before); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(after); + auto beforeGenome = GenomeDescriptionService::convertBytesToDescription(before); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(after); if (afterGenome.header != beforeGenome.header) { return false; } @@ -563,8 +563,8 @@ class MutationTests : public IntegrationTestFramework bool compareUniformColorMutation(std::vector const& before, std::vector const& after, std::optional const& allowedColor) { - auto beforeGenome = GenomeDescriptionConverter::convertBytesToDescription(before); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(after); + auto beforeGenome = GenomeDescriptionService::convertBytesToDescription(before); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(after); if (afterGenome.header != beforeGenome.header) { return false; } @@ -717,7 +717,7 @@ TEST_F(MutationTests, insertMutation_emptyGenome) auto actualConstructor = std::get(*actualCellById.at(1).cellFunction); - auto actualGenomeDescription = GenomeDescriptionConverter::convertBytesToDescription(actualConstructor.genome); + auto actualGenomeDescription = GenomeDescriptionService::convertBytesToDescription(actualConstructor.genome); EXPECT_EQ(1, actualGenomeDescription.cells.size()); EXPECT_EQ(cellColor, actualGenomeDescription.cells.front().color); } @@ -747,7 +747,7 @@ TEST_F(MutationTests, insertMutation) TEST_F(MutationTests, deleteMutation_eraseSmallGenome) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({ + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({ CellGenomeDescription().setCellFunction(NeuronGenomeDescription()), })); @@ -761,7 +761,7 @@ TEST_F(MutationTests, deleteMutation_eraseSmallGenome) auto actualCellById = getCellById(actualData); auto actualConstructor = std::get(*actualCellById.at(1).cellFunction); - EXPECT_EQ(GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()).size(), actualConstructor.genome.size()); + EXPECT_EQ(GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()).size(), actualConstructor.genome.size()); EXPECT_EQ(0, actualConstructor.genomeCurrentNodeIndex); } @@ -781,7 +781,7 @@ TEST_F(MutationTests, deleteMutation_eraseLargeGenome_preserveSelfReplication) auto actualCellById = getCellById(actualData); auto actualConstructor = std::get(*actualCellById.at(1).cellFunction); - auto afterGenome = GenomeDescriptionConverter::convertBytesToDescription(actualConstructor.genome); + auto afterGenome = GenomeDescriptionService::convertBytesToDescription(actualConstructor.genome); std::set afterGenomeRollout; rollout(afterGenome, afterGenomeRollout); @@ -812,7 +812,7 @@ TEST_F(MutationTests, deleteMutation_eraseLargeGenome_changeSelfReplication) auto actualConstructor = std::get(*actualCellById.at(1).cellFunction); - EXPECT_EQ(GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription()).size(), actualConstructor.genome.size()); + EXPECT_EQ(GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription()).size(), actualConstructor.genome.size()); EXPECT_EQ(0, actualConstructor.genomeCurrentNodeIndex); } diff --git a/source/EngineTests/NerveTests.cpp b/source/EngineTests/NerveTests.cpp index b6355677c..4691c3c9b 100644 --- a/source/EngineTests/NerveTests.cpp +++ b/source/EngineTests/NerveTests.cpp @@ -1,6 +1,6 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" diff --git a/source/EngineTests/NeuronTests.cpp b/source/EngineTests/NeuronTests.cpp index ca5de0145..daf1f3019 100644 --- a/source/EngineTests/NeuronTests.cpp +++ b/source/EngineTests/NeuronTests.cpp @@ -1,7 +1,7 @@ #include #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" diff --git a/source/EngineTests/SensorTests.cpp b/source/EngineTests/SensorTests.cpp index 17c515a6d..f675a72d1 100644 --- a/source/EngineTests/SensorTests.cpp +++ b/source/EngineTests/SensorTests.cpp @@ -1,6 +1,6 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" @@ -104,7 +104,7 @@ TEST_F(SensorTests, scanNeighborhood_densityTooLow) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({10.0f, 100.0f}).width(10).height(10).cellDistance(2.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({10.0f, 100.0f}).width(10).height(10).cellDistance(2.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -135,7 +135,7 @@ TEST_F(SensorTests, scanNeighborhood_wrongColor) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({10.0f, 100.0f}).width(10).height(10).cellDistance(2.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({10.0f, 100.0f}).width(10).height(10).cellDistance(2.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -166,7 +166,7 @@ TEST_F(SensorTests, scanNeighborhood_foundAtFront) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({10.0f, 100.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({10.0f, 100.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -202,7 +202,7 @@ TEST_F(SensorTests, scanNeighborhood_foundAtRightHandSide) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 10.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 10.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -238,7 +238,7 @@ TEST_F(SensorTests, scanNeighborhood_foundAtLeftHandSide) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -274,7 +274,7 @@ TEST_F(SensorTests, scanNeighborhood_foundAtBack) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({190.0f, 100.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({190.0f, 100.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -310,8 +310,8 @@ TEST_F(SensorTests, scanNeighborhood_twoMasses) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 10.0f}).width(16).height(16).cellDistance(0.8f))); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 200.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 10.0f}).width(16).height(16).cellDistance(0.8f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 200.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -347,7 +347,7 @@ TEST_F(SensorTests, scanByAngle_found) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); @@ -381,7 +381,7 @@ TEST_F(SensorTests, scanByAngle_wrongAngle) .setActivity({1, 0, 0, 0, 0, 0, 0, 0})}); data.addConnection(1, 2); - data.add(DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); + data.add(DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters().center({100.0f, 190.0f}).width(16).height(16).cellDistance(0.5f))); _simController->setSimulationData(data); _simController->calcTimesteps(1); diff --git a/source/EngineTests/StatisticsTests.cpp b/source/EngineTests/StatisticsTests.cpp index cd1b5c12f..5572d2554 100644 --- a/source/EngineTests/StatisticsTests.cpp +++ b/source/EngineTests/StatisticsTests.cpp @@ -1,10 +1,10 @@ #include #include "Base/NumberGenerator.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/StatisticsData.h" #include "IntegrationTestFramework.h" @@ -21,9 +21,9 @@ class StatisticsTests : public IntegrationTestFramework TEST_F(StatisticsTests, selfReplicatorWithRepetitionsInGenome) { - auto subGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto subGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setNumRepetitions(3)).setCells({CellGenomeDescription()})); - auto mainGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto mainGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription() .setHeader(GenomeHeaderDescription().setNumRepetitions(2)) .setCells({ @@ -46,9 +46,9 @@ TEST_F(StatisticsTests, selfReplicatorWithRepetitionsInGenome) TEST_F(StatisticsTests, selfReplicatorWithInfiniteRepetitionsInGenome) { - auto subGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto subGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setInfiniteRepetitions()).setCells({CellGenomeDescription()})); - auto mainGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto mainGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription() .setHeader(GenomeHeaderDescription().setNumRepetitions(2)) .setCells({ @@ -71,9 +71,9 @@ TEST_F(StatisticsTests, selfReplicatorWithInfiniteRepetitionsInGenome) TEST_F(StatisticsTests, nonSelfReplicatorWithRepetitionsInGenome) { - auto subGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto subGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription().setHeader(GenomeHeaderDescription().setNumRepetitions(3)).setCells({CellGenomeDescription()})); - auto mainGenome = GenomeDescriptionConverter::convertDescriptionToBytes( + auto mainGenome = GenomeDescriptionService::convertDescriptionToBytes( GenomeDescription() .setHeader(GenomeHeaderDescription().setNumRepetitions(2)) .setCells({ diff --git a/source/EngineTests/TransmitterTests.cpp b/source/EngineTests/TransmitterTests.cpp index 086f3ef7c..6fd301b88 100644 --- a/source/EngineTests/TransmitterTests.cpp +++ b/source/EngineTests/TransmitterTests.cpp @@ -1,10 +1,10 @@ #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationController.h" #include "IntegrationTestFramework.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/GenomeDescriptions.h" class TransmitterTests : public IntegrationTestFramework @@ -168,7 +168,7 @@ TEST_F(TransmitterTests, distributeToConnectedCells) TEST_F(TransmitterTests, distributeToOtherTransmitterAndConstructor) { - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription().setCells({CellGenomeDescription()})); DataDescription data; data.addCells({ @@ -225,7 +225,7 @@ TEST_F(TransmitterTests, distributeOnlyToActiveConstructors) .setPos({11.0f, 10.0f}) .setMaxConnections(2) .setExecutionOrderNumber(5) - .setCellFunction(ConstructorDescription().setGenome(GenomeDescriptionConverter::convertDescriptionToBytes(genome))), + .setCellFunction(ConstructorDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(genome))), CellDescription().setId(3).setPos({9.0f, 10.0f}).setMaxConnections(1).setExecutionOrderNumber(1).setCellFunction(TransmitterDescription()), }); data.addConnection(1, 2); diff --git a/source/Gui/BrowserWindow.cpp b/source/Gui/BrowserWindow.cpp index 87551df09..802ba10b4 100644 --- a/source/Gui/BrowserWindow.cpp +++ b/source/Gui/BrowserWindow.cpp @@ -14,7 +14,7 @@ #include "Base/Resources.h" #include "Base/StringHelper.h" #include "Base/VersionChecker.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/Serializer.h" #include "EngineInterface/SimulationController.h" @@ -860,7 +860,7 @@ void _BrowserWindow::onDownloadItem(RemoteSimulationData* sim) return; } _editorController->setOn(true); - _editorController->getGenomeEditorWindow()->openTab(GenomeDescriptionConverter::convertBytesToDescription(genome)); + _editorController->getGenomeEditorWindow()->openTab(GenomeDescriptionService::convertBytesToDescription(genome)); } if (VersionChecker::isVersionNewer(sim->version)) { MessageDialog::getInstance().information( diff --git a/source/Gui/CreatorWindow.cpp b/source/Gui/CreatorWindow.cpp index cb93a6299..6a3789445 100644 --- a/source/Gui/CreatorWindow.cpp +++ b/source/Gui/CreatorWindow.cpp @@ -11,7 +11,7 @@ #include "Base/NumberGenerator.h" #include "Base/Math.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "StyleRepository.h" @@ -189,7 +189,7 @@ void _CreatorWindow::onDrawing() pos.x = toFloat(toInt(pos.x)); pos.y = toFloat(toInt(pos.y)); } - return DescriptionHelper::createUnconnectedCircle(DescriptionHelper::CreateUnconnectedCircleParameters() + return DescriptionEditService::createUnconnectedCircle(DescriptionEditService::CreateUnconnectedCircleParameters() .center(pos) .radius(_editorModel->getPencilWidth()) .energy(_energy) @@ -201,7 +201,7 @@ void _CreatorWindow::onDrawing() }; if (_drawing.isEmpty()) { - DescriptionHelper::addIfSpaceAvailable(_drawing, _drawingOccupancy, createAlignedCircle(pos), 0.5f, _simController->getWorldSize()); + DescriptionEditService::addIfSpaceAvailable(_drawing, _drawingOccupancy, createAlignedCircle(pos), 0.5f, _simController->getWorldSize()); _lastDrawPos = pos; } else { auto posDelta = Math::length(pos - _lastDrawPos); @@ -210,15 +210,15 @@ void _CreatorWindow::onDrawing() for (float interDelta = 0; interDelta < posDelta; interDelta += 1.0f) { auto drawPos = lastDrawPos + (pos - lastDrawPos) * interDelta / posDelta; auto toAdd = createAlignedCircle(drawPos); - DescriptionHelper::addIfSpaceAvailable(_drawing, _drawingOccupancy, toAdd, 0.5f, _simController->getWorldSize()); + DescriptionEditService::addIfSpaceAvailable(_drawing, _drawingOccupancy, toAdd, 0.5f, _simController->getWorldSize()); _lastDrawPos = drawPos; } } } - DescriptionHelper::reconnectCells(_drawing, 1.5f); + DescriptionEditService::reconnectCells(_drawing, 1.5f); if (!_makeSticky) { auto origDrawing = _drawing; - DescriptionHelper::removeStickiness(_drawing); + DescriptionEditService::removeStickiness(_drawing); _simController->addAndSelectSimulationData(_drawing); _drawing = origDrawing; } else { @@ -270,7 +270,7 @@ void _CreatorWindow::createRectangle() } auto parameters = _simController->getSimulationParameters(); - auto data = DescriptionHelper::createRect(DescriptionHelper::CreateRectParameters() + auto data = DescriptionEditService::createRect(DescriptionEditService::CreateRectParameters() .width(_rectHorizontalCells) .height(_rectVerticalCells) .cellDistance(_cellDistance) @@ -290,7 +290,7 @@ void _CreatorWindow::createHexagon() if (_layers <= 0) { return; } - DataDescription data = DescriptionHelper::createHex(DescriptionHelper::CreateHexParameters() + DataDescription data = DescriptionEditService::createHex(DescriptionEditService::CreateHexParameters() .layers(_layers) .cellDistance(_cellDistance) .energy(_energy) @@ -335,9 +335,9 @@ void _CreatorWindow::createDisc() } } - DescriptionHelper::reconnectCells(data, _cellDistance * 1.7f); + DescriptionEditService::reconnectCells(data, _cellDistance * 1.7f); if (!_makeSticky) { - DescriptionHelper::removeStickiness(data); + DescriptionEditService::removeStickiness(data); } data.setCenter(getRandomPos()); _simController->addAndSelectSimulationData(data); diff --git a/source/Gui/CreatorWindow.h b/source/Gui/CreatorWindow.h index a0355af95..2f3b5a90e 100644 --- a/source/Gui/CreatorWindow.h +++ b/source/Gui/CreatorWindow.h @@ -1,7 +1,7 @@ #pragma once #include "EngineInterface/Descriptions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "Definitions.h" #include "AlienWindow.h" @@ -61,7 +61,7 @@ class _CreatorWindow : public _AlienWindow //drawing DataDescription _drawing; - DescriptionHelper::Occupancy _drawingOccupancy; + DescriptionEditService::Occupancy _drawingOccupancy; RealVector2D _lastDrawPos; CreationMode _mode = CreationMode_Drawing; diff --git a/source/Gui/EditorController.cpp b/source/Gui/EditorController.cpp index 43b4fc9a4..7ee1f4fe2 100644 --- a/source/Gui/EditorController.cpp +++ b/source/Gui/EditorController.cpp @@ -6,7 +6,7 @@ #include "Base/Math.h" #include "EngineInterface/SimulationController.h" #include "EngineInterface/InspectedEntityIds.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "Viewport.h" #include "StyleRepository.h" #include "EditorModel.h" @@ -127,7 +127,7 @@ void _EditorController::onInspectSelectedObjects() auto selection = _editorModel->getSelectionShallowData(); if (selection.numCells + selection.numParticles <= MaxInspectorWindowsToAdd) { DataDescription selectedData = _simController->getSelectedSimulationData(false); - onInspectObjects(DescriptionHelper::getObjects(selectedData), false); + onInspectObjects(DescriptionEditService::getObjects(selectedData), false); } else { showMessage( "Inspection not possible", @@ -139,7 +139,7 @@ void _EditorController::onInspectSelectedObjects() void _EditorController::onInspectSelectedGenomes() { DataDescription selectedData = _simController->getSelectedSimulationData(true); - auto constructors = DescriptionHelper::getConstructorToMainGenomes(selectedData); + auto constructors = DescriptionEditService::getConstructorToMainGenomes(selectedData); if (constructors.size() > 1) { constructors = {constructors.front()}; } @@ -157,12 +157,12 @@ void _EditorController::onInspectObjects(std::vector } auto origInspectedIds = inspectedIds; for (auto const& entity : entities) { - inspectedIds.insert(DescriptionHelper::getId(entity)); + inspectedIds.insert(DescriptionEditService::getId(entity)); } std::vector newEntities; for (auto const& entity : entities) { - if (origInspectedIds.find(DescriptionHelper::getId(entity)) == origInspectedIds.end()) { + if (origInspectedIds.find(DescriptionEditService::getId(entity)) == origInspectedIds.end()) { newEntities.emplace_back(entity); } } @@ -175,7 +175,7 @@ void _EditorController::onInspectObjects(std::vector RealVector2D center; int num = 0; for (auto const& entity : entities) { - auto entityPos = _viewport->mapWorldToViewPosition(DescriptionHelper::getPos(entity)); + auto entityPos = _viewport->mapWorldToViewPosition(DescriptionEditService::getPos(entity)); center += entityPos; ++num; } @@ -183,7 +183,7 @@ void _EditorController::onInspectObjects(std::vector float maxDistanceFromCenter = 0; for (auto const& entity : entities) { - auto entityPos = _viewport->mapWorldToViewPosition(DescriptionHelper::getPos(entity)); + auto entityPos = _viewport->mapWorldToViewPosition(DescriptionEditService::getPos(entity)); auto distanceFromCenter = toFloat(Math::length(entityPos - center)); maxDistanceFromCenter = std::max(maxDistanceFromCenter, distanceFromCenter); } @@ -192,9 +192,9 @@ void _EditorController::onInspectObjects(std::vector auto factorY = maxDistanceFromCenter == 0 ? 1.0f : viewSize.y / maxDistanceFromCenter / 3.4f; for (auto const& entity : newEntities) { - auto id = DescriptionHelper::getId(entity); + auto id = DescriptionEditService::getId(entity); _editorModel->addInspectedEntity(entity); - auto entityPos = _viewport->mapWorldToViewPosition(DescriptionHelper::getPos(entity)); + auto entityPos = _viewport->mapWorldToViewPosition(DescriptionEditService::getPos(entity)); auto windowPosX = (entityPos.x - center.x) * factorX + center.x; auto windowPosY = (entityPos.y - center.y) * factorY + center.y; windowPosX = std::min(std::max(windowPosX, 0.0f), toFloat(viewSize.x) - 300.0f) + 40.0f; @@ -344,10 +344,10 @@ void _EditorController::processInspectorWindows() } std::vector entityIds; for (auto const& entity : inspectedEntities) { - entityIds.emplace_back(DescriptionHelper::getId(entity)); + entityIds.emplace_back(DescriptionEditService::getId(entity)); } auto inspectedData = _simController->getInspectedSimulationData(entityIds); - auto newInspectedEntities = DescriptionHelper::getObjects(inspectedData); + auto newInspectedEntities = DescriptionEditService::getObjects(inspectedData); _editorModel->setInspectedEntities(newInspectedEntities); inspectorWindows.clear(); diff --git a/source/Gui/EditorModel.cpp b/source/Gui/EditorModel.cpp index c45366996..10095a84c 100644 --- a/source/Gui/EditorModel.cpp +++ b/source/Gui/EditorModel.cpp @@ -1,6 +1,6 @@ #include "EditorModel.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" _EditorModel::_EditorModel(SimulationController const& simController) @@ -47,14 +47,14 @@ CellOrParticleDescription _EditorModel::getInspectedEntity(uint64_t id) const void _EditorModel::addInspectedEntity(CellOrParticleDescription const& entity) { - _inspectedEntityById.emplace(DescriptionHelper::getId(entity), entity); + _inspectedEntityById.emplace(DescriptionEditService::getId(entity), entity); } void _EditorModel::setInspectedEntities(std::vector const& inspectedEntities) { _inspectedEntityById.clear(); for (auto const& entity : inspectedEntities) { - _inspectedEntityById.emplace(DescriptionHelper::getId(entity), entity); + _inspectedEntityById.emplace(DescriptionEditService::getId(entity), entity); } } diff --git a/source/Gui/GenomeEditorWindow.cpp b/source/Gui/GenomeEditorWindow.cpp index 8a5bcf10d..d2c993813 100644 --- a/source/Gui/GenomeEditorWindow.cpp +++ b/source/Gui/GenomeEditorWindow.cpp @@ -10,10 +10,10 @@ #include "Base/GlobalSettings.h" #include "Base/StringHelper.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "EngineInterface/Colors.h" #include "EngineInterface/SimulationParameters.h" -#include "EngineInterface/PreviewDescriptionConverter.h" +#include "EngineInterface/PreviewDescriptionService.h" #include "EngineInterface/Serializer.h" #include "EngineInterface/ShapeGenerator.h" @@ -145,7 +145,7 @@ void _GenomeEditorWindow::processToolbar() ImGui::SameLine(); if (AlienImGui::ToolbarButton(ICON_FA_COPY)) { - _copiedGenome = GenomeDescriptionConverter::convertDescriptionToBytes(selectedTab.genome); + _copiedGenome = GenomeDescriptionService::convertDescriptionToBytes(selectedTab.genome); printOverlayMessage("Genome copied"); } AlienImGui::Tooltip("Copy genome"); @@ -419,7 +419,7 @@ namespace cell.cellFunction = TransmitterGenomeDescription(); } break; case CellFunction_Constructor: { - cell.cellFunction = ConstructorGenomeDescription().setGenome(GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription())); + cell.cellFunction = ConstructorGenomeDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription())); } break; case CellFunction_Sensor: { cell.cellFunction = SensorGenomeDescription(); @@ -431,7 +431,7 @@ namespace cell.cellFunction = AttackerGenomeDescription(); } break; case CellFunction_Injector: { - cell.cellFunction = InjectorGenomeDescription().setGenome(GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription())); + cell.cellFunction = InjectorGenomeDescription().setGenome(GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription())); } break; case CellFunction_Muscle: { cell.cellFunction = MuscleGenomeDescription(); @@ -805,11 +805,11 @@ void _GenomeEditorWindow::processSubGenomeWidgets(TabData const& tab, Descriptio AlienImGui::MonospaceText(content); AlienImGui::HelpMarker(Const::SubGenomeTooltip); if (AlienImGui::Button("Clear")) { - desc.setGenome(GenomeDescriptionConverter::convertDescriptionToBytes(GenomeDescription())); + desc.setGenome(GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription())); } ImGui::SameLine(); if (AlienImGui::Button("Copy")) { - _copiedGenome = desc.isMakeGenomeCopy() ? GenomeDescriptionConverter::convertDescriptionToBytes(tab.genome) : desc.getGenomeData(); + _copiedGenome = desc.isMakeGenomeCopy() ? GenomeDescriptionService::convertDescriptionToBytes(tab.genome) : desc.getGenomeData(); } ImGui::SameLine(); ImGui::BeginDisabled(!_copiedGenome.has_value()); @@ -822,7 +822,7 @@ void _GenomeEditorWindow::processSubGenomeWidgets(TabData const& tab, Descriptio if (AlienImGui::Button("Edit")) { auto genomeToOpen = desc.isMakeGenomeCopy() ? tab.genome - : GenomeDescriptionConverter::convertBytesToDescription(desc.getGenomeData()); + : GenomeDescriptionService::convertBytesToDescription(desc.getGenomeData()); openTab(genomeToOpen, false); } ImGui::SameLine(); @@ -845,7 +845,7 @@ void _GenomeEditorWindow::onOpenGenome() if (!Serializer::deserializeGenomeFromFile(genomeData, firstFilename.string())) { MessageDialog::getInstance().information("Open genome", "The selected file could not be opened."); } else { - openTab(GenomeDescriptionConverter::convertBytesToDescription(genomeData), false); + openTab(GenomeDescriptionService::convertBytesToDescription(genomeData), false); } }); } @@ -859,7 +859,7 @@ void _GenomeEditorWindow::onSaveGenome() _startingPath = firstFilenameCopy.remove_filename().string(); auto const& selectedTab = _tabDatas.at(_selectedTabIndex); - auto genomeData = GenomeDescriptionConverter::convertDescriptionToBytes(selectedTab.genome); + auto genomeData = GenomeDescriptionService::convertDescriptionToBytes(selectedTab.genome); if (!Serializer::serializeGenomeToFile(firstFilename.string(), genomeData)) { MessageDialog::getInstance().information("Save genome", "The selected file could not be saved."); } @@ -936,7 +936,7 @@ void _GenomeEditorWindow::onCreateSpore() pos.y += (toFloat(std::rand()) / RAND_MAX - 0.5f) * 8; auto genomeDesc = getCurrentGenome(); - auto genome = GenomeDescriptionConverter::convertDescriptionToBytes(genomeDesc); + auto genome = GenomeDescriptionService::convertDescriptionToBytes(genomeDesc); auto parameter = _simController->getSimulationParameters(); auto energy = parameter.cellNormalEnergy[_editorModel->getDefaultColorCode()] @@ -959,7 +959,7 @@ void _GenomeEditorWindow::onCreateSpore() void _GenomeEditorWindow::showPreview(TabData& tab) { auto const& genome = _tabDatas.at(_selectedTabIndex).genome; - auto preview = PreviewDescriptionConverter::convert(genome, tab.selectedNode, _simController->getSimulationParameters()); + auto preview = PreviewDescriptionService::convert(genome, tab.selectedNode, _simController->getSimulationParameters()); if (AlienImGui::ShowPreviewDescription(preview, tab.previewZoom, tab.selectedNode)) { _nodeIndexToJump = tab.selectedNode; } diff --git a/source/Gui/ImageToPatternDialog.cpp b/source/Gui/ImageToPatternDialog.cpp index 44b5e3f51..622b97025 100644 --- a/source/Gui/ImageToPatternDialog.cpp +++ b/source/Gui/ImageToPatternDialog.cpp @@ -9,7 +9,7 @@ #include "Base/GlobalSettings.h" #include "Base/NumberGenerator.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "EngineInterface/Colors.h" @@ -112,7 +112,7 @@ void _ImageToPatternDialog::show() } } - DescriptionHelper::reconnectCells(dataDesc, 1 * 1.5f); + DescriptionEditService::reconnectCells(dataDesc, 1 * 1.5f); dataDesc.setCenter(_viewport->getCenterInWorldPos()); _simController->addAndSelectSimulationData(dataDesc); diff --git a/source/Gui/InspectorWindow.cpp b/source/Gui/InspectorWindow.cpp index cdad0484e..9b1a76eb9 100644 --- a/source/Gui/InspectorWindow.cpp +++ b/source/Gui/InspectorWindow.cpp @@ -6,10 +6,10 @@ #include #include -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" -#include "EngineInterface/PreviewDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" +#include "EngineInterface/PreviewDescriptionService.h" #include "StyleRepository.h" #include "Viewport.h" @@ -78,7 +78,7 @@ void _InspectorWindow::process() processParticle(std::get(entity)); } ImDrawList* drawList = ImGui::GetBackgroundDrawList(); - auto entityPos = _viewport->mapWorldToViewPosition(DescriptionHelper::getPos(entity)); + auto entityPos = _viewport->mapWorldToViewPosition(DescriptionEditService::getPos(entity)); auto factor = StyleRepository::getInstance().scale(1); drawList->AddLine( @@ -376,20 +376,20 @@ void _InspectorWindow::processCellGenomeTab(Description& desc) if (ImGui::TreeNodeEx("Data", TreeNodeFlags)) { if (ImGui::BeginChild("##child", ImVec2(0, scale(200)), true, ImGuiWindowFlags_HorizontalScrollbar)) { - auto genomDesc = GenomeDescriptionConverter::convertBytesToDescription(desc.genome); - auto previewDesc = PreviewDescriptionConverter::convert(genomDesc, std::nullopt, parameters); + auto genomDesc = GenomeDescriptionService::convertBytesToDescription(desc.genome); + auto previewDesc = PreviewDescriptionService::convert(genomDesc, std::nullopt, parameters); std::optional selectedNodeDummy; AlienImGui::ShowPreviewDescription(previewDesc, _genomeZoom, selectedNodeDummy); } ImGui::EndChild(); if (AlienImGui::Button("Edit")) { - _genomeEditorWindow->openTab(GenomeDescriptionConverter::convertBytesToDescription(desc.genome)); + _genomeEditorWindow->openTab(GenomeDescriptionService::convertBytesToDescription(desc.genome)); } ImGui::SameLine(); if (AlienImGui::Button(AlienImGui::ButtonParameters().buttonText("Inject from editor").textWidth(ImGui::GetContentRegionAvail().x))) { printOverlayMessage("Genome injected"); - desc.genome = GenomeDescriptionConverter::convertDescriptionToBytes(_genomeEditorWindow->getCurrentGenome()); + desc.genome = GenomeDescriptionService::convertDescriptionToBytes(_genomeEditorWindow->getCurrentGenome()); if constexpr (std::is_same()) { desc.genomeCurrentNodeIndex = 0; } @@ -398,7 +398,7 @@ void _InspectorWindow::processCellGenomeTab(Description& desc) } if (ImGui::TreeNodeEx("Properties (entire genome)", TreeNodeFlags)) { - auto numNodes = toInt(GenomeDescriptionConverter::getNumNodesRecursively(desc.genome, true)); + auto numNodes = toInt(GenomeDescriptionService::getNumNodesRecursively(desc.genome, true)); AlienImGui::InputInt( AlienImGui::InputIntParameters() .name("Number of cells") @@ -424,7 +424,7 @@ void _InspectorWindow::processCellGenomeTab(Description& desc) if (ImGui::TreeNodeEx("Properties (principal genome part)", TreeNodeFlags)) { - auto genomeDesc = GenomeDescriptionConverter::convertBytesToDescription(desc.genome); + auto genomeDesc = GenomeDescriptionService::convertBytesToDescription(desc.genome); auto numRepetitions = genomeDesc.header.numRepetitions; AlienImGui::InputInt( AlienImGui::InputIntParameters() @@ -756,14 +756,14 @@ void _InspectorWindow::validationAndCorrection(CellDescription& cell) const switch (cell.getCellFunctionType()) { case CellFunction_Constructor: { auto& constructor = std::get(*cell.cellFunction); - auto numNodes = GenomeDescriptionConverter::convertNodeAddressToNodeIndex(constructor.genome, toInt(constructor.genome.size())); + auto numNodes = GenomeDescriptionService::convertNodeAddressToNodeIndex(constructor.genome, toInt(constructor.genome.size())); if (numNodes > 0) { constructor.genomeCurrentNodeIndex = ((constructor.genomeCurrentNodeIndex % numNodes) + numNodes) % numNodes; } else { constructor.genomeCurrentNodeIndex = 0; } - auto numRepetitions = GenomeDescriptionConverter::getNumRepetitions(constructor.genome); + auto numRepetitions = GenomeDescriptionService::getNumRepetitions(constructor.genome); if (numRepetitions != std::numeric_limits::max()) { constructor.genomeCurrentRepetition = ((constructor.genomeCurrentRepetition % numRepetitions) + numRepetitions) % numRepetitions; } else { diff --git a/source/Gui/MassOperationsDialog.cpp b/source/Gui/MassOperationsDialog.cpp index 3d0926f9d..e88ef8803 100644 --- a/source/Gui/MassOperationsDialog.cpp +++ b/source/Gui/MassOperationsDialog.cpp @@ -5,7 +5,7 @@ #include "Base/Definitions.h" #include "EngineInterface/Colors.h" #include "EngineInterface/Descriptions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "AlienImGui.h" @@ -168,19 +168,19 @@ void _MassOperationsDialog::onExecute() return result; }; if (_randomizeCellColors) { - DescriptionHelper::randomizeCellColors(content, getColorVector(_checkedCellColors)); + DescriptionEditService::randomizeCellColors(content, getColorVector(_checkedCellColors)); } if (_randomizeGenomeColors) { - DescriptionHelper::randomizeGenomeColors(content, getColorVector(_checkedGenomeColors)); + DescriptionEditService::randomizeGenomeColors(content, getColorVector(_checkedGenomeColors)); } if (_randomizeEnergies) { - DescriptionHelper::randomizeEnergies(content, _minEnergy, _maxEnergy); + DescriptionEditService::randomizeEnergies(content, _minEnergy, _maxEnergy); } if (_randomizeAges) { - DescriptionHelper::randomizeAges(content, _minAge, _maxAge); + DescriptionEditService::randomizeAges(content, _minAge, _maxAge); } if (_randomizeCountdowns) { - DescriptionHelper::randomizeCountdowns(content, _minCountdown, _maxCountdown); + DescriptionEditService::randomizeCountdowns(content, _minCountdown, _maxCountdown); } if (_restrictToSelectedClusters) { diff --git a/source/Gui/MultiplierWindow.cpp b/source/Gui/MultiplierWindow.cpp index 9b2ab6e29..984764a18 100644 --- a/source/Gui/MultiplierWindow.cpp +++ b/source/Gui/MultiplierWindow.cpp @@ -150,11 +150,11 @@ void _MultiplierWindow::onBuild() _origSelection = _simController->getSelectedSimulationData(true); auto multiplicationResult = [&] { if (_mode == MultiplierMode_Grid) { - return DescriptionHelper::gridMultiply(_origSelection, _gridParameters); + return DescriptionEditService::gridMultiply(_origSelection, _gridParameters); } else { auto data = _simController->getSimulationData(); auto overlappingCheckSuccessful = true; - auto result = DescriptionHelper::randomMultiply( + auto result = DescriptionEditService::randomMultiply( _origSelection, _randomParameters, _simController->getWorldSize(), std::move(data), overlappingCheckSuccessful); if (!overlappingCheckSuccessful) { MessageDialog::getInstance().information("Random multiplication", "Non-overlapping copies could not be created."); diff --git a/source/Gui/MultiplierWindow.h b/source/Gui/MultiplierWindow.h index 200fefe7e..c171272b8 100644 --- a/source/Gui/MultiplierWindow.h +++ b/source/Gui/MultiplierWindow.h @@ -1,7 +1,7 @@ #pragma once #include "EngineInterface/Definitions.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SelectionShallowData.h" #include "Definitions.h" @@ -35,8 +35,8 @@ class _MultiplierWindow : public _AlienWindow MultiplierMode _mode = MultiplierMode_Grid; - DescriptionHelper::GridMultiplyParameters _gridParameters; - DescriptionHelper::RandomMultiplyParameters _randomParameters; + DescriptionEditService::GridMultiplyParameters _gridParameters; + DescriptionEditService::RandomMultiplyParameters _randomParameters; DataDescription _origSelection; std::optional _selectionDataAfterMultiplication; diff --git a/source/Gui/PatternEditorWindow.cpp b/source/Gui/PatternEditorWindow.cpp index 441516940..1e91fb067 100644 --- a/source/Gui/PatternEditorWindow.cpp +++ b/source/Gui/PatternEditorWindow.cpp @@ -8,7 +8,7 @@ #include "Base/GlobalSettings.h" #include "EngineInterface/Colors.h" #include "EngineInterface/ShallowUpdateSelectionData.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "EditorModel.h" @@ -391,7 +391,7 @@ void _PatternEditorWindow::onPaste() auto data = *_copiedSelection; auto center = _viewport->getCenterInWorldPos(); data.setCenter(center); - DescriptionHelper::generateNewCreatureIds(data); + DescriptionEditService::generateNewCreatureIds(data); _simController->addAndSelectSimulationData(data); _editorModel->update(); } @@ -414,7 +414,7 @@ void _PatternEditorWindow::onGenerateExecutionOrderNumbers() std::unordered_set cellIds = dataWithoutClusters.getCellIds(); auto parameters = _simController->getSimulationParameters(); - DescriptionHelper::generateExecutionOrderNumbers(dataWithClusters, cellIds, parameters.cellNumExecutionOrderNumbers); + DescriptionEditService::generateExecutionOrderNumbers(dataWithClusters, cellIds, parameters.cellNumExecutionOrderNumbers); _simController->removeSelectedObjects(true); _simController->addAndSelectSimulationData(dataWithClusters); diff --git a/source/Gui/ResizeWorldDialog.cpp b/source/Gui/ResizeWorldDialog.cpp index f2b5c49f2..9f0a67a44 100644 --- a/source/Gui/ResizeWorldDialog.cpp +++ b/source/Gui/ResizeWorldDialog.cpp @@ -2,7 +2,7 @@ #include "ResizeWorldDialog.h" -#include "EngineInterface/DescriptionHelper.h" +#include "EngineInterface/DescriptionEditService.h" #include "EngineInterface/SimulationController.h" #include "AlienImGui.h" @@ -84,9 +84,9 @@ void _ResizeWorldDialog::onResizing() _simController->newSimulation(timestep, generalSettings, parameters); - DescriptionHelper::correctConnections(content, {_width, _height}); + DescriptionEditService::correctConnections(content, {_width, _height}); if (_scaleContent) { - DescriptionHelper::duplicate(content, origWorldSize, {_width, _height}); + DescriptionEditService::duplicate(content, origWorldSize, {_width, _height}); } _simController->setClusteredSimulationData(content); } diff --git a/source/Gui/UploadSimulationDialog.cpp b/source/Gui/UploadSimulationDialog.cpp index dd092f3e9..cd319f6ef 100644 --- a/source/Gui/UploadSimulationDialog.cpp +++ b/source/Gui/UploadSimulationDialog.cpp @@ -5,7 +5,7 @@ #include "Base/GlobalSettings.h" #include "EngineInterface/Serializer.h" #include "EngineInterface/SimulationController.h" -#include "EngineInterface/GenomeDescriptionConverter.h" +#include "EngineInterface/GenomeDescriptionService.h" #include "AlienImGui.h" #include "MessageDialog.h" @@ -142,8 +142,8 @@ void _UploadSimulationDialog::onUpload() showMessage("Upload genome", "The is no valid genome in the genome editor selected."); return; } - auto genomeData = GenomeDescriptionConverter::convertDescriptionToBytes(genome); - numObjects = GenomeDescriptionConverter::getNumNodesRecursively(genomeData, true); + auto genomeData = GenomeDescriptionService::convertDescriptionToBytes(genome); + numObjects = GenomeDescriptionService::getNumNodesRecursively(genomeData, true); if (!Serializer::serializeGenomeToString(mainData, genomeData)) { showMessage("Upload genome", "The genome could not be serialized for uploading.");