FPRInstrument.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. @class FPRClassInstrumentor;
  16. NS_ASSUME_NONNULL_BEGIN
  17. /** FPRInstrument instances can instrument many different classes, but should try to instrument
  18. * only a single class in the general case. Due to class clusters, FPRInstruments need to be able
  19. * to support logical groups of classes, even if the public API is a single class (e.g.
  20. * NSDictionary or NSURLSession. FPRInstrument is expected to be subclassed by other classes that
  21. * actually implement the instrument. Subclasses should provide their own implementations of
  22. * registerInstrumentor
  23. */
  24. @interface FPRInstrument : NSObject
  25. /** The list of class instrumentors. count should == 1 in most cases, and be > 1 for class clusters.
  26. */
  27. @property(nonatomic, readonly) NSArray<FPRClassInstrumentor *> *classInstrumentors;
  28. /** A set of the instrumented classes. */
  29. @property(nonatomic, readonly) NSSet<Class> *instrumentedClasses;
  30. /**
  31. * Checks if the given object is instrumentable and returns YES if instrumentable. NO, otherwise.
  32. *
  33. * @param object Object that needs to be validated.
  34. * @return Yes if instrumentable, NO otherwise.
  35. */
  36. - (BOOL)isObjectInstrumentable:(id)object;
  37. /** Registers all instrumentors this instrument will utilize. Should be instrumented in a subclass.
  38. *
  39. * @note This method is thread-safe.
  40. */
  41. - (void)registerInstrumentors;
  42. /** Deregisters the instrumentors by using API provided by FPRClassInstrumentor. Called by dealloc.
  43. *
  44. * @note This method is thread-safe.
  45. */
  46. - (void)deregisterInstrumentors;
  47. @end
  48. NS_ASSUME_NONNULL_END