-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix local seed type and add get function for int
- Loading branch information
1 parent
5b94714
commit 7c9889a
Showing
5 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright (C) 2018 - 2021 by the authors of the World Builder code. | ||
This file is part of the World Builder. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef WORLD_BUILDER_TYPES_INT_H | ||
#define WORLD_BUILDER_TYPES_INT_H | ||
|
||
|
||
#include "world_builder/types/interface.h" | ||
|
||
|
||
namespace WorldBuilder | ||
{ | ||
class Parameters; | ||
|
||
namespace Types | ||
{ | ||
|
||
/** | ||
* This class represents a bool value with documentation | ||
*/ | ||
class Int final: public Interface | ||
{ | ||
public: | ||
/** | ||
* A constructor for the load_entry function | ||
*/ | ||
Int(int default_value = 0); | ||
|
||
/** | ||
* Copy constructor | ||
*/ | ||
Int(Int const &other); | ||
|
||
/** | ||
* Destructor | ||
*/ | ||
~Int() override final; | ||
|
||
|
||
/** | ||
* Todo | ||
*/ | ||
void write_schema(Parameters &prm, | ||
const std::string &name, | ||
const std::string &documentation) const override final; | ||
|
||
unsigned int value {0}; | ||
unsigned int default_value; | ||
|
||
protected: | ||
/** | ||
* This implements the actual cloneing for the clone function in the base class. | ||
*/ | ||
Int *clone_impl() const override final | ||
{ | ||
return new Int(*this); | ||
}; | ||
private: | ||
|
||
}; | ||
} // namespace Types | ||
} // namespace WorldBuilder | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright (C) 2018 - 2021 by the authors of the World Builder code. | ||
This file is part of the World Builder. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
#include "world_builder/types/int.h" | ||
|
||
#include "world_builder/parameters.h" | ||
|
||
namespace WorldBuilder | ||
{ | ||
namespace Types | ||
{ | ||
Int::Int(int default_value_) | ||
: | ||
|
||
default_value(default_value_) | ||
{ | ||
this->type_name = Types::type::Int; | ||
} | ||
|
||
|
||
Int::Int(Int const &other) | ||
: | ||
value(other.value), | ||
default_value(other.default_value) | ||
{ | ||
this->type_name = Types::type::Int; | ||
} | ||
|
||
Int::~Int () | ||
= default; | ||
|
||
|
||
void | ||
Int::write_schema(Parameters &prm, | ||
const std::string &name, | ||
const std::string &documentation) const | ||
{ | ||
using namespace rapidjson; | ||
Document &declarations = prm.declarations; | ||
|
||
const std::string base = prm.get_full_json_path() + "/" + name; | ||
Pointer((base + "/default value").c_str()).Set(declarations,default_value); | ||
Pointer((base + "/type").c_str()).Set(declarations,"integer"); | ||
Pointer((base + "/description").c_str()).Set(declarations,documentation.c_str()); | ||
|
||
} | ||
} // namespace Types | ||
} // namespace WorldBuilder | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters