mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-26 06:49:09 -06:00
Merge branch 'master' into feature/animation-fixes
* Resolve conflicts in scene.cpp
This commit is contained in:
@@ -175,7 +175,7 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::Verification;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -290,7 +290,7 @@ TestResult NotInListVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::Verification;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -346,7 +346,7 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::WrongType;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -363,7 +363,7 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::Verification;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -405,7 +405,7 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::WrongType;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -419,7 +419,7 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
o.offender = key;
|
||||
o.reason = TestResult::Offense::Reason::Verification;
|
||||
r.offenses.push_back(o);
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
else {
|
||||
return { true, {}, {} };
|
||||
|
||||
@@ -89,6 +89,7 @@ struct Configuration {
|
||||
|
||||
bool isCheckingOpenGLState = false;
|
||||
bool isLoggingOpenGLCalls = false;
|
||||
bool isPrintingEvents = false;
|
||||
|
||||
float shutdownCountdown = 0.f;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace openspace {
|
||||
class Dashboard;
|
||||
class DeferredcasterManager;
|
||||
class DownloadManager;
|
||||
class EventEngine;
|
||||
class LuaConsole;
|
||||
class MemoryManager;
|
||||
class MissionManager;
|
||||
@@ -74,6 +75,7 @@ inline ghoul::fontrendering::FontManager* fontManager;
|
||||
inline Dashboard* dashboard;
|
||||
inline DeferredcasterManager* deferredcasterManager;
|
||||
inline DownloadManager* downloadManager;
|
||||
inline EventEngine* eventEngine;
|
||||
inline LuaConsole* luaConsole;
|
||||
inline MemoryManager* memoryManager;
|
||||
inline MissionManager* missionManager;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_CORE___OPENSPACEENGINE___H__
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/scene/profile.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
@@ -117,6 +118,8 @@ private:
|
||||
std::string generateFilePath(std::string openspaceRelativePath);
|
||||
void resetPropertyChangeFlagsOfSubowners(openspace::properties::PropertyOwner* po);
|
||||
|
||||
properties::BoolProperty _printEvents;
|
||||
|
||||
std::unique_ptr<Scene> _scene;
|
||||
std::unique_ptr<AssetManager> _assetManager;
|
||||
bool _shouldAbortLoading = false;
|
||||
|
||||
395
include/openspace/events/event.h
Normal file
395
include/openspace/events/event.h
Normal file
@@ -0,0 +1,395 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___EVENT___H__
|
||||
#define __OPENSPACE_CORE___EVENT___H__
|
||||
|
||||
#include <openspace/util/tstring.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace properties { class Property; }
|
||||
|
||||
class Camera;
|
||||
class Layer;
|
||||
class Profile;
|
||||
class SceneGraphNode;
|
||||
class ScreenSpaceRenderable;
|
||||
class Time;
|
||||
} // namespace openspace
|
||||
|
||||
namespace openspace::events {
|
||||
|
||||
struct Event {
|
||||
// Steps to add a new event type:
|
||||
// 1. Add a new entry into this enum list
|
||||
// 2. Create a new subclass of Event in this file with a constructor that sets the
|
||||
// Event's `type` to this new enum entry
|
||||
// 3. In the cpp file, add a new `log` message that takes the new type as an argument
|
||||
// and that prints something useful when the log is encountered and the user wants
|
||||
// to see all events.
|
||||
// 4. Add a new case into the logAllEvents function that handles the new enum entry
|
||||
// 5. If the new event type has any parameters it takes in its constructor, go into
|
||||
// the `toParameter` function and add a case label for the new enum type and
|
||||
// return a dictionary with these parameters. This dictionary is passed to actions
|
||||
// if they are triggered by events
|
||||
// 6. Add the new enum entry into the `toString` and `fromString` methods
|
||||
enum class Type {
|
||||
SceneGraphNodeAdded,
|
||||
SceneGraphNodeRemoved,
|
||||
ParallelConnection,
|
||||
ProfileLoadingFinished,
|
||||
ApplicationShutdown,
|
||||
ScreenSpaceRenderableAdded,
|
||||
ScreenSpaceRenderableRemoved,
|
||||
CameraFocusTransition,
|
||||
TimeOfInterestReached,
|
||||
MissionEventReached,
|
||||
PlanetEclipsed,
|
||||
InterpolationFinished,
|
||||
FocusNodeChanged,
|
||||
LayerAdded,
|
||||
LayerRemoved,
|
||||
SessionRecordingPlayback,
|
||||
Custom
|
||||
};
|
||||
constexpr explicit Event(Type type_) : type(type_) {}
|
||||
|
||||
const Type type;
|
||||
const Event* next = nullptr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* asType(Event* e) {
|
||||
ghoul_assert(e->type == T::Type, "Wrong type requested, check 'isType'");
|
||||
return static_cast<T*>(e);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool isType(Event* e) {
|
||||
return e->type == T::Type;
|
||||
}
|
||||
|
||||
std::string_view toString(Event::Type type);
|
||||
Event::Type fromString(std::string_view str);
|
||||
|
||||
ghoul::Dictionary toParameter(const Event& e);
|
||||
|
||||
void logAllEvents(const Event* e);
|
||||
|
||||
//
|
||||
// Events
|
||||
//
|
||||
|
||||
/**
|
||||
* This event is created whenever a new scene graph node is added to the system. By the
|
||||
* time this event is signalled, the scene graph node has already been created and added
|
||||
* to the scene.
|
||||
*
|
||||
* \param Node The identifier of the node that was added
|
||||
*/
|
||||
struct EventSceneGraphNodeAdded : public Event {
|
||||
static const Type Type = Event::Type::SceneGraphNodeAdded;
|
||||
|
||||
explicit EventSceneGraphNodeAdded(const SceneGraphNode* node_);
|
||||
const tstring node;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created whenever a scene graph node was removed. By the time this event
|
||||
* is signalled, the scene graph node has already been removed.
|
||||
*
|
||||
* \param Node The identifier of that node that was removed
|
||||
*/
|
||||
struct EventSceneGraphNodeRemoved : public Event {
|
||||
static const Type Type = Event::Type::SceneGraphNodeRemoved;
|
||||
|
||||
explicit EventSceneGraphNodeRemoved(const SceneGraphNode* node_);
|
||||
const tstring node;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created whenever something in the parallel connection subsystem changes.
|
||||
* The new state is sent as an argument with this event.
|
||||
*
|
||||
* \param State The new state of the parallel connection system; is one of `Established`,
|
||||
* `Lost`, `HostshipGained`, or `HostshipLost`
|
||||
*/
|
||||
struct EventParallelConnection : public Event {
|
||||
static const Type Type = Event::Type::ParallelConnection;
|
||||
|
||||
enum class State : uint8_t {
|
||||
Established,
|
||||
Lost,
|
||||
HostshipGained,
|
||||
HostshipLost
|
||||
};
|
||||
explicit EventParallelConnection(State state_);
|
||||
State state;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when the loading of a profile is finished. This is emitted
|
||||
* regardless of whether it is the initial profile, or any subsequent profile is loaded.
|
||||
*/
|
||||
struct EventProfileLoadingFinished : public Event {
|
||||
static const Type Type = Event::Type::ProfileLoadingFinished;
|
||||
|
||||
EventProfileLoadingFinished();
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created whenever some information about the application shutdown sequence
|
||||
* changes. This can either be that the seqeuence started, was aborted, or is finished,
|
||||
* which means that OpenSpace is just about the shutdown.
|
||||
*
|
||||
* \param State The next state of the application shutdown sequence; is one of `Started`,
|
||||
* `Aborted`, or `Finished`
|
||||
*/
|
||||
struct EventApplicationShutdown : public Event {
|
||||
static const Type Type = Event::Type::ApplicationShutdown;
|
||||
|
||||
enum class State : uint8_t {
|
||||
Started,
|
||||
Aborted,
|
||||
Finished
|
||||
};
|
||||
|
||||
explicit EventApplicationShutdown(State state_);
|
||||
const State state;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when a new screenspace renderable has been created. By the time
|
||||
* this event is craeted, the screenspace renderable is already registered and available.
|
||||
*
|
||||
* \param Renderable The identifier of the new screenspace renderable that was just added
|
||||
* to the system
|
||||
*/
|
||||
struct EventScreenSpaceRenderableAdded : public Event {
|
||||
static const Type Type = Event::Type::ScreenSpaceRenderableAdded;
|
||||
|
||||
explicit EventScreenSpaceRenderableAdded(const ScreenSpaceRenderable* renderable_);
|
||||
const tstring renderable;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when a screenspace renderable has been removed from the system.
|
||||
* When this event is created, the screenspace renderable has already been removed and is
|
||||
* no longer available
|
||||
*
|
||||
* \param Renderable The identifier of the screenspace renderable that was removed
|
||||
*/
|
||||
struct EventScreenSpaceRenderableRemoved : public Event {
|
||||
static const Type Type = Event::Type::ScreenSpaceRenderableRemoved;
|
||||
|
||||
explicit EventScreenSpaceRenderableRemoved(const ScreenSpaceRenderable* renderable_);
|
||||
const tstring renderable;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when the camera transitions between different interaction sphere
|
||||
* distances. Right now, only movement relative to camera's focus node is considered.
|
||||
* Each scene graph node has an interaction sphere radius that serves as the reference
|
||||
* distance for all spheres.
|
||||
```
|
||||
Diagram of events for a camera moving from right-to-left. Interaction sphere is 'O' in
|
||||
middle, and ')' are spherical boundaries. The approach factor, reach factor, and
|
||||
interaction sphere radius are all taken from the current focus node.
|
||||
|
||||
|<------------------->| Approach factor * Interaction sphere
|
||||
|<------>| Reach Factor * Interaction sphere
|
||||
|
||||
( ( O ) )
|
||||
^ ^ ^ ^
|
||||
Exiting Receding Reaching Approaching
|
||||
```
|
||||
*
|
||||
* \param Node The name of the node the camera is transitioning relative to. Currently is
|
||||
* always the same as the camera's focus node
|
||||
* \param Transition The transition type that the camera just finished; is one of
|
||||
* `Approaching`, `Reaching`, `Receding`, or `Exiting`
|
||||
*/
|
||||
struct EventCameraFocusTransition : public Event {
|
||||
static const Type Type = Event::Type::CameraFocusTransition;
|
||||
|
||||
enum class Transition {
|
||||
Approaching,
|
||||
Reaching,
|
||||
Receding,
|
||||
Exiting
|
||||
};
|
||||
|
||||
EventCameraFocusTransition(const Camera* camera_, const SceneGraphNode* node_,
|
||||
Transition transition_);
|
||||
|
||||
const Camera* camera = nullptr;
|
||||
const tstring node;
|
||||
const Transition transition;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This event is created with a specific time of interest is reached. This event is
|
||||
* currently unused.
|
||||
*/
|
||||
struct EventTimeOfInterestReached : public Event {
|
||||
static const Type Type = Event::Type::TimeOfInterestReached;
|
||||
|
||||
EventTimeOfInterestReached(const Time* time_, const Camera* camera_);
|
||||
const Time* time = nullptr;
|
||||
const Camera* camera = nullptr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This event is created when the end of a mission phase is reached. This event is
|
||||
* currently unused.
|
||||
*/
|
||||
struct EventMissionEventReached : public Event {
|
||||
static const Type Type = Event::Type::MissionEventReached;
|
||||
|
||||
// Not sure which kind of parameters we want to pass here
|
||||
EventMissionEventReached();
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when a planet is eclipsed by a moon or a different planet. This
|
||||
* event is currently unused.
|
||||
*
|
||||
* \param Eclipsee The identifier of the scene graph node that is eclipsed by another
|
||||
* object
|
||||
* \param Eclipser The identifier of the scene graph node that is eclipsing the other
|
||||
* object
|
||||
*/
|
||||
struct EventPlanetEclipsed : public Event {
|
||||
static const Type Type = Event::Type::PlanetEclipsed;
|
||||
|
||||
EventPlanetEclipsed(const SceneGraphNode* eclipsee_, const SceneGraphNode* eclipser_);
|
||||
const tstring eclipsee;
|
||||
const tstring eclipser;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when the interpolation of a property value is finished. If the
|
||||
* interpolation time of a property change is 0s, this event is not fired
|
||||
*
|
||||
* \param Property The URI of the property whose interpolation has finished
|
||||
*/
|
||||
struct EventInterpolationFinished : public Event {
|
||||
static const Type Type = Event::Type::InterpolationFinished;
|
||||
|
||||
EventInterpolationFinished(const properties::Property* property_);
|
||||
const tstring property;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when the camera changes focus nodes. Even if the camera position
|
||||
* is interpolated, the node change happens instantaneously and the event is fired at the
|
||||
* same time.
|
||||
*
|
||||
* \param OldNode The identifier of the scene graph node which was the old focus node
|
||||
* \param NewNode The identifier of the scene graph node that is the new focus node
|
||||
*/
|
||||
struct EventFocusNodeChanged : public Event {
|
||||
static const Type Type = Event::Type::FocusNodeChanged;
|
||||
|
||||
EventFocusNodeChanged(const SceneGraphNode* oldNode_, const SceneGraphNode* newNode_);
|
||||
const tstring oldNode;
|
||||
const tstring newNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when a layer is added to to a globe.
|
||||
*
|
||||
* \param Globe The identifier of the globe to which the layer is added
|
||||
* \param Group The identifier of the layer group to which the layer is added
|
||||
* \param Layer The identifier of the layer that was added
|
||||
*/
|
||||
struct EventLayerAdded : public Event {
|
||||
static const Type Type = Event::Type::LayerAdded;
|
||||
|
||||
explicit EventLayerAdded(std::string_view node_, std::string_view layerGroup_,
|
||||
std::string_view layer_);
|
||||
const tstring node;
|
||||
const tstring layerGroup;
|
||||
const tstring layer;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when a layer is removed from a globe.
|
||||
*
|
||||
* \param Globe The identifier of the globe from which the layer is removed
|
||||
* \param Group The identifier of the layer group from which the layer is removed
|
||||
* \param Layer The identifier of the layer that was removed
|
||||
*/
|
||||
struct EventLayerRemoved : public Event {
|
||||
static const Type Type = Event::Type::LayerRemoved;
|
||||
|
||||
explicit EventLayerRemoved(std::string_view node_, std::string_view layerGroup_,
|
||||
std::string_view layer_);
|
||||
const tstring node;
|
||||
const tstring layerGroup;
|
||||
const tstring layer;
|
||||
};
|
||||
|
||||
/**
|
||||
* This event is created when something regarding a session recording playback changes.
|
||||
* The event contains information about the new state of the session recording subsystem.
|
||||
*
|
||||
* \param State The new state of the session recording; one of `Started`, `Paused`,
|
||||
* `Resumed`, `Finished`
|
||||
*/
|
||||
struct EventSessionRecordingPlayback : public Event {
|
||||
static const Type Type = Event::Type::SessionRecordingPlayback;
|
||||
|
||||
enum class State {
|
||||
Started,
|
||||
Paused,
|
||||
Resumed,
|
||||
Finished
|
||||
};
|
||||
|
||||
EventSessionRecordingPlayback(State state_);
|
||||
const State state;
|
||||
};
|
||||
|
||||
/**
|
||||
* A custom event type that can be used in a pinch when no explicit event type is
|
||||
* available. This should only be used in special circumstances and it should be
|
||||
* transitioned to a specific event type, if it is deemed to be useful.
|
||||
*/
|
||||
struct CustomEvent : public Event {
|
||||
static const Type Type = Event::Type::Custom;
|
||||
|
||||
CustomEvent(std::string_view subtype_, const void* payload_);
|
||||
|
||||
const tstring subtype;
|
||||
const void* payload = nullptr;
|
||||
};
|
||||
|
||||
} // namespace openspace::events
|
||||
|
||||
#endif // __OPENSPACE_CORE___EVENT___H__
|
||||
125
include/openspace/events/eventengine.h
Normal file
125
include/openspace/events/eventengine.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___EVENTENGINE___H__
|
||||
#define __OPENSPACE_CORE___EVENTENGINE___H__
|
||||
|
||||
#include <openspace/events/event.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <ghoul/misc/memorypool.h>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace events { struct Event; }
|
||||
|
||||
class EventEngine {
|
||||
public:
|
||||
/**
|
||||
* This function returns the first event stored in the EventEngine, or \c nullptr if
|
||||
* no event exists. To navigate the full list of events, you can access the returned
|
||||
* Event's next function. If the end of the list is reached, the next pointer will be
|
||||
* a nullptr
|
||||
*
|
||||
* \return The first event stored in the EventEngine or nullptr if no event exists
|
||||
*/
|
||||
events::Event* firstEvent() const;
|
||||
|
||||
/**
|
||||
* Publish a new event of type T by providing optional arguments Args to the Event's
|
||||
* constructor. An example of usage is
|
||||
* <code>engine.publishEvent<MyEvent>("a", 2.0);</code> which would call the
|
||||
* constructor of \c MyEvent with a <code>const char*</code> and \c double parameter.
|
||||
*
|
||||
* \param args The arguments that are passed to the constructor of T
|
||||
* \tparam T The subclass of Event that is to be published
|
||||
*/
|
||||
template <typename T, typename... Args>
|
||||
void publishEvent(Args&&... args);
|
||||
|
||||
/**
|
||||
* This function cleans up the memory for all published events.After this function
|
||||
* has been called, no previously published events are valid any longer. This means
|
||||
* that pointers retrieved from events before this call must be kept beyond this call.
|
||||
*/
|
||||
void postFrameCleanup();
|
||||
|
||||
/**
|
||||
* Registers a new action for a specific event type.
|
||||
*
|
||||
* \param type The type for which a new action is registered
|
||||
* \param actionIdentifier The identifier of the action that will be triggered the
|
||||
* identifier must not exist at this moment, but must exist by the time the
|
||||
* event is encountered next
|
||||
* \param filter If the filter is provided, it describes the event parameters that are
|
||||
* checked and only if an event passes the filter, the corresponding action is
|
||||
* triggered
|
||||
*/
|
||||
void registerEventAction(events::Event::Type type, std::string identifier,
|
||||
std::optional<ghoul::Dictionary> filter = std::nullopt);
|
||||
|
||||
/**
|
||||
* Removing registration for a type/action combination.
|
||||
*
|
||||
* \param type The type of the action that should be unregistered
|
||||
* \param actionIdentifier The identifier of the action that should be unregistered
|
||||
* \param filter The optional filter applied to the event-action combination
|
||||
*/
|
||||
void unregisterEventAction(events::Event::Type type,
|
||||
const std::string& identifier,
|
||||
std::optional<ghoul::Dictionary> filter = std::nullopt);
|
||||
|
||||
/**
|
||||
* Triggers all actions that are registered for events that are in the current event
|
||||
* queue
|
||||
*/
|
||||
void triggerActions() const;
|
||||
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
/// The storage space in which Events are stored
|
||||
ghoul::MemoryPool<4096> _memory;
|
||||
/// The first event in the chain of events stored in the memory pool
|
||||
events::Event* _firstEvent = nullptr;
|
||||
/// The last event in the chain of events stored in the memory pool
|
||||
events::Event* _lastEvent = nullptr;
|
||||
|
||||
struct ActionInfo {
|
||||
std::string action;
|
||||
std::optional<ghoul::Dictionary> filter;
|
||||
};
|
||||
std::unordered_map<events::Event::Type, std::vector<ActionInfo>> _eventActions;
|
||||
|
||||
#ifdef _DEBUG
|
||||
/// Stores the total number of events during this frame for debugging purposes
|
||||
static uint64_t nEvents;
|
||||
#endif // _DEBUG
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#include "eventengine.inl"
|
||||
|
||||
#endif // __OPENSPACE_CORE___EVENTENGINE___H__
|
||||
51
include/openspace/events/eventengine.inl
Normal file
51
include/openspace/events/eventengine.inl
Normal file
@@ -0,0 +1,51 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
template <typename T, typename... Args>
|
||||
void EventEngine::publishEvent(Args&&... args) {
|
||||
static_assert(
|
||||
std::is_base_of<events::Event, T>::value,
|
||||
"T must be a subclass of Event"
|
||||
);
|
||||
|
||||
T* e = _memory.alloc<T>(args...);
|
||||
if (!_firstEvent) {
|
||||
_firstEvent = e;
|
||||
_lastEvent = e;
|
||||
}
|
||||
else {
|
||||
_lastEvent->next = e;
|
||||
_lastEvent = e;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
nEvents++;
|
||||
#endif // _DEBUG
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -140,6 +140,7 @@ public:
|
||||
|
||||
private:
|
||||
void applyNavigationState(const NavigationState& ns);
|
||||
void updateCameraTransitions();
|
||||
|
||||
bool _playbackModeEnabled = false;
|
||||
|
||||
@@ -147,6 +148,10 @@ private:
|
||||
Camera* _camera = nullptr;
|
||||
std::function<void()> _playbackEndCallback;
|
||||
|
||||
inline static const double InteractionHystersis = 0.0125;
|
||||
bool _inAnchorApproachSphere = false;
|
||||
bool _inAnchorReachSphere = false;
|
||||
|
||||
OrbitalNavigator _orbitalNavigator;
|
||||
KeyframeNavigator _keyframeNavigator;
|
||||
PathNavigator _pathNavigator;
|
||||
|
||||
@@ -371,10 +371,10 @@ private:
|
||||
|
||||
/**
|
||||
* Orbit the current anchor node, in a right-bound orbit, by updating the position
|
||||
* and global rotation of the camera.
|
||||
*
|
||||
* and global rotation of the camera.
|
||||
*
|
||||
* Used for IdleBehavior::Behavior::Orbit
|
||||
*
|
||||
*
|
||||
* \param deltaTime The time step to use for the motion. Controls the rotation angle
|
||||
* \param position The position of the camera. Will be changed by the function
|
||||
* \param globalRotation The camera's global rotation. Will be changed by the function
|
||||
@@ -384,15 +384,15 @@ private:
|
||||
glm::dquat& globalRotation, double speedScale);
|
||||
|
||||
/**
|
||||
* Orbit the current anchor node, by adding a rotation around the given axis. For
|
||||
* example, when the axis is the north vector, the camera will stay on the current
|
||||
* latitude band. Note that this creates a rolling motion if the camera's forward
|
||||
* vector coincides with the axis, and should be used with care.
|
||||
*
|
||||
* Orbit the current anchor node, by adding a rotation around the given axis. For
|
||||
* example, when the axis is the north vector, the camera will stay on the current
|
||||
* latitude band. Note that this creates a rolling motion if the camera's forward
|
||||
* vector coincides with the axis, and should be used with care.
|
||||
*
|
||||
* Used for:
|
||||
* IdleBehavior::Behavior::OrbitAtConstantLat ( axis = north = z-axis ) and
|
||||
* IdleBehavior::Behavior::OrbitAroundUp ( axis = up = y-axis )
|
||||
*
|
||||
*
|
||||
* \param axis The axis to arbit around, given in model coordinates of the anchor
|
||||
* \param deltaTime The time step to use for the motion. Controls the rotation angle
|
||||
* \param position The position of the camera. Will be changed by the function
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
struct CameraPose;
|
||||
namespace openspace {
|
||||
struct CameraPose;
|
||||
} // namespace openspace
|
||||
|
||||
namespace openspace::interaction {
|
||||
@@ -44,10 +44,10 @@ public:
|
||||
Linear,
|
||||
ZoomOutOverview,
|
||||
AvoidCollisionWithLookAt // @TODO (2021-08-13, emmbr) This type right now leads
|
||||
// to rapid rotations, but is useful in specific
|
||||
// scenarios, e.g. close to surfaces. Later we want to
|
||||
// to rapid rotations, but is useful in specific
|
||||
// scenarios, e.g. close to surfaces. Later we want to
|
||||
// remove it, and create a curve type that looks nicely
|
||||
// at the targets when moving, avoids collisions and
|
||||
// at the targets when moving, avoids collisions and
|
||||
// doesn't introduce sudden large changes in rotation
|
||||
};
|
||||
|
||||
@@ -63,21 +63,21 @@ public:
|
||||
double pathLength() const;
|
||||
|
||||
/**
|
||||
* Return a vector of positions corresponding to the control points of the path's
|
||||
* Return a vector of positions corresponding to the control points of the path's
|
||||
* spline curve
|
||||
*/
|
||||
std::vector<glm::dvec3> controlPoints() const;
|
||||
|
||||
/**
|
||||
* Take a step along the current path, corresponding to the delta time step \p dt, and
|
||||
* return the resulting camera pose. The \p speedScale is a factor that will be
|
||||
* return the resulting camera pose. The \p speedScale is a factor that will be
|
||||
* multiplied with the traversal speed
|
||||
*/
|
||||
CameraPose traversePath(double dt, float speedScale = 1.f);
|
||||
|
||||
/**
|
||||
* Return the identifer of the node that is the current appropriate anchor node, of
|
||||
* the start and end waypoint's reference node. Dtermined based on how far along the
|
||||
* Return the identifer of the node that is the current appropriate anchor node, of
|
||||
* the start and end waypoint's reference node. Dtermined based on how far along the
|
||||
* path we have traveled
|
||||
*/
|
||||
std::string currentAnchor() const;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
private:
|
||||
/**
|
||||
* Interpolate between the paths start and end rotation using the approach that
|
||||
* Interpolate between the paths start and end rotation using the approach that
|
||||
* corresponds to the path's curve type. The interpolation parameter \p t is the
|
||||
* same as for the position interpolation, i.e. the relative traveled in distance
|
||||
* along the path, in [0, 1]
|
||||
@@ -107,14 +107,14 @@ private:
|
||||
glm::dquat easedSlerpRotation(double t) const;
|
||||
|
||||
/**
|
||||
* Compute the interpolated rotation quaternion using an approach that first
|
||||
* interpolates to look at the start node, and then the end node, before
|
||||
* Compute the interpolated rotation quaternion using an approach that first
|
||||
* interpolates to look at the start node, and then the end node, before
|
||||
* interpolating to the end rotation
|
||||
*/
|
||||
glm::dquat lookAtTargetsRotation(double t) const;
|
||||
|
||||
/**
|
||||
* Evaluate the current traversal speed along the path, based on the currently
|
||||
* Evaluate the current traversal speed along the path, based on the currently
|
||||
* traveled distance. The final speed will be scaled to match the desired duration
|
||||
* for the path (which might have been specified by the user)
|
||||
*/
|
||||
@@ -134,9 +134,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// Create a path of the given type based on an instruction given as a dictionary.
|
||||
// See top of cpp file for documentation on keys and values for the dictionary.
|
||||
// Returns the created path.
|
||||
// Create a path of the given type based on an instruction given as a dictionary.
|
||||
// See top of cpp file for documentation on keys and values for the dictionary.
|
||||
// Returns the created path.
|
||||
Path createPathFromDictionary(const ghoul::Dictionary& dictionary, Path::Type type);
|
||||
|
||||
} // namespace openspace::interaction
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
glm::dvec3 positionAt(double relativeDistance) const;
|
||||
|
||||
/**
|
||||
* Get the intorlatied position along the spline, based on the given curve parameter
|
||||
* u in range [0, 1]. A curve parameter of 0 returns the start position and 1 the end
|
||||
* position. Note that u does not correspond to the relatively traveled distance.
|
||||
* Get the intorlatied position along the spline, based on the given curve parameter
|
||||
* u in range [0, 1]. A curve parameter of 0 returns the start position and 1 the end
|
||||
* position. Note that u does not correspond to the relatively traveled distance.
|
||||
*/
|
||||
virtual glm::dvec3 interpolate(double u) const;
|
||||
|
||||
|
||||
@@ -45,4 +45,4 @@ private:
|
||||
|
||||
} // namespace openspace::interaction
|
||||
|
||||
#endif // __OPENSPACE_MODULE_AUTONAVIGATION___AVOIDCOLLISIONCURVE___H__
|
||||
#endif // __OPENSPACE_CORE___AVOIDCOLLISIONCURVE___H__
|
||||
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
private:
|
||||
CameraPose _pose;
|
||||
std::string _nodeIdentifier;
|
||||
double _validBoundingSphere = 0.0; // to be able to handle nodes with faulty bounding spheres
|
||||
// to be able to handle nodes with faulty bounding spheres
|
||||
double _validBoundingSphere = 0.0;
|
||||
};
|
||||
|
||||
} // namespace openspace::interaction
|
||||
|
||||
@@ -114,7 +114,8 @@ public:
|
||||
using TemplateProperty<std::set<std::string>>::operator=;
|
||||
|
||||
protected:
|
||||
std::set<std::string> fromLuaConversion(lua_State* state, bool& success) const override;
|
||||
std::set<std::string> fromLuaConversion(lua_State* state,
|
||||
bool& success) const override;
|
||||
|
||||
void toLuaConversion(lua_State* state) const override;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
const glm::dmat3& matrix() const;
|
||||
virtual glm::dmat3 matrix(const UpdateData& time) const = 0;
|
||||
void update(const UpdateData& data);
|
||||
virtual void update(const UpdateData& data);
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <ghoul/misc/easing.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <ghoul/misc/memorypool.h>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
@@ -46,6 +47,15 @@ namespace openspace {
|
||||
namespace documentation { struct Documentation; }
|
||||
namespace scripting { struct LuaLibrary; }
|
||||
|
||||
enum class PropertyValueType {
|
||||
Boolean = 0,
|
||||
Float,
|
||||
String,
|
||||
Table,
|
||||
Nil
|
||||
};
|
||||
using ProfilePropertyLua = std::variant<bool, float, std::string, ghoul::lua::nil_t>;
|
||||
|
||||
class SceneInitializer;
|
||||
|
||||
// Notifications:
|
||||
@@ -246,6 +256,59 @@ public:
|
||||
void setPropertiesFromProfile(const Profile& p);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Accepts string version of a property value from a profile, converts it to the
|
||||
* appropriate type, and then pushes the value onto the lua state.
|
||||
*
|
||||
* \param L the lua state to push value to
|
||||
* \param value string representation of the value with which to set property
|
||||
*/
|
||||
void propertyPushProfileValueToLua(ghoul::lua::LuaState& L, const std::string& value);
|
||||
|
||||
/**
|
||||
* Accepts string version of a property value from a profile, and processes it
|
||||
* according to the data type of the value
|
||||
*
|
||||
* \param L the lua state to (eventually) push to
|
||||
* \param value string representation of the value with which to set property
|
||||
* \param didPushToLua Bool reference that represents the lua push state at the end
|
||||
* of this function call. This will be set to true if the value (e.g. table)
|
||||
* has already been pushed to the lua stack
|
||||
* \return The ProfilePropertyLua variant type translated from string representation
|
||||
*/
|
||||
ProfilePropertyLua propertyProcessValue(ghoul::lua::LuaState& L,
|
||||
const std::string& value);
|
||||
|
||||
/**
|
||||
* Accepts string version of a property value from a profile, and returns the
|
||||
* supported data types that can be pushed to a lua state. Currently, the full
|
||||
* range of possible lua values is not supported.
|
||||
*
|
||||
* \param value string representation of the value with which to set property
|
||||
*/
|
||||
PropertyValueType propertyValueType(const std::string& value);
|
||||
|
||||
/**
|
||||
* Accepts string version of a property value from a profile, and adds it to a vector
|
||||
* which will later be used to push as a lua table containing values of type T
|
||||
*
|
||||
* \param L the lua state to (eventually) push to
|
||||
* \param value string representation of the value with which to set property
|
||||
* \param table the std::vector container which has elements of type T for a lua table
|
||||
*/
|
||||
template <typename T>
|
||||
void processPropertyValueTableEntries(ghoul::lua::LuaState& L,
|
||||
const std::string& value, std::vector<T>& table);
|
||||
|
||||
/**
|
||||
* Handles a lua table entry, creating a vector of the correct variable type based
|
||||
* on the profile string, and pushes this vector to the lua stack.
|
||||
*
|
||||
* \param L the lua state to (eventually) push to
|
||||
* \param value string representation of the value with which to set property
|
||||
*/
|
||||
void handlePropertyLuaTableEntry(ghoul::lua::LuaState& L, const std::string& value);
|
||||
|
||||
/**
|
||||
* Update dependencies.
|
||||
*/
|
||||
@@ -260,8 +323,9 @@ private:
|
||||
bool _dirtyNodeRegistry = false;
|
||||
SceneGraphNode _rootDummy;
|
||||
std::unique_ptr<SceneInitializer> _initializer;
|
||||
|
||||
std::string _profilePropertyName;
|
||||
std::vector<InterestingTime> _interestingTimes;
|
||||
bool _valueIsTable = false;
|
||||
|
||||
std::mutex _programUpdateLock;
|
||||
std::set<ghoul::opengl::ProgramObject*> _programsToUpdate;
|
||||
@@ -279,16 +343,6 @@ private:
|
||||
ghoul::MemoryPool<4096> _memoryPool;
|
||||
};
|
||||
|
||||
/**
|
||||
* Accepts string version of a property value from a profile, converts it to the
|
||||
* appropriate type, and then pushes the value onto the lua state.
|
||||
*
|
||||
* \param L the lua state to push value to
|
||||
* \param value string representation of the value with which to set property
|
||||
*/
|
||||
void propertyPushValueFromProfileToLuaState(ghoul::lua::LuaState& L,
|
||||
const std::string& value);
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___SCENE___H__
|
||||
|
||||
@@ -128,9 +128,17 @@ public:
|
||||
SceneGraphNode* parent() const;
|
||||
std::vector<SceneGraphNode*> children() const;
|
||||
|
||||
const std::vector<std::string>& onApproachAction() const;
|
||||
const std::vector<std::string>& onReachAction() const;
|
||||
const std::vector<std::string>& onRecedeAction() const;
|
||||
const std::vector<std::string>& onExitAction() const;
|
||||
|
||||
double boundingSphere() const;
|
||||
double interactionSphere() const;
|
||||
|
||||
double reachFactor() const;
|
||||
double approachFactor() const;
|
||||
|
||||
SceneGraphNode* childNode(const std::string& identifier);
|
||||
|
||||
const Renderable* renderable() const;
|
||||
@@ -155,6 +163,11 @@ private:
|
||||
std::vector<SceneGraphNode*> _dependentNodes;
|
||||
Scene* _scene = nullptr;
|
||||
|
||||
std::vector<std::string> _onApproachAction;
|
||||
std::vector<std::string> _onReachAction;
|
||||
std::vector<std::string> _onRecedeAction;
|
||||
std::vector<std::string> _onExitAction;
|
||||
|
||||
// If this value is 'true' GUIs are asked to hide this node from collections, as it
|
||||
// might be a node that is not very interesting (for example barycenters)
|
||||
properties::BoolProperty _guiHidden;
|
||||
@@ -183,6 +196,8 @@ private:
|
||||
|
||||
properties::DoubleProperty _boundingSphere;
|
||||
properties::DoubleProperty _interactionSphere;
|
||||
properties::DoubleProperty _approachFactor;
|
||||
properties::DoubleProperty _reachFactor;
|
||||
properties::BoolProperty _computeScreenSpaceValues;
|
||||
properties::IVec2Property _screenSpacePosition;
|
||||
properties::BoolProperty _screenVisibility;
|
||||
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
virtual ~Translation() = default;
|
||||
virtual bool initialize();
|
||||
|
||||
virtual void update(const UpdateData& data);
|
||||
glm::dvec3 position() const;
|
||||
void update(const UpdateData& data);
|
||||
|
||||
virtual glm::dvec3 position(const UpdateData& data) const = 0;
|
||||
|
||||
|
||||
@@ -357,7 +357,9 @@ constexpr double convertUnit(DistanceUnit fromUnit, DistanceUnit toUnit) {
|
||||
return convertMeters(toMeter(fromUnit), toUnit);
|
||||
}
|
||||
|
||||
constexpr double convertDistance(double distance, DistanceUnit fromUnit, DistanceUnit toUnit) {
|
||||
constexpr double convertDistance(double distance, DistanceUnit fromUnit,
|
||||
DistanceUnit toUnit)
|
||||
{
|
||||
return distance * convertUnit(fromUnit, toUnit);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace openspace {
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory;
|
||||
ghoul::MemoryPool<8 * 1024 * 1024> PersistentMemory;
|
||||
|
||||
// This should be replaced with a std::pmr::memory_resource wrapper around our own
|
||||
// Memory pool so that we can get a high-water mark out of it
|
||||
ghoul::MemoryPool<100 * 4096, false> TemporaryMemory;
|
||||
ghoul::MemoryPool<100 * 4096, false, true> TemporaryMemory;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
69
include/openspace/util/tstring.h
Normal file
69
include/openspace/util/tstring.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___TSTRING___H__
|
||||
#define __OPENSPACE_CORE___TSTRING___H__
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
/**
|
||||
* This string is a temporary string that is generated using the temporary memory
|
||||
* storage. This means that under no circumstances must an instance of a tstring be kept
|
||||
* across frame boundaries as the temporary storage is reset at between frames. In
|
||||
* exchange, the allocation of these objects is extreme fast and with barely any overhead
|
||||
* associated with it. The memory accessed through a tstring object shall never be
|
||||
* released manually.
|
||||
*/
|
||||
using tstring = std::string_view;
|
||||
|
||||
/**
|
||||
* Allocate and create a temporary string from the passed std::string.
|
||||
*
|
||||
* \param str The string to be copied into a newly allocated tstring
|
||||
* \return The copy of the str as a temporary string
|
||||
*/
|
||||
tstring temporaryString(const std::string& str);
|
||||
|
||||
/**
|
||||
* Allocate and create a temporary string from the passed std::string_view.
|
||||
*
|
||||
* \param str The string to be copied into a newly allocated tstring
|
||||
* \return The copy of the str as a temporary string
|
||||
*/
|
||||
tstring temporaryString(std::string_view str);
|
||||
|
||||
/**
|
||||
* Allocate and create a temporary string from the passed char array.
|
||||
*
|
||||
* \param str The string to be copied into a newly allocated tstring
|
||||
* \return The copy of the str as a temporary string
|
||||
*/
|
||||
tstring temporaryString(const char str[]);
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___TSTRING___H__
|
||||
Reference in New Issue
Block a user