diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/util/decoration_container.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/util/decoration_container.h')
-rw-r--r-- | src/mongo/util/decoration_container.h | 167 |
1 files changed, 83 insertions, 84 deletions
diff --git a/src/mongo/util/decoration_container.h b/src/mongo/util/decoration_container.h index 4ef784d0d7e..b0318f7df37 100644 --- a/src/mongo/util/decoration_container.h +++ b/src/mongo/util/decoration_container.h @@ -35,97 +35,96 @@ namespace mongo { - class DecorationRegistry; +class DecorationRegistry; +/** + * An container for decorations. + */ +class DecorationContainer { + MONGO_DISALLOW_COPYING(DecorationContainer); + +public: /** - * An container for decorations. + * Opaque descriptor of a decoration. It is an identifier to a field on the + * DecorationContainer that is private to those modules that have access to the descriptor. */ - class DecorationContainer { - MONGO_DISALLOW_COPYING(DecorationContainer); + class DecorationDescriptor { public: + DecorationDescriptor() = default; + + private: + friend class DecorationContainer; + friend class DecorationRegistry; + + explicit DecorationDescriptor(size_t index) : _index(index) {} + + size_t _index; + }; - /** - * Opaque descriptor of a decoration. It is an identifier to a field on the - * DecorationContainer that is private to those modules that have access to the descriptor. - */ - class DecorationDescriptor { - public: - DecorationDescriptor() = default; - - private: - friend class DecorationContainer; - friend class DecorationRegistry; - - explicit DecorationDescriptor(size_t index) : _index(index) {} - - size_t _index; - }; - - /** - * Opaque description of a decoration of specified type T. It is an identifier to a field - * on the DecorationContainer that is private to those modules that have access to the - * descriptor. - */ - template <typename T> - class DecorationDescriptorWithType { - public: - DecorationDescriptorWithType() = default; - - private: - friend class DecorationContainer; - friend class DecorationRegistry; - - explicit DecorationDescriptorWithType(DecorationDescriptor raw) : - _raw(std::move(raw)) {} - - DecorationDescriptor _raw; - }; - - /** - * Constructs a decorable built based on the given "registry." - * - * The registry must stay in scope for the lifetime of the DecorationContainer, and must not - * have any declareDecoration() calls made on it while a DecorationContainer dependent on it - * is in scope. - */ - explicit DecorationContainer(const DecorationRegistry* registry); - ~DecorationContainer(); - - /** - * Gets the decorated value for the given descriptor. - * - * The descriptor must be one returned from this DecorationContainer's associated _registry. - */ - void* getDecoration(DecorationDescriptor descriptor) { - return _decorationData.get() + descriptor._index; - } - - /** - * Same as the non-const form above, but returns a const result. - */ - const void* getDecoration(DecorationDescriptor descriptor) const { - return _decorationData.get() + descriptor._index; - } - - /** - * Gets the decorated value or the given typed descriptor. - */ - template <typename T> - T& getDecoration(DecorationDescriptorWithType<T> descriptor) { - return *static_cast<T*>(getDecoration(descriptor._raw)); - } - - /** - * Same as the non-const form above, but returns a const result. - */ - template <typename T> - const T& getDecoration(DecorationDescriptorWithType<T> descriptor) const { - return *static_cast<const T*>(getDecoration(descriptor._raw)); - } + /** + * Opaque description of a decoration of specified type T. It is an identifier to a field + * on the DecorationContainer that is private to those modules that have access to the + * descriptor. + */ + template <typename T> + class DecorationDescriptorWithType { + public: + DecorationDescriptorWithType() = default; private: - const DecorationRegistry* const _registry; - const std::unique_ptr<unsigned char[]> _decorationData; + friend class DecorationContainer; + friend class DecorationRegistry; + + explicit DecorationDescriptorWithType(DecorationDescriptor raw) : _raw(std::move(raw)) {} + + DecorationDescriptor _raw; }; + /** + * Constructs a decorable built based on the given "registry." + * + * The registry must stay in scope for the lifetime of the DecorationContainer, and must not + * have any declareDecoration() calls made on it while a DecorationContainer dependent on it + * is in scope. + */ + explicit DecorationContainer(const DecorationRegistry* registry); + ~DecorationContainer(); + + /** + * Gets the decorated value for the given descriptor. + * + * The descriptor must be one returned from this DecorationContainer's associated _registry. + */ + void* getDecoration(DecorationDescriptor descriptor) { + return _decorationData.get() + descriptor._index; + } + + /** + * Same as the non-const form above, but returns a const result. + */ + const void* getDecoration(DecorationDescriptor descriptor) const { + return _decorationData.get() + descriptor._index; + } + + /** + * Gets the decorated value or the given typed descriptor. + */ + template <typename T> + T& getDecoration(DecorationDescriptorWithType<T> descriptor) { + return *static_cast<T*>(getDecoration(descriptor._raw)); + } + + /** + * Same as the non-const form above, but returns a const result. + */ + template <typename T> + const T& getDecoration(DecorationDescriptorWithType<T> descriptor) const { + return *static_cast<const T*>(getDecoration(descriptor._raw)); + } + +private: + const DecorationRegistry* const _registry; + const std::unique_ptr<unsigned char[]> _decorationData; +}; + } // namespace mongo |