1*02ca8ccaSAndroid Build Coastguard Worker /*! 2*02ca8ccaSAndroid Build Coastguard Worker * \file trc_component.h 3*02ca8ccaSAndroid Build Coastguard Worker * \brief OpenCSD : Base trace decode component. 4*02ca8ccaSAndroid Build Coastguard Worker * 5*02ca8ccaSAndroid Build Coastguard Worker * \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved. 6*02ca8ccaSAndroid Build Coastguard Worker */ 7*02ca8ccaSAndroid Build Coastguard Worker 8*02ca8ccaSAndroid Build Coastguard Worker 9*02ca8ccaSAndroid Build Coastguard Worker /* 10*02ca8ccaSAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without modification, 11*02ca8ccaSAndroid Build Coastguard Worker * are permitted provided that the following conditions are met: 12*02ca8ccaSAndroid Build Coastguard Worker * 13*02ca8ccaSAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright notice, 14*02ca8ccaSAndroid Build Coastguard Worker * this list of conditions and the following disclaimer. 15*02ca8ccaSAndroid Build Coastguard Worker * 16*02ca8ccaSAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright notice, 17*02ca8ccaSAndroid Build Coastguard Worker * this list of conditions and the following disclaimer in the documentation 18*02ca8ccaSAndroid Build Coastguard Worker * and/or other materials provided with the distribution. 19*02ca8ccaSAndroid Build Coastguard Worker * 20*02ca8ccaSAndroid Build Coastguard Worker * 3. Neither the name of the copyright holder nor the names of its contributors 21*02ca8ccaSAndroid Build Coastguard Worker * may be used to endorse or promote products derived from this software without 22*02ca8ccaSAndroid Build Coastguard Worker * specific prior written permission. 23*02ca8ccaSAndroid Build Coastguard Worker * 24*02ca8ccaSAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 25*02ca8ccaSAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26*02ca8ccaSAndroid Build Coastguard Worker * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27*02ca8ccaSAndroid Build Coastguard Worker * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28*02ca8ccaSAndroid Build Coastguard Worker * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29*02ca8ccaSAndroid Build Coastguard Worker * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30*02ca8ccaSAndroid Build Coastguard Worker * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 31*02ca8ccaSAndroid Build Coastguard Worker * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32*02ca8ccaSAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33*02ca8ccaSAndroid Build Coastguard Worker * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*02ca8ccaSAndroid Build Coastguard Worker */ 35*02ca8ccaSAndroid Build Coastguard Worker 36*02ca8ccaSAndroid Build Coastguard Worker #ifndef ARM_TRC_COMPONENT_H_INCLUDED 37*02ca8ccaSAndroid Build Coastguard Worker #define ARM_TRC_COMPONENT_H_INCLUDED 38*02ca8ccaSAndroid Build Coastguard Worker 39*02ca8ccaSAndroid Build Coastguard Worker #include <string> 40*02ca8ccaSAndroid Build Coastguard Worker #include "comp_attach_pt_t.h" 41*02ca8ccaSAndroid Build Coastguard Worker #include "interfaces/trc_error_log_i.h" 42*02ca8ccaSAndroid Build Coastguard Worker #include "ocsd_error.h" 43*02ca8ccaSAndroid Build Coastguard Worker 44*02ca8ccaSAndroid Build Coastguard Worker class errLogAttachMonitor; 45*02ca8ccaSAndroid Build Coastguard Worker 46*02ca8ccaSAndroid Build Coastguard Worker /** @addtogroup ocsd_infrastructure 47*02ca8ccaSAndroid Build Coastguard Worker @{*/ 48*02ca8ccaSAndroid Build Coastguard Worker 49*02ca8ccaSAndroid Build Coastguard Worker /*! 50*02ca8ccaSAndroid Build Coastguard Worker * @class TraceComponent 51*02ca8ccaSAndroid Build Coastguard Worker * @brief Base class for all decode components in the library. 52*02ca8ccaSAndroid Build Coastguard Worker * 53*02ca8ccaSAndroid Build Coastguard Worker * Provides error logging attachment point and component type and instance naming 54*02ca8ccaSAndroid Build Coastguard Worker * Interface for handling of component operational mode. 55*02ca8ccaSAndroid Build Coastguard Worker */ 56*02ca8ccaSAndroid Build Coastguard Worker class TraceComponent 57*02ca8ccaSAndroid Build Coastguard Worker { 58*02ca8ccaSAndroid Build Coastguard Worker public: 59*02ca8ccaSAndroid Build Coastguard Worker TraceComponent(const std::string &name); 60*02ca8ccaSAndroid Build Coastguard Worker TraceComponent(const std::string &name, int instIDNum); 61*02ca8ccaSAndroid Build Coastguard Worker virtual ~TraceComponent(); /**< Default Destructor */ 62*02ca8ccaSAndroid Build Coastguard Worker getComponentName()63*02ca8ccaSAndroid Build Coastguard Worker const std::string &getComponentName() const { return m_name; }; setComponentName(const std::string & name)64*02ca8ccaSAndroid Build Coastguard Worker void setComponentName(const std::string &name) { m_name = name; }; 65*02ca8ccaSAndroid Build Coastguard Worker 66*02ca8ccaSAndroid Build Coastguard Worker /** Error logger attachment point.*/ getErrorLogAttachPt()67*02ca8ccaSAndroid Build Coastguard Worker componentAttachPt<ITraceErrorLog> *getErrorLogAttachPt() { return &m_error_logger; }; 68*02ca8ccaSAndroid Build Coastguard Worker 69*02ca8ccaSAndroid Build Coastguard Worker /*! 70*02ca8ccaSAndroid Build Coastguard Worker * Set the operational mode for the component. 71*02ca8ccaSAndroid Build Coastguard Worker * This controls the way the component behaves under error conditions etc. 72*02ca8ccaSAndroid Build Coastguard Worker * These flags may also control output formats or data. 73*02ca8ccaSAndroid Build Coastguard Worker * Operation mode flags used are component specific and defined by derived classes. 74*02ca8ccaSAndroid Build Coastguard Worker * 75*02ca8ccaSAndroid Build Coastguard Worker * @param op_flags : Set of operation mode flags. 76*02ca8ccaSAndroid Build Coastguard Worker * 77*02ca8ccaSAndroid Build Coastguard Worker * @return ocsd_err_t : OCSD_OK if flags supported by this component, error if unsuppored 78*02ca8ccaSAndroid Build Coastguard Worker */ 79*02ca8ccaSAndroid Build Coastguard Worker ocsd_err_t setComponentOpMode(uint32_t op_flags); 80*02ca8ccaSAndroid Build Coastguard Worker 81*02ca8ccaSAndroid Build Coastguard Worker /*! 82*02ca8ccaSAndroid Build Coastguard Worker * Return the current operational mode flags values 83*02ca8ccaSAndroid Build Coastguard Worker * 84*02ca8ccaSAndroid Build Coastguard Worker * @return const uint32_t : Op Mode flags. 85*02ca8ccaSAndroid Build Coastguard Worker */ getComponentOpMode()86*02ca8ccaSAndroid Build Coastguard Worker const uint32_t getComponentOpMode() const { return m_op_flags; }; 87*02ca8ccaSAndroid Build Coastguard Worker 88*02ca8ccaSAndroid Build Coastguard Worker /*! 89*02ca8ccaSAndroid Build Coastguard Worker * Get the supported operational mode flags for this component. 90*02ca8ccaSAndroid Build Coastguard Worker * Base class will return nothing supported. 91*02ca8ccaSAndroid Build Coastguard Worker * Derived class must set the value correctly for the component. 92*02ca8ccaSAndroid Build Coastguard Worker * 93*02ca8ccaSAndroid Build Coastguard Worker * @return const uint32_t : Supported flags values. 94*02ca8ccaSAndroid Build Coastguard Worker */ getSupportedOpModes()95*02ca8ccaSAndroid Build Coastguard Worker const uint32_t getSupportedOpModes() const { return m_supported_op_flags; }; 96*02ca8ccaSAndroid Build Coastguard Worker 97*02ca8ccaSAndroid Build Coastguard Worker /*! 98*02ca8ccaSAndroid Build Coastguard Worker * Set associated trace component - used by generic code to track 99*02ca8ccaSAndroid Build Coastguard Worker * packet processor / packet decoder pairs. 100*02ca8ccaSAndroid Build Coastguard Worker * 101*02ca8ccaSAndroid Build Coastguard Worker * @param *assocComp : pointer to the associated component 102*02ca8ccaSAndroid Build Coastguard Worker */ setAssocComponent(TraceComponent * assocComp)103*02ca8ccaSAndroid Build Coastguard Worker void setAssocComponent(TraceComponent *assocComp) { m_assocComp = assocComp; }; 104*02ca8ccaSAndroid Build Coastguard Worker 105*02ca8ccaSAndroid Build Coastguard Worker 106*02ca8ccaSAndroid Build Coastguard Worker /*! 107*02ca8ccaSAndroid Build Coastguard Worker * get associated trace component pointer 108*02ca8ccaSAndroid Build Coastguard Worker * 109*02ca8ccaSAndroid Build Coastguard Worker * @return TraceComponent *: associated component. 110*02ca8ccaSAndroid Build Coastguard Worker */ getAssocComponent()111*02ca8ccaSAndroid Build Coastguard Worker TraceComponent *getAssocComponent() { return m_assocComp; }; 112*02ca8ccaSAndroid Build Coastguard Worker 113*02ca8ccaSAndroid Build Coastguard Worker /*! 114*02ca8ccaSAndroid Build Coastguard Worker * Log a message at the default severity on this component. 115*02ca8ccaSAndroid Build Coastguard Worker */ LogDefMessage(const std::string & msg)116*02ca8ccaSAndroid Build Coastguard Worker void LogDefMessage(const std::string &msg) 117*02ca8ccaSAndroid Build Coastguard Worker { 118*02ca8ccaSAndroid Build Coastguard Worker LogMessage(m_errVerbosity, msg); 119*02ca8ccaSAndroid Build Coastguard Worker } 120*02ca8ccaSAndroid Build Coastguard Worker 121*02ca8ccaSAndroid Build Coastguard Worker protected: 122*02ca8ccaSAndroid Build Coastguard Worker friend class errLogAttachMonitor; 123*02ca8ccaSAndroid Build Coastguard Worker 124*02ca8ccaSAndroid Build Coastguard Worker void LogError(const ocsdError &Error); 125*02ca8ccaSAndroid Build Coastguard Worker void LogMessage(const ocsd_err_severity_t filter_level, const std::string &msg); getErrorLogLevel()126*02ca8ccaSAndroid Build Coastguard Worker const ocsd_err_severity_t getErrorLogLevel() const { return m_errVerbosity; }; isLoggingErrorLevel(const ocsd_err_severity_t level)127*02ca8ccaSAndroid Build Coastguard Worker const bool isLoggingErrorLevel(const ocsd_err_severity_t level) const { return level <= m_errVerbosity; }; 128*02ca8ccaSAndroid Build Coastguard Worker void updateErrorLogLevel(); 129*02ca8ccaSAndroid Build Coastguard Worker 130*02ca8ccaSAndroid Build Coastguard Worker void do_attach_notify(const int num_attached); 131*02ca8ccaSAndroid Build Coastguard Worker void Init(const std::string &name); 132*02ca8ccaSAndroid Build Coastguard Worker 133*02ca8ccaSAndroid Build Coastguard Worker uint32_t m_op_flags; //!< current component operational mode flags. 134*02ca8ccaSAndroid Build Coastguard Worker uint32_t m_supported_op_flags; //!< supported component operational mode flags - derived class to intialise. 135*02ca8ccaSAndroid Build Coastguard Worker 136*02ca8ccaSAndroid Build Coastguard Worker private: 137*02ca8ccaSAndroid Build Coastguard Worker componentAttachPt<ITraceErrorLog> m_error_logger; 138*02ca8ccaSAndroid Build Coastguard Worker ocsd_hndl_err_log_t m_errLogHandle; 139*02ca8ccaSAndroid Build Coastguard Worker ocsd_err_severity_t m_errVerbosity; 140*02ca8ccaSAndroid Build Coastguard Worker errLogAttachMonitor *m_pErrAttachMon; 141*02ca8ccaSAndroid Build Coastguard Worker 142*02ca8ccaSAndroid Build Coastguard Worker std::string m_name; 143*02ca8ccaSAndroid Build Coastguard Worker 144*02ca8ccaSAndroid Build Coastguard Worker TraceComponent *m_assocComp; //!< associated component -> if this is a pkt decoder, associated pkt processor. 145*02ca8ccaSAndroid Build Coastguard Worker }; 146*02ca8ccaSAndroid Build Coastguard Worker /** @}*/ 147*02ca8ccaSAndroid Build Coastguard Worker #endif // ARM_TRC_COMPONENT_H_INCLUDED 148*02ca8ccaSAndroid Build Coastguard Worker 149*02ca8ccaSAndroid Build Coastguard Worker /* End of File trc_component.h */ 150