00001 /* 00002 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of NVIDIA CORPORATION nor the names of its 00013 * contributors may be used to endorse or promote products derived 00014 * from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 00017 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00019 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00020 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00021 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00022 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00023 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00024 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00026 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 /** 00030 * @file 00031 * <b>NVIDIA Eagle Eye API: NvElement Base Class</b> 00032 * 00033 * @b This file declares the NvElement base class. 00034 */ 00035 00036 #ifndef __NV_ELEMENT_H__ 00037 #define __NV_ELEMENT_H__ 00038 00039 #include <iostream> 00040 #include <sys/time.h> 00041 #include <stdint.h> 00042 #include <string.h> 00043 00044 #include "NvElementProfiler.h" 00045 00046 /** 00047 * 00048 * @defgroup ee_nvelement_base_group NvElement Base Class 00049 * @ingroup ee_nvelement_group 00050 * 00051 * This class is the class from which both V4L2 and non-V4L2 00052 * components are derived. 00053 * 00054 * @{ 00055 */ 00056 /** 00057 * Every element has a unique name that can be used for identifying 00058 * the element in debug logs. 00059 * 00060 * @c %NvElement also provides other common functionality, such as keeping 00061 * track of errors. 00062 */ 00063 class NvElement 00064 { 00065 public: 00066 /** 00067 * Indicates if the element encountered an error during its operation. 00068 * 00069 * @return 0 if no error was encountered, a non-zero value if an 00070 * error was encountered. 00071 */ 00072 virtual int isInError() 00073 { 00074 return is_in_error; 00075 } 00076 virtual ~NvElement() 00077 { 00078 } 00079 00080 /** 00081 * Get profiling data for the element. 00082 * 00083 * @return A constant reference to the element's profiling data. 00084 */ 00085 void getProfilingData(NvElementProfiler::NvElementProfilerData &data); 00086 00087 /** 00088 * Print profiling data for the element to an output stream. 00089 * 00090 * @param[in] out_stream Output stream of type std::ostream to print the 00091 * data to. Takes default value std::cout if not specified. 00092 */ 00093 void printProfilingStats(std::ostream &out_stream = std::cout); 00094 00095 /** 00096 * Enable profiling for the element. 00097 */ 00098 virtual void enableProfiling(); 00099 00100 /** 00101 * Check if profiling has been enabled for the element. 00102 * 00103 * @return Boolean value indicating if profiling has been enabled. 00104 */ 00105 bool isProfilingEnabled(); 00106 00107 protected: 00108 00109 /** 00110 * Creates a new NvElement object with name @a name. 00111 * 00112 * If the @a name parameter is NULL, this method sets the internal 00113 * error variable. 00114 * 00115 * @param[in] name If non-NULL, a pointer to the name of the 00116 * element. 00117 */ 00118 NvElement(const char *name, NvElementProfiler::ProfilerField = NvElementProfiler::PROFILER_FIELD_NONE); 00119 00120 int is_in_error; /**< Indicates if an error was encountered during 00121 the operation of the element. */ 00122 const char *comp_name; /**< Specifies the name of the component, 00123 for debugging. */ 00124 NvElementProfiler profiler; /**< Profiler for the element. */ 00125 00126 /** 00127 * Disallow copy constructor. 00128 */ 00129 NvElement(const NvElement& that); 00130 /** 00131 * Disallow assignment. 00132 */ 00133 void operator=(NvElement const&); 00134 00135 }; 00136 /** @} */ 00137 #endif