NvElement.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of NVIDIA CORPORATION nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  23. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  24. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. /**
  29. * @file
  30. * <b>NVIDIA Multimedia API: %NvElement Base Class</b>
  31. *
  32. * @b This file declares the NvElement base class.
  33. */
  34. #ifndef __NV_ELEMENT_H__
  35. #define __NV_ELEMENT_H__
  36. #include <iostream>
  37. #include <sys/time.h>
  38. #include <stdint.h>
  39. #include <string.h>
  40. #include "NvElementProfiler.h"
  41. /**
  42. *
  43. * @defgroup l4t_mm_nvelement_base_group NvElement Base Class
  44. * @ingroup l4t_mm_nvelement_group
  45. *
  46. * This class is the class from which both V4L2 and non-V4L2
  47. * components are derived.
  48. *
  49. * @{
  50. */
  51. /**
  52. * Every element has a unique name that can be used for identifying
  53. * the element in debug logs.
  54. *
  55. * @c %NvElement also provides other common functionality, such as keeping
  56. * track of errors.
  57. */
  58. class NvElement
  59. {
  60. public:
  61. /**
  62. * Indicates whether the element encountered an error during its operation.
  63. *
  64. * @return 0 if no error was encountered, a non-zero value if an
  65. * error was encountered.
  66. */
  67. virtual int isInError()
  68. {
  69. return is_in_error;
  70. }
  71. virtual ~NvElement()
  72. {
  73. }
  74. /**
  75. * Gets profiling data for the element.
  76. *
  77. * @return A constant reference to the element's profiling data.
  78. */
  79. void getProfilingData(NvElementProfiler::NvElementProfilerData &data);
  80. /**
  81. * Prints profiling data for the element to an output stream.
  82. *
  83. * @param[in] out_stream Output stream of type std::ostream to print the
  84. * data to. It takes the default value std::cout if not specified.
  85. */
  86. void printProfilingStats(std::ostream &out_stream = std::cout);
  87. /**
  88. * Enables profiling for the element.
  89. */
  90. virtual void enableProfiling();
  91. /**
  92. * Checks whether profiling is enabled for the element.
  93. *
  94. * @return Boolean value indicating if profiling is enabled.
  95. */
  96. bool isProfilingEnabled();
  97. protected:
  98. /**
  99. * Creates a new NvElement object with name @a name.
  100. *
  101. * If the @a name parameter is NULL, this method sets the internal
  102. * error variable.
  103. *
  104. * @param[in] name If non-NULL, a pointer to the name of the
  105. * element.
  106. */
  107. NvElement(const char *name, NvElementProfiler::ProfilerField = NvElementProfiler::PROFILER_FIELD_NONE);
  108. int is_in_error; /**< Indicates if an error was encountered during
  109. the operation of the element. */
  110. const char *comp_name; /**< Specifies the name of the component,
  111. for debugging. */
  112. NvElementProfiler profiler; /**< Profiler for the element. */
  113. /**
  114. * Disallows copy constructor.
  115. */
  116. NvElement(const NvElement& that);
  117. /**
  118. * Disallows assignment.
  119. */
  120. void operator=(NvElement const&);
  121. };
  122. /** @} */
  123. #endif