OpenCSD - CoreSight Trace Decode Library 1.8.3
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#include <new>
41
44
55class OcsdLibDcdRegister
56{
57public:
58 static OcsdLibDcdRegister *getDecoderRegister();
59
60 static void deregisterAllDecoders();
63
64 const ocsd_err_t registerDecoderTypeByName(const std::string &name, IDecoderMngr *p_decoder_fact);
65 const ocsd_err_t getDecoderMngrByName(const std::string &name, IDecoderMngr **p_decoder_mngr);
66 const ocsd_err_t getDecoderMngrByType(const ocsd_trace_protocol_t decoderType, IDecoderMngr **p_decoder_mngr);
67
68 const bool isRegisteredDecoder(const std::string &name);
69 const bool getFirstNamedDecoder(std::string &name);
70 const bool getNextNamedDecoder(std::string &name);
71
72 const bool isRegisteredDecoderType(const ocsd_trace_protocol_t decoderType);
73
74private:
75 void registerBuiltInDecoders();
76 void deRegisterCustomDecoders();
77
78 std::map<const std::string, IDecoderMngr *> m_decoder_mngrs;
79 std::map<const std::string, IDecoderMngr *>::const_iterator m_iter;
80
81 std::map<const ocsd_trace_protocol_t, IDecoderMngr *> m_typed_decoder_mngrs;
82
83 // cache last found by type to speed up repeated quries on same object.
84 IDecoderMngr *m_pLastTypedDecoderMngr;
85
86
87
88 // singleton pattern - need just one of these in the library - ensure all default constructors are private.
89 OcsdLibDcdRegister();
90 OcsdLibDcdRegister(OcsdLibDcdRegister const &) {};
91 OcsdLibDcdRegister& operator=(OcsdLibDcdRegister const &){ return *this; };
92 ~OcsdLibDcdRegister();
93
94 static OcsdLibDcdRegister *m_p_libMngr;
95 static bool m_b_registeredBuiltins;
96 static ocsd_trace_protocol_t m_nextCustomProtocolID;
97};
98
104typedef IDecoderMngr *(*CreateMngr)(const std::string &name);
105
113template <typename T> IDecoderMngr *createManagerInst(const std::string &name)
114{
115 return new (std::nothrow)T(name);
116}
117
126
128#define CREATE_BUILTIN_ENTRY(C,N) { 0, createManagerInst<C>, N }
129
130#endif // ARM_OCSD_LIB_DCD_REGISTER_H_INCLUDED
131
132/* 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.