Antkeeper  0.0.1
nest-site-loader.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
25 #include <engine/math/angles.hpp>
26 #include <engine/math/numbers.hpp>
27 #include <stdexcept>
28 
29 using namespace ::ant;
30 
31 static void deserialize_nest_site_phene(phene::nest_site& phene, const json& phene_element, resource_manager* resource_manager)
32 {
33 
34 }
35 
36 template <>
37 gene::nest_site* resource_loader<gene::nest_site>::load(resource_manager* resource_manager, PHYSFS_File* file, const std::filesystem::path& path)
38 {
39  // Load JSON data
41 
42  // Validate gene file
43  auto nest_site_element = data->find("nest_site");
44  if (nest_site_element == data->end())
45  throw std::runtime_error("Invalid nest site gene.");
46 
47  // Allocate gene
49 
50  // Deserialize gene
51  gene::deserialize_gene(*nest_site, &deserialize_nest_site_phene, *nest_site_element, resource_manager);
52 
53  // Free JSON data
54  delete data;
55 
56  return nest_site;
57 }
static T * load(resource_manager *resourceManager, PHYSFS_File *file, const std::filesystem::path &path)
Loads resource data.
Loads resources.
nlohmann::json json
JSON data.
Definition: json.hpp:26
void deserialize_gene(monophenic_gene< T > &gene, void(*deserialize_phene)(T &, const json &, resource_manager *), const json &gene_element, resource_manager *resource_manager)
Deserializes a gene.
Definition: gene-loader.hpp:43
nest_site
Colony nest site phene.
Definition: caste.hpp:25