blob: 48270add033ddced3da8b4b56546869271dc9337 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/trace/compdesc.H $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2012 */
/* */
/* p1 */
/* */
/* Object Code Only (OCO) source materials */
/* Licensed Internal Code Source Materials */
/* IBM HostBoot Licensed Internal Code */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __TRACE_COMPDESC_H
#define __TRACE_COMPDESC_H
/** @file compdesc.H
*
* @brief Defines the classes for component descriptors and a singleton list
* of descriptors.
*/
#include <trace/interface.H>
#include <sys/sync.h>
#include <list>
namespace TRACEDAEMON { class Daemon; } // Forward declaration.
namespace TRACE
{
class Entry; // Forward declaration.
/** @class ComponentDesc
*
* @brief The descriptor for a particular component.
*
* @note These should not be created directly, but by the ComponentList
* interfaces.
*/
class ComponentDesc
{
public:
friend class ComponentList;
friend class Service;
friend class Buffer;
friend class TRACEDAEMON::Daemon;
private:
/** Constructor
*
* @param[in] i_comp - Component name.
* @param[in] i_size - Size limit of buffer.
* @param[in] i_bufferType - Type of buffer this component is
* assigned to.
*/
ComponentDesc(const char* i_comp, uint32_t i_size,
uint8_t i_bufferType = BUFFER_FAST);
/** Max ength of component names. */
enum { COMP_SIZE = TRAC_COMP_SIZE };
char iv_compName[COMP_SIZE]; //< Component name.
uint8_t iv_compNameLen; //< Length in bytes of name.
uint8_t iv_bufferType; //< Buffer type.
bool iv_debugEnabled; //< Debug or Field-only traces.
uint32_t iv_maxSize; //< Size limit.
uint32_t iv_curSize; //< Current size.
Entry* iv_first; //< First (newest) trace entry.
Entry* iv_last; //< Last (oldest) trace entry.
};
/** @class ComponentList
*
* @brief Maintains the global list of component trace descriptors.
*
* It is expected that a singleton instance of this exists and all
* trace descriptors are allocated from it.
*/
class ComponentList
{
public:
typedef std::list<ComponentDesc> List;
/** Default constructor */
ComponentList();
/** Default destructor */
~ComponentList();
/** Get descriptor for a component
*
* @param[in] i_comp - Name of the component.
* @param[in] i_size - Size limit of buffer.
* @param[in] i_bufferType - Buffer type.
*
* If i_size is 0, that implies this is not "creating" a buffer
* but "requesting" the buffer, for instance to pass to the
* buffer-extract functions. In that case, if the buffer does
* not currently exist we don't know what size-limit to use
* when creating the buffer, so the function will return NULL.
*
* @return Descriptor or NULL.
*/
ComponentDesc* getDescriptor(const char* i_comp, uint32_t i_size,
uint8_t i_bufferType = BUFFER_FAST);
/* Thread-safe iterator functions (for daemon). */
/** Get the first component descriptor
*
* @param[out] o_comp - Iterator to first component.
*
* @return bool - True if empty-list.
*/
bool first(List::iterator& o_comp);
/** Get the next component descriptor
*
* @param[in,out] io_comp - Iterator to increment.
*
* @return bool - True if iterator was the last descriptor.
*
* Ex. "if (io_comp->next == iv_components.end()) return true"
*/
bool next(List::iterator& io_comp);
private:
/** List of component descriptors. */
List iv_components;
/** Mutex for thread-safety. */
mutex_t iv_mutex;
};
}
#endif
|