RCTComponentViewDescriptor.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIKit.h>
  8. #import <React/RCTComponentViewProtocol.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. /*
  11. * Holds a native view instance and a set of attributes associated with it.
  12. * Mounting infrastructure uses these objects to bookkeep views and cache their
  13. * attributes for efficient access.
  14. */
  15. class RCTComponentViewDescriptor final {
  16. public:
  17. /*
  18. * Associated (and owned) native view instance.
  19. */
  20. __strong UIView<RCTComponentViewProtocol> *view = nil;
  21. /*
  22. * Indicates a requirement to call on the view methods from
  23. * `RCTMountingTransactionObserving` protocol.
  24. */
  25. bool observesMountingTransactionWillMount{false};
  26. bool observesMountingTransactionDidMount{false};
  27. };
  28. inline bool operator==(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
  29. {
  30. return lhs.view == rhs.view;
  31. }
  32. inline bool operator!=(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
  33. {
  34. return lhs.view != rhs.view;
  35. }
  36. template <>
  37. struct std::hash<RCTComponentViewDescriptor> {
  38. size_t operator()(RCTComponentViewDescriptor const &componentViewDescriptor) const
  39. {
  40. return std::hash<void *>()((__bridge void *)componentViewDescriptor.view);
  41. }
  42. };
  43. NS_ASSUME_NONNULL_END