mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 15:43:24 +02:00
Revise scriptable resource caches' interfaces
This commit is contained in:
parent
16e06de9cd
commit
baf88ab508
15 changed files with 54 additions and 54 deletions
|
@ -32,8 +32,8 @@
|
|||
#include <udt/PacketHeaders.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <ScriptCache.h>
|
||||
#include <SoundCacheScriptingInterface.h>
|
||||
#include <ScriptEngines.h>
|
||||
#include <SoundCacheScriptingInterface.h>
|
||||
#include <SoundCache.h>
|
||||
#include <UsersScriptingInterface.h>
|
||||
#include <UUID.h>
|
||||
|
@ -72,6 +72,7 @@ Agent::Agent(ReceivedMessage& message) :
|
|||
|
||||
DependencyManager::set<ResourceCacheSharedItems>();
|
||||
DependencyManager::set<SoundCache>();
|
||||
DependencyManager::set<SoundCacheScriptingInterface>();
|
||||
DependencyManager::set<AudioScriptingInterface>();
|
||||
DependencyManager::set<AudioInjectorManager>();
|
||||
|
||||
|
@ -456,8 +457,8 @@ void Agent::executeScript() {
|
|||
// register ourselves to the script engine
|
||||
_scriptEngine->registerGlobalObject("Agent", this);
|
||||
|
||||
_scriptEngine->registerGlobalObject("SoundCache", new SoundCacheScriptingInterface(DependencyManager::get<SoundCache>().data()));
|
||||
_scriptEngine->registerGlobalObject("AnimationCache", new AnimationCacheScriptingInterface(DependencyManager::get<AnimationCache>().data()));
|
||||
_scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
|
||||
_scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||
|
||||
QScriptValue webSocketServerConstructorValue = _scriptEngine->newFunction(WebSocketServerClass::constructor);
|
||||
_scriptEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
|
||||
|
@ -846,6 +847,7 @@ void Agent::aboutToFinish() {
|
|||
DependencyManager::destroy<ScriptEngines>();
|
||||
|
||||
DependencyManager::destroy<ResourceCacheSharedItems>();
|
||||
DependencyManager::destroy<SoundCacheScriptingInterface>();
|
||||
DependencyManager::destroy<SoundCache>();
|
||||
DependencyManager::destroy<AudioScriptingInterface>();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <shared/QtHelpers.h>
|
||||
#include <AccountManager.h>
|
||||
#include <AddressManager.h>
|
||||
#include <AnimationCacheScriptingInterface.h>
|
||||
#include <Assignment.h>
|
||||
#include <AvatarHashMap.h>
|
||||
#include <EntityScriptingInterface.h>
|
||||
|
@ -63,6 +64,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
|
|||
auto nodeList = DependencyManager::set<NodeList>(NodeType::Unassigned, listenPort);
|
||||
|
||||
auto animationCache = DependencyManager::set<AnimationCache>();
|
||||
DependencyManager::set<AnimationCacheScriptingInterface>();
|
||||
auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>(false);
|
||||
|
||||
DependencyManager::registerInheritance<EntityDynamicFactoryInterface, AssignmentDynamicFactory>();
|
||||
|
|
|
@ -66,6 +66,7 @@ EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssig
|
|||
|
||||
DependencyManager::set<ResourceCacheSharedItems>();
|
||||
DependencyManager::set<SoundCache>();
|
||||
DependencyManager::set<SoundCacheScriptingInterface>();
|
||||
DependencyManager::set<AudioInjectorManager>();
|
||||
|
||||
DependencyManager::set<ScriptCache>();
|
||||
|
@ -438,7 +439,7 @@ void EntityScriptServer::resetEntitiesScriptEngine() {
|
|||
auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor);
|
||||
newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
|
||||
|
||||
newEngine->registerGlobalObject("SoundCache", new SoundCacheScriptingInterface(DependencyManager::get<SoundCache>().data()));
|
||||
newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||
|
||||
// connect this script engines printedMessage signal to the global ScriptEngines these various messages
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
|
||||
|
|
|
@ -869,16 +869,20 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
DependencyManager::set<recording::ClipCache>();
|
||||
DependencyManager::set<GeometryCache>();
|
||||
DependencyManager::set<ModelCache>();
|
||||
DependencyManager::set<ModelCacheScriptingInterface>();
|
||||
DependencyManager::set<ScriptCache>();
|
||||
DependencyManager::set<SoundCache>();
|
||||
DependencyManager::set<SoundCacheScriptingInterface>();
|
||||
DependencyManager::set<DdeFaceTracker>();
|
||||
DependencyManager::set<EyeTracker>();
|
||||
DependencyManager::set<AudioClient>();
|
||||
DependencyManager::set<AudioScope>();
|
||||
DependencyManager::set<DeferredLightingEffect>();
|
||||
DependencyManager::set<TextureCache>();
|
||||
DependencyManager::set<TextureCacheScriptingInterface>();
|
||||
DependencyManager::set<FramebufferCache>();
|
||||
DependencyManager::set<AnimationCache>();
|
||||
DependencyManager::set<AnimationCacheScriptingInterface>();
|
||||
DependencyManager::set<ModelBlender>();
|
||||
DependencyManager::set<UsersScriptingInterface>();
|
||||
DependencyManager::set<AvatarManager>();
|
||||
|
@ -2565,12 +2569,18 @@ Application::~Application() {
|
|||
|
||||
DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache
|
||||
|
||||
DependencyManager::destroy<SoundCacheScriptingInterface>();
|
||||
|
||||
DependencyManager::destroy<AvatarManager>();
|
||||
DependencyManager::destroy<AnimationCacheScriptingInterface>();
|
||||
DependencyManager::destroy<AnimationCache>();
|
||||
DependencyManager::destroy<FramebufferCache>();
|
||||
DependencyManager::destroy<TextureCacheScriptingInterface>();
|
||||
DependencyManager::destroy<TextureCache>();
|
||||
DependencyManager::destroy<ModelCacheScriptingInterface>();
|
||||
DependencyManager::destroy<ModelCache>();
|
||||
DependencyManager::destroy<ScriptCache>();
|
||||
DependencyManager::destroy<SoundCacheScriptingInterface>();
|
||||
DependencyManager::destroy<SoundCache>();
|
||||
DependencyManager::destroy<OctreeStatsProvider>();
|
||||
DependencyManager::destroy<GeometryCache>();
|
||||
|
@ -2992,10 +3002,11 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
|
|||
surfaceContext->setContextProperty("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data());
|
||||
|
||||
// Caches
|
||||
surfaceContext->setContextProperty("AnimationCache", new AnimationCacheScriptingInterface(DependencyManager::get<AnimationCache>().data()));
|
||||
surfaceContext->setContextProperty("TextureCache", new TextureCacheScriptingInterface(DependencyManager::get<TextureCache>().data()));
|
||||
surfaceContext->setContextProperty("ModelCache", new ModelCacheScriptingInterface(DependencyManager::get<ModelCache>().data()));
|
||||
surfaceContext->setContextProperty("SoundCache", new SoundCacheScriptingInterface(DependencyManager::get<SoundCache>().data()));
|
||||
surfaceContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
|
||||
surfaceContext->setContextProperty("TextureCache", DependencyManager::get<TextureCacheScriptingInterface>().data());
|
||||
surfaceContext->setContextProperty("ModelCache", DependencyManager::get<ModelCacheScriptingInterface>().data());
|
||||
surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||
|
||||
surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
|
||||
|
||||
surfaceContext->setContextProperty("Account", AccountServicesScriptingInterface::getInstance()); // DEPRECATED - TO BE REMOVED
|
||||
|
@ -6615,10 +6626,10 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
|||
scriptEngine->registerGlobalObject("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
|
||||
|
||||
// Caches
|
||||
scriptEngine->registerGlobalObject("AnimationCache", new AnimationCacheScriptingInterface(DependencyManager::get<AnimationCache>().data()));
|
||||
scriptEngine->registerGlobalObject("TextureCache", new TextureCacheScriptingInterface(DependencyManager::get<TextureCache>().data()));
|
||||
scriptEngine->registerGlobalObject("ModelCache", new ModelCacheScriptingInterface(DependencyManager::get<ModelCache>().data()));
|
||||
scriptEngine->registerGlobalObject("SoundCache", new SoundCacheScriptingInterface(DependencyManager::get<SoundCache>().data()));
|
||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("TextureCache", DependencyManager::get<TextureCacheScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCacheScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface);
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ void Web3DOverlay::setupQmlSurface() {
|
|||
_webSurface->getSurfaceContext()->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("SoundCache", new SoundCacheScriptingInterface(DependencyManager::get<SoundCache>().data()));
|
||||
_webSurface->getSurfaceContext()->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
|
||||
#include "AnimationCacheScriptingInterface.h"
|
||||
|
||||
AnimationCacheScriptingInterface::AnimationCacheScriptingInterface(AnimationCache* animationCache) :
|
||||
_animationCache(animationCache),
|
||||
ScriptableResourceCache::ScriptableResourceCache(animationCache)
|
||||
AnimationCacheScriptingInterface::AnimationCacheScriptingInterface() :
|
||||
ScriptableResourceCache::ScriptableResourceCache(DependencyManager::get<AnimationCache>())
|
||||
{ }
|
||||
|
||||
AnimationPointer AnimationCacheScriptingInterface::getAnimation(const QUrl& url) {
|
||||
return _animationCache->getAnimation(url);
|
||||
}
|
||||
return DependencyManager::get<AnimationCache>()->getAnimation(url);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "AnimationCache.h"
|
||||
|
||||
class AnimationCacheScriptingInterface : public ScriptableResourceCache {
|
||||
class AnimationCacheScriptingInterface : public ScriptableResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
// Properties are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
@ -44,7 +44,7 @@ class AnimationCacheScriptingInterface : public ScriptableResourceCache {
|
|||
*/
|
||||
|
||||
public:
|
||||
AnimationCacheScriptingInterface(AnimationCache* animationCache);
|
||||
AnimationCacheScriptingInterface();
|
||||
|
||||
/**jsdoc
|
||||
* Returns animation resource for particular animation.
|
||||
|
@ -54,9 +54,6 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
||||
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
|
||||
|
||||
private:
|
||||
AnimationCache* _animationCache;
|
||||
};
|
||||
|
||||
#endif // hifi_AnimationCacheScriptingInterface_h
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
|
||||
#include "SoundCacheScriptingInterface.h"
|
||||
|
||||
SoundCacheScriptingInterface::SoundCacheScriptingInterface(SoundCache* soundCache) :
|
||||
_soundCache(soundCache),
|
||||
ScriptableResourceCache::ScriptableResourceCache(soundCache)
|
||||
SoundCacheScriptingInterface::SoundCacheScriptingInterface() :
|
||||
ScriptableResourceCache::ScriptableResourceCache(DependencyManager::get<SoundCache>())
|
||||
{ }
|
||||
|
||||
SharedSoundPointer SoundCacheScriptingInterface::getSound(const QUrl& url) {
|
||||
return _soundCache->getSound(url);
|
||||
return DependencyManager::get<SoundCache>()->getSound(url);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "SoundCache.h"
|
||||
|
||||
class SoundCacheScriptingInterface : public ScriptableResourceCache {
|
||||
class SoundCacheScriptingInterface : public ScriptableResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
// Properties are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
@ -45,7 +45,7 @@ class SoundCacheScriptingInterface : public ScriptableResourceCache {
|
|||
*/
|
||||
|
||||
public:
|
||||
SoundCacheScriptingInterface(SoundCache* soundCache);
|
||||
SoundCacheScriptingInterface();
|
||||
|
||||
/**jsdoc
|
||||
* @function SoundCache.getSound
|
||||
|
@ -53,9 +53,6 @@ public:
|
|||
* @returns {SoundObject}
|
||||
*/
|
||||
Q_INVOKABLE SharedSoundPointer getSound(const QUrl& url);
|
||||
|
||||
private:
|
||||
SoundCache* _soundCache;
|
||||
};
|
||||
|
||||
#endif // hifi_SoundCacheScriptingInterface_h
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "ModelCacheScriptingInterface.h"
|
||||
|
||||
ModelCacheScriptingInterface::ModelCacheScriptingInterface(ModelCache* modelCache) :
|
||||
_ModelCache(modelCache),
|
||||
ScriptableResourceCache::ScriptableResourceCache(modelCache)
|
||||
ModelCacheScriptingInterface::ModelCacheScriptingInterface() :
|
||||
ScriptableResourceCache::ScriptableResourceCache(DependencyManager::get<ModelCache>())
|
||||
{ }
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "ModelCache.h"
|
||||
|
||||
class ModelCacheScriptingInterface : public ScriptableResourceCache {
|
||||
class ModelCacheScriptingInterface : public ScriptableResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
// Properties are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
@ -43,10 +43,7 @@ class ModelCacheScriptingInterface : public ScriptableResourceCache {
|
|||
*/
|
||||
|
||||
public:
|
||||
ModelCacheScriptingInterface(ModelCache* modelCache);
|
||||
|
||||
private:
|
||||
ModelCache* _ModelCache;
|
||||
ModelCacheScriptingInterface();
|
||||
};
|
||||
|
||||
#endif // hifi_ModelCacheScriptingInterface_h
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
|
||||
#include "TextureCacheScriptingInterface.h"
|
||||
|
||||
TextureCacheScriptingInterface::TextureCacheScriptingInterface(TextureCache* textureCache) :
|
||||
_textureCache(textureCache),
|
||||
ScriptableResourceCache::ScriptableResourceCache(textureCache)
|
||||
TextureCacheScriptingInterface::TextureCacheScriptingInterface() :
|
||||
ScriptableResourceCache::ScriptableResourceCache(DependencyManager::get<TextureCache>())
|
||||
{
|
||||
connect(_textureCache, &TextureCache::spectatorCameraFramebufferReset,
|
||||
connect(DependencyManager::get<TextureCache>().data(), &TextureCache::spectatorCameraFramebufferReset,
|
||||
this, &TextureCacheScriptingInterface::spectatorCameraFramebufferReset);
|
||||
}
|
||||
|
||||
ScriptableResource* TextureCacheScriptingInterface::prefetch(const QUrl& url, int type, int maxNumPixels) {
|
||||
return _textureCache->prefetch(url, type, maxNumPixels);
|
||||
return DependencyManager::get<TextureCache>()->prefetch(url, type, maxNumPixels);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "TextureCache.h"
|
||||
|
||||
class TextureCacheScriptingInterface : public ScriptableResourceCache {
|
||||
class TextureCacheScriptingInterface : public ScriptableResourceCache, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
// Properties are copied over from ResourceCache (see ResourceCache.h for reason).
|
||||
|
@ -43,7 +43,7 @@ class TextureCacheScriptingInterface : public ScriptableResourceCache {
|
|||
*/
|
||||
|
||||
public:
|
||||
TextureCacheScriptingInterface(TextureCache* textureCache);
|
||||
TextureCacheScriptingInterface();
|
||||
|
||||
/**jsdoc
|
||||
* @function TextureCache.prefetch
|
||||
|
@ -60,9 +60,6 @@ signals:
|
|||
* @returns {Signal}
|
||||
*/
|
||||
void spectatorCameraFramebufferReset();
|
||||
|
||||
private:
|
||||
TextureCache* _textureCache;
|
||||
};
|
||||
|
||||
#endif // hifi_TextureCacheScriptingInterface_h
|
||||
|
|
|
@ -132,7 +132,7 @@ QSharedPointer<Resource> ResourceCacheSharedItems::getHighestPendingRequest() {
|
|||
}
|
||||
|
||||
|
||||
ScriptableResourceCache::ScriptableResourceCache(ResourceCache* resourceCache) {
|
||||
ScriptableResourceCache::ScriptableResourceCache(QSharedPointer<ResourceCache> resourceCache) {
|
||||
_resourceCache = resourceCache;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ private:
|
|||
class ScriptableResourceCache : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
// JSDoc 3.5.5 doesn't augment namespaces with @property definitions so the following properties JSDoc is copied to the
|
||||
// JSDoc 3.5.5 doesn't augment name spaces with @property definitions so the following properties JSDoc is copied to the
|
||||
// different exposed cache classes.
|
||||
|
||||
/**jsdoc
|
||||
|
@ -318,7 +318,7 @@ class ScriptableResourceCache : public QObject {
|
|||
Q_PROPERTY(size_t sizeCached READ getSizeCachedResources NOTIFY dirty)
|
||||
|
||||
public:
|
||||
ScriptableResourceCache(ResourceCache* resourceCache);
|
||||
ScriptableResourceCache(QSharedPointer<ResourceCache> resourceCache);
|
||||
|
||||
/**jsdoc
|
||||
* Get the list of all resource URLs.
|
||||
|
@ -351,7 +351,7 @@ signals:
|
|||
void dirty();
|
||||
|
||||
private:
|
||||
ResourceCache * _resourceCache;
|
||||
QSharedPointer<ResourceCache> _resourceCache;
|
||||
|
||||
size_t getNumTotalResources() const { return _resourceCache->getNumTotalResources(); }
|
||||
size_t getSizeTotalResources() const { return _resourceCache->getSizeTotalResources(); }
|
||||
|
|
Loading…
Reference in a new issue