diff options
Diffstat (limited to 'src/mongo/util/decorable.h')
-rw-r--r-- | src/mongo/util/decorable.h | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/src/mongo/util/decorable.h b/src/mongo/util/decorable.h index 780317e64f9..34fb4a78d87 100644 --- a/src/mongo/util/decorable.h +++ b/src/mongo/util/decorable.h @@ -65,57 +65,57 @@ namespace mongo { - template <typename D> - class Decorable { - MONGO_DISALLOW_COPYING(Decorable); +template <typename D> +class Decorable { + MONGO_DISALLOW_COPYING(Decorable); + +public: + template <typename T> + class Decoration { public: - template <typename T> - class Decoration { - public: - Decoration() = delete; + Decoration() = delete; - T& operator()(D& d) const { - return static_cast<Decorable&>(d)._decorations.getDecoration(_raw); - } + T& operator()(D& d) const { + return static_cast<Decorable&>(d)._decorations.getDecoration(_raw); + } - T& operator()(D* d) const { - return (*this)(*d); - } + T& operator()(D* d) const { + return (*this)(*d); + } - const T& operator()(const D& d) const { - return static_cast<const Decorable&>(d)._decorations.getDecoration(_raw); - } + const T& operator()(const D& d) const { + return static_cast<const Decorable&>(d)._decorations.getDecoration(_raw); + } - const T& operator()(const D* d) const { - return (*this)(*d); - } + const T& operator()(const D* d) const { + return (*this)(*d); + } - private: - friend class Decorable; + private: + friend class Decorable; - explicit Decoration(DecorationContainer::DecorationDescriptorWithType<T> raw) : - _raw(std::move(raw)) { - } + explicit Decoration(DecorationContainer::DecorationDescriptorWithType<T> raw) + : _raw(std::move(raw)) {} - DecorationContainer::DecorationDescriptorWithType<T> _raw; - }; + DecorationContainer::DecorationDescriptorWithType<T> _raw; + }; - template <typename T> - static Decoration<T> declareDecoration() { - return Decoration<T>(getRegistry()->declareDecoration<T>()); - } + template <typename T> + static Decoration<T> declareDecoration() { + return Decoration<T>(getRegistry()->declareDecoration<T>()); + } - protected: - Decorable() : _decorations(getRegistry()) {} - ~Decorable() = default; +protected: + Decorable() : _decorations(getRegistry()) {} + ~Decorable() = default; - private: - static DecorationRegistry* getRegistry() { - static DecorationRegistry* theRegistry = new DecorationRegistry(); - return theRegistry; - } +private: + static DecorationRegistry* getRegistry() { + static DecorationRegistry* theRegistry = new DecorationRegistry(); + return theRegistry; + } - DecorationContainer _decorations; - }; + DecorationContainer _decorations; +}; } // namespace mongo |