OpenCSD - CoreSight Trace Decode Library 1.5.5
Loading...
Searching...
No Matches
ocsd_lib_dcd_register.h
Go to the documentation of this file.
1/*
2 * \file ocsd_lib_dcd_register.h
3 * \brief OpenCSD : Library decoder registration and management.
4 *
5 * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
6 */
7
8#ifndef ARM_OCSD_LIB_DCD_REGISTER_H_INCLUDED
9#define ARM_OCSD_LIB_DCD_REGISTER_H_INCLUDED
10
11
12/*
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 *
23 * 3. Neither the name of the copyright holder nor the names of its contributors
24 * may be used to endorse or promote products derived from this software without
25 * specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
31 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#include <map>
40
43
55{
56public:
58
59 static void deregisterAllDecoders();
62
63 const ocsd_err_t registerDecoderTypeByName(const std::string &name, IDecoderMngr *p_decoder_fact);
64 const ocsd_err_t getDecoderMngrByName(const std::string &name, IDecoderMngr **p_decoder_mngr);
65 const ocsd_err_t getDecoderMngrByType(const ocsd_trace_protocol_t decoderType, IDecoderMngr **p_decoder_mngr);
66
67 const bool isRegisteredDecoder(const std::string &name);
68 const bool getFirstNamedDecoder(std::string &name);
69 const bool getNextNamedDecoder(std::string &name);
70
71 const bool isRegisteredDecoderType(const ocsd_trace_protocol_t decoderType);
72
73private:
74 void registerBuiltInDecoders();
75 void deRegisterCustomDecoders();
76
77 std::map<const std::string, IDecoderMngr *> m_decoder_mngrs;
78 std::map<const std::string, IDecoderMngr *>::const_iterator m_iter;
79
80 std::map<const ocsd_trace_protocol_t, IDecoderMngr *> m_typed_decoder_mngrs;
81
82 // cache last found by type to speed up repeated quries on same object.
83 IDecoderMngr *m_pLastTypedDecoderMngr;
84
85
86
87 // singleton pattern - need just one of these in the library - ensure all default constructors are private.
90 OcsdLibDcdRegister& operator=(OcsdLibDcdRegister const &){ return *this; };
92
93 static OcsdLibDcdRegister *m_p_libMngr;
94 static bool m_b_registeredBuiltins;
95 static ocsd_trace_protocol_t m_nextCustomProtocolID;
96};
97
103typedef IDecoderMngr *(*CreateMngr)(const std::string &name);
104
112template <typename T> IDecoderMngr *createManagerInst(const std::string &name)
113{
114 return new (std::nothrow)T(name);
115}
116
125
127#define CREATE_BUILTIN_ENTRY(C,N) { 0, createManagerInst<C>, N }
128
129#endif // ARM_OCSD_LIB_DCD_REGISTER_H_INCLUDED
130
131/* End of File ocsd_lib_dcd_register.h */
const bool isRegisteredDecoder(const std::string &name)
const ocsd_err_t getDecoderMngrByType(const ocsd_trace_protocol_t decoderType, IDecoderMngr **p_decoder_mngr)
const ocsd_err_t registerDecoderTypeByName(const std::string &name, IDecoderMngr *p_decoder_fact)
register a decoder manager interface
static OcsdLibDcdRegister * getDecoderRegister()
const bool isRegisteredDecoderType(const ocsd_trace_protocol_t decoderType)
const ocsd_err_t getDecoderMngrByName(const std::string &name, IDecoderMngr **p_decoder_mngr)
static const ocsd_trace_protocol_t getNextCustomProtocolID()
static void releaseLastCustomProtocolID()
const bool getNextNamedDecoder(std::string &name)
const bool getFirstNamedDecoder(std::string &name)
static void deregisterAllDecoders()
library cleanup - deregisters decoder managers and destroys the register object.
enum _ocsd_trace_protocol_t ocsd_trace_protocol_t
enum _ocsd_err_t ocsd_err_t
OpenCSD : Standard Types used in the library interfaces.
struct built_in_decoder_info built_in_decoder_info_t
IDecoderMngr * createManagerInst(const std::string &name)
IDecoderMngr *(* CreateMngr)(const std::string &name)
IDecoderMngr * pMngr
pointer to created decoder manager
const char * name
registered name of the decoder.
CreateMngr PFn
function to create the decoder manager.