From 8792824960aa9fc8774c4f85735d1296a8a6d0aa Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Mon, 10 Dec 2018 09:58:59 -0800 Subject: [PATCH] Remove FormatSerializerRegister as it is unused --- .../hfm/src/hfm/FormatSerializerRegister.cpp | 29 --------------- .../hfm/src/hfm/FormatSerializerRegister.h | 35 ------------------- libraries/hfm/src/hfm/ModelFormatRegistry.cpp | 4 +-- libraries/hfm/src/hfm/ModelFormatRegistry.h | 4 +-- .../src/model-networking/ModelCache.h | 1 - 5 files changed, 3 insertions(+), 70 deletions(-) delete mode 100644 libraries/hfm/src/hfm/FormatSerializerRegister.cpp delete mode 100644 libraries/hfm/src/hfm/FormatSerializerRegister.h diff --git a/libraries/hfm/src/hfm/FormatSerializerRegister.cpp b/libraries/hfm/src/hfm/FormatSerializerRegister.cpp deleted file mode 100644 index 09c858b79d..0000000000 --- a/libraries/hfm/src/hfm/FormatSerializerRegister.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// FormatSerializerRegister.cpp -// libraries/hfm/src/hfm -// -// Created by Sabrina Shanman on 2018/12/07. -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "FormatSerializerRegister.h" - -#include "ModelFormatRegistry.h" - -namespace hfm { - -DoFormatSerializerRegister::DoFormatSerializerRegister(const MediaType& mediaType, std::unique_ptr factory) { - auto registry = DependencyManager::get(); - _mediaTypeID = registry->_hfmFormatRegistry.registerMediaType(mediaType, std::move(factory)); -} - -void DoFormatSerializerRegister::unregisterFormat() { - auto registry = DependencyManager::get(); - registry->_hfmFormatRegistry.unregisterMediaType(_mediaTypeID); - _mediaTypeID = hfm::FormatRegistry::INVALID_MEDIA_TYPE_ID; -} - -}; diff --git a/libraries/hfm/src/hfm/FormatSerializerRegister.h b/libraries/hfm/src/hfm/FormatSerializerRegister.h deleted file mode 100644 index 5971d678c8..0000000000 --- a/libraries/hfm/src/hfm/FormatSerializerRegister.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// FormatSerializerRegister.h -// libraries/hfm/src/hfm -// -// Created by Sabrina Shanman on 2018/11/30. -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_HFMFormat_h -#define hifi_HFMFormat_h - -#include "HFMFormatRegistry.h" -#include "HFMSerializer.h" - -namespace hfm { - // A helper class which allows early de-registration of a Serializer from ModelFormatRegistry - class FormatSerializerRegister { - public: - virtual void unregisterFormat() = 0; - }; - - class DoFormatSerializerRegister : public FormatSerializerRegister { - public: - DoFormatSerializerRegister(const MediaType& mediaType, std::unique_ptr factory); - - void unregisterFormat() override; - protected: - FormatRegistry::MediaTypeID _mediaTypeID { FormatRegistry::INVALID_MEDIA_TYPE_ID }; - }; -}; - -#endif // hifi_HFMFormat_h diff --git a/libraries/hfm/src/hfm/ModelFormatRegistry.cpp b/libraries/hfm/src/hfm/ModelFormatRegistry.cpp index 5520307a9b..b4d7c5849f 100644 --- a/libraries/hfm/src/hfm/ModelFormatRegistry.cpp +++ b/libraries/hfm/src/hfm/ModelFormatRegistry.cpp @@ -11,8 +11,8 @@ #include "ModelFormatRegistry.h" -std::unique_ptr ModelFormatRegistry::addFormat(const hfm::Serializer& serializer) { - return std::make_unique(serializer.getMediaType(), serializer.getFactory()); +void ModelFormatRegistry::addFormat(const hfm::Serializer& serializer) { + _hfmFormatRegistry.registerMediaType(serializer.getMediaType(), std::move(serializer.getFactory())); } std::shared_ptr ModelFormatRegistry::getSerializerForMediaType(const hifi::ByteArray& data, const hifi::URL& url, const std::string& webMediaType) const { diff --git a/libraries/hfm/src/hfm/ModelFormatRegistry.h b/libraries/hfm/src/hfm/ModelFormatRegistry.h index 4116869390..1228465298 100644 --- a/libraries/hfm/src/hfm/ModelFormatRegistry.h +++ b/libraries/hfm/src/hfm/ModelFormatRegistry.h @@ -12,18 +12,16 @@ #ifndef hifi_ModelFormatRegistry_h #define hifi_ModelFormatRegistry_h -#include "FormatSerializerRegister.h" #include "HFMFormatRegistry.h" #include class ModelFormatRegistry : public Dependency { public: - std::unique_ptr addFormat(const hfm::Serializer& serializer); + void addFormat(const hfm::Serializer& serializer); std::shared_ptr getSerializerForMediaType(const hifi::ByteArray& data, const hifi::URL& url, const std::string& webMediaType) const; protected: - friend class hfm::DoFormatSerializerRegister; hfm::FormatRegistry _hfmFormatRegistry; }; diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index 5f583d82d9..1018bdecd5 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -21,7 +21,6 @@ #include "FBXSerializer.h" #include "TextureCache.h" #include "ModelLoader.h" -#include "hfm/FormatSerializerRegister.h" // Alias instead of derive to avoid copying