mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-30 07:49:31 -05:00
Use string_views in more query functions
This commit is contained in:
+1
-1
Submodule ext/ghoul updated: 90240b2d5b...faa5727b46
@@ -159,7 +159,7 @@ public:
|
||||
* \return If the Property cannot be found, `nullptr` is returned, otherwise the
|
||||
* pointer to the Property is returned
|
||||
*/
|
||||
Property* property(const std::string& uri) const;
|
||||
Property* property(std::string_view uri) const;
|
||||
|
||||
/**
|
||||
* Retrieves a PropertyOwner identified by \p uri from this PropertyOwner. If \p uri
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
* \return If the PropertyOwner cannot be found, `nullptr` is returned, otherwise the
|
||||
* pointer to the PropertyOwner is returned
|
||||
*/
|
||||
PropertyOwner* propertyOwner(const std::string& uri) const;
|
||||
PropertyOwner* propertyOwner(std::string_view uri) const;
|
||||
|
||||
/**
|
||||
* Returns a uri for this PropertyOwner. This is created by looking up all the owners
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
* \param identifier The identifier of the sub-owner that should be returned
|
||||
* \return The PropertyOwner with the given \p identifier, or `nullptr`
|
||||
*/
|
||||
PropertyOwner* propertySubOwner(const std::string& identifier) const;
|
||||
PropertyOwner* propertySubOwner(std::string_view identifier) const;
|
||||
|
||||
/**
|
||||
* Returns `true` if this PropertyOwner owns a sub-owner with the provided
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef __OPENSPACE_CORE___QUERY___H__
|
||||
#define __OPENSPACE_CORE___QUERY___H__
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
@@ -39,10 +39,10 @@ class IswaGroup;
|
||||
class ScreenSpaceRenderable;
|
||||
|
||||
Scene* sceneGraph();
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name);
|
||||
const Renderable* renderable(const std::string& name);
|
||||
properties::Property* property(const std::string& uri);
|
||||
properties::PropertyOwner* propertyOwner(const std::string& uri);
|
||||
SceneGraphNode* sceneGraphNode(std::string_view name);
|
||||
const Renderable* renderable(std::string_view name);
|
||||
properties::Property* property(std::string_view uri);
|
||||
properties::PropertyOwner* propertyOwner(std::string_view uri);
|
||||
const std::vector<properties::Property*>& allProperties();
|
||||
const std::vector<properties::PropertyOwner*>& allPropertyOwners();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <ghoul/misc/easing.h>
|
||||
#include <ghoul/misc/map.h>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
* Return the scenegraph node with the specified name or `nullptr` if that name does
|
||||
* not exist.
|
||||
*/
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
SceneGraphNode* sceneGraphNode(std::string_view name) const;
|
||||
|
||||
/**
|
||||
* Add a node and all its children to the scene.
|
||||
@@ -137,11 +138,6 @@ public:
|
||||
*/
|
||||
const std::vector<SceneGraphNode*>& allSceneGraphNodes() const;
|
||||
|
||||
/**
|
||||
* Returns a map from identifier to scene graph node.
|
||||
*/
|
||||
const std::unordered_map<std::string, SceneGraphNode*>& nodesByIdentifier() const;
|
||||
|
||||
/**
|
||||
* Load a scene graph node from a dictionary and return it.
|
||||
*/
|
||||
@@ -268,7 +264,6 @@ private:
|
||||
*/
|
||||
void propertyPushProfileValueToLua(ghoul::lua::LuaState& L, const std::string& value);
|
||||
|
||||
|
||||
/**
|
||||
* Update dependencies.
|
||||
*/
|
||||
@@ -278,7 +273,11 @@ private:
|
||||
std::unique_ptr<Camera> _camera;
|
||||
std::vector<SceneGraphNode*> _topologicallySortedNodes;
|
||||
std::vector<SceneGraphNode*> _circularNodes;
|
||||
std::unordered_map<std::string, SceneGraphNode*> _nodesByIdentifier;
|
||||
std::unordered_map<
|
||||
std::string, SceneGraphNode*,
|
||||
transparent_string_hash,
|
||||
std::equal_to<>
|
||||
> _nodesByIdentifier;
|
||||
bool _dirtyNodeRegistry = false;
|
||||
SceneGraphNode _rootNode;
|
||||
std::unique_ptr<SceneInitializer> _initializer;
|
||||
|
||||
@@ -105,7 +105,7 @@ std::vector<PropertyOwner*> PropertyOwner::subownersRecursive() const {
|
||||
return subowners;
|
||||
}
|
||||
|
||||
Property* PropertyOwner::property(const std::string& uri) const {
|
||||
Property* PropertyOwner::property(std::string_view uri) const {
|
||||
auto it = std::find_if(
|
||||
_properties.begin(),
|
||||
_properties.end(),
|
||||
@@ -121,8 +121,8 @@ Property* PropertyOwner::property(const std::string& uri) const {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
const std::string ownerName = uri.substr(0, ownerSeparator);
|
||||
const std::string propertyName = uri.substr(ownerSeparator + 1);
|
||||
const std::string_view ownerName = uri.substr(0, ownerSeparator);
|
||||
const std::string_view propertyName = uri.substr(ownerSeparator + 1);
|
||||
|
||||
PropertyOwner* owner = propertySubOwner(ownerName);
|
||||
if (!owner) {
|
||||
@@ -139,7 +139,7 @@ Property* PropertyOwner::property(const std::string& uri) const {
|
||||
}
|
||||
}
|
||||
|
||||
PropertyOwner* PropertyOwner::propertyOwner(const std::string& uri) const {
|
||||
PropertyOwner* PropertyOwner::propertyOwner(std::string_view uri) const {
|
||||
PropertyOwner* directChild = propertySubOwner(uri);
|
||||
if (directChild) {
|
||||
return directChild;
|
||||
@@ -153,8 +153,8 @@ PropertyOwner* PropertyOwner::propertyOwner(const std::string& uri) const {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
const std::string parentName = uri.substr(0, ownerSeparator);
|
||||
const std::string ownerName = uri.substr(ownerSeparator + 1);
|
||||
const std::string_view parentName = uri.substr(0, ownerSeparator);
|
||||
const std::string_view ownerName = uri.substr(ownerSeparator + 1);
|
||||
|
||||
PropertyOwner* owner = propertySubOwner(parentName);
|
||||
return owner ? owner->propertyOwner(ownerName) : nullptr;
|
||||
@@ -205,7 +205,7 @@ const std::vector<PropertyOwner*>& PropertyOwner::propertySubOwners() const {
|
||||
return _subOwners;
|
||||
}
|
||||
|
||||
PropertyOwner* PropertyOwner::propertySubOwner(const std::string& identifier) const {
|
||||
PropertyOwner* PropertyOwner::propertySubOwner(std::string_view identifier) const {
|
||||
std::vector<PropertyOwner*>::const_iterator it = std::find_if(
|
||||
_subOwners.begin(),
|
||||
_subOwners.end(),
|
||||
|
||||
+4
-4
@@ -35,7 +35,7 @@ Scene* sceneGraph() {
|
||||
return global::renderEngine->scene();
|
||||
}
|
||||
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) {
|
||||
SceneGraphNode* sceneGraphNode(std::string_view name) {
|
||||
const Scene* graph = sceneGraph();
|
||||
if (!graph) {
|
||||
return nullptr;
|
||||
@@ -43,7 +43,7 @@ SceneGraphNode* sceneGraphNode(const std::string& name) {
|
||||
return graph->sceneGraphNode(name);
|
||||
}
|
||||
|
||||
const Renderable* renderable(const std::string& name) {
|
||||
const Renderable* renderable(std::string_view name) {
|
||||
SceneGraphNode* node = sceneGraphNode(name);
|
||||
if (!node) {
|
||||
return nullptr;
|
||||
@@ -51,12 +51,12 @@ const Renderable* renderable(const std::string& name) {
|
||||
return node->renderable();
|
||||
}
|
||||
|
||||
properties::Property* property(const std::string& uri) {
|
||||
properties::Property* property(std::string_view uri) {
|
||||
properties::Property* property = global::rootPropertyOwner->property(uri);
|
||||
return property;
|
||||
}
|
||||
|
||||
properties::PropertyOwner* propertyOwner(const std::string& uri) {
|
||||
properties::PropertyOwner* propertyOwner(std::string_view uri) {
|
||||
properties::PropertyOwner* property = global::rootPropertyOwner->propertyOwner(uri);
|
||||
return property;
|
||||
}
|
||||
|
||||
+1
-5
@@ -524,10 +524,6 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) {
|
||||
}
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, SceneGraphNode*>& Scene::nodesByIdentifier() const {
|
||||
return _nodesByIdentifier;
|
||||
}
|
||||
|
||||
SceneGraphNode* Scene::root() {
|
||||
return &_rootNode;
|
||||
}
|
||||
@@ -536,7 +532,7 @@ const SceneGraphNode* Scene::root() const {
|
||||
return &_rootNode;
|
||||
}
|
||||
|
||||
SceneGraphNode* Scene::sceneGraphNode(const std::string& name) const {
|
||||
SceneGraphNode* Scene::sceneGraphNode(std::string_view name) const {
|
||||
const auto it = _nodesByIdentifier.find(name);
|
||||
if (it != _nodesByIdentifier.end()) {
|
||||
return it->second;
|
||||
|
||||
Reference in New Issue
Block a user