OpenCSD - CoreSight Trace Decode Library
1.8.3
Toggle main menu visibility
Loading...
Searching...
No Matches
include
common
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
42
#include "
opencsd/ocsd_if_types.h
"
43
#include "
common/ocsd_dcd_mngr_i.h
"
44
55
class
OcsdLibDcdRegister
56
{
57
public
:
58
static
OcsdLibDcdRegister *
getDecoderRegister
();
59
60
static
void
deregisterAllDecoders
();
61
static
const
ocsd_trace_protocol_t
getNextCustomProtocolID
();
62
static
void
releaseLastCustomProtocolID
();
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
74
private
:
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
104
typedef
IDecoderMngr
*(*CreateMngr)(
const
std::string &name);
105
113
template
<
typename
T>
IDecoderMngr
*
createManagerInst
(
const
std::string &name)
114
{
115
return
new
(std::nothrow)T(name);
116
}
117
121
typedef
struct
built_in_decoder_info
{
122
IDecoderMngr
*
pMngr
;
123
CreateMngr
PFn
;
124
const
char
*
name
;
125
}
built_in_decoder_info_t
;
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 */
IDecoderMngr
Definition
ocsd_dcd_mngr_i.h:50
OcsdLibDcdRegister
Definition
ocsd_lib_dcd_register.h:56
OcsdLibDcdRegister::isRegisteredDecoder
const bool isRegisteredDecoder(const std::string &name)
OcsdLibDcdRegister::getDecoderMngrByType
const ocsd_err_t getDecoderMngrByType(const ocsd_trace_protocol_t decoderType, IDecoderMngr **p_decoder_mngr)
OcsdLibDcdRegister::registerDecoderTypeByName
const ocsd_err_t registerDecoderTypeByName(const std::string &name, IDecoderMngr *p_decoder_fact)
register a decoder manager interface
OcsdLibDcdRegister::getDecoderRegister
static OcsdLibDcdRegister * getDecoderRegister()
OcsdLibDcdRegister::isRegisteredDecoderType
const bool isRegisteredDecoderType(const ocsd_trace_protocol_t decoderType)
OcsdLibDcdRegister::getDecoderMngrByName
const ocsd_err_t getDecoderMngrByName(const std::string &name, IDecoderMngr **p_decoder_mngr)
OcsdLibDcdRegister::getNextCustomProtocolID
static const ocsd_trace_protocol_t getNextCustomProtocolID()
OcsdLibDcdRegister::releaseLastCustomProtocolID
static void releaseLastCustomProtocolID()
OcsdLibDcdRegister::getNextNamedDecoder
const bool getNextNamedDecoder(std::string &name)
OcsdLibDcdRegister::getFirstNamedDecoder
const bool getFirstNamedDecoder(std::string &name)
OcsdLibDcdRegister::deregisterAllDecoders
static void deregisterAllDecoders()
library cleanup - deregisters decoder managers and destroys the register object.
ocsd_trace_protocol_t
enum _ocsd_trace_protocol_t ocsd_trace_protocol_t
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
ocsd_dcd_mngr_i.h
ocsd_if_types.h
OpenCSD : Standard Types used in the library interfaces.
built_in_decoder_info_t
struct built_in_decoder_info built_in_decoder_info_t
createManagerInst
IDecoderMngr * createManagerInst(const std::string &name)
Definition
ocsd_lib_dcd_register.h:113
CreateMngr
IDecoderMngr *(* CreateMngr)(const std::string &name)
Definition
ocsd_lib_dcd_register.h:104
built_in_decoder_info
Definition
ocsd_lib_dcd_register.h:121
built_in_decoder_info::pMngr
IDecoderMngr * pMngr
pointer to created decoder manager
Definition
ocsd_lib_dcd_register.h:122
built_in_decoder_info::name
const char * name
registered name of the decoder.
Definition
ocsd_lib_dcd_register.h:124
built_in_decoder_info::PFn
CreateMngr PFn
function to create the decoder manager.
Definition
ocsd_lib_dcd_register.h:123
Generated on
for OpenCSD - CoreSight Trace Decode Library by
1.17.0