mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-27 14:39:20 -06:00
Make use of referenced verifier for Renderables
Adapt HTML documentation generation
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
@@ -42,22 +44,37 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Documentation Renderable::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
|
||||
return {
|
||||
"Renderable",
|
||||
"renderable",
|
||||
{
|
||||
{
|
||||
KeyType,
|
||||
new StringAnnotationVerifier("A valid Renderable created by a factory"),
|
||||
"This key specifies the type of Renderable that gets created. It has to be one"
|
||||
"of the valid Renderables that are available for creation (see the "
|
||||
"FactoryDocumentation for a list of possible Renderables), which depends on "
|
||||
"the configration of the application",
|
||||
Optional::No
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary) {
|
||||
// The name is passed down from the SceneGraphNode
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
assert(success);
|
||||
ghoul_assert(success, "The SceneGraphNode did not set the 'name' key");
|
||||
|
||||
std::string renderableType;
|
||||
success = dictionary.getValue(KeyType, renderableType);
|
||||
documentation::testSpecificationAndThrow(Documentation(), dictionary, "Renderable");
|
||||
|
||||
if (!success) {
|
||||
LERROR("Renderable '" << name << "' did not have key '" << KeyType << "'");
|
||||
return nullptr;
|
||||
}
|
||||
std::string renderableType = dictionary.value<std::string>(KeyType);
|
||||
|
||||
ghoul::TemplateFactory<Renderable>* factory
|
||||
= FactoryManager::ref().factory<Renderable>();
|
||||
auto factory = FactoryManager::ref().factory<Renderable>();
|
||||
Renderable* result = factory->create(renderableType, dictionary);
|
||||
if (result == nullptr) {
|
||||
LERROR("Failed to create a Renderable object of type '" << renderableType << "'");
|
||||
|
||||
Reference in New Issue
Block a user